Created
January 25, 2021 15:23
-
-
Save Patrick-web/16df216fc7e58a6b46c4c644dad37a28 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var https = require("follow-redirects").https; | |
var fs = require("fs"); | |
var options = { | |
method: "GET", | |
hostname: "www.megalobiz.com", | |
path: | |
"/lrc/maker/download-music-lyrics-lrc-generated-files?qry=helplessly%20tatiana%20manaois", | |
maxRedirects: 20, | |
}; | |
var req = https.request(options, function (res) { | |
var chunks = []; | |
res.on("data", function (chunk) { | |
chunks.push(chunk); | |
}); | |
res.on("end", function (chunk) { | |
var body = Buffer.concat(chunks); | |
// console.log(body.toString()); | |
const regex = /\[00:03.05].*\"\;/gm; | |
const str = ``; | |
let m; | |
while ((m = regex.exec(body)) !== null) { | |
if (m.index === regex.lastIndex) { | |
regex.lastIndex++; | |
} | |
const lyricStrings = m[0].replace(/\\n/gm,'__').split('__'); | |
lyricStrings.forEach(string=>{ | |
const strip = string.split(']'); | |
const lyricStrip = { | |
timestamp: strip[0].replace('[',''), | |
text:strip[1].replace(/"/g,'') | |
} | |
console.log(lyricStrip); | |
}) | |
} | |
}); | |
res.on("error", function (error) { | |
console.error(error); | |
}); | |
}); | |
req.end(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment