Skip to content

Instantly share code, notes, and snippets.

@Patrick-web
Last active January 25, 2021 15:31
Show Gist options
  • Select an option

  • Save Patrick-web/572adaef6b66497f9d881e2db3c5c489 to your computer and use it in GitHub Desktop.

Select an option

Save Patrick-web/572adaef6b66497f9d881e2db3c5c489 to your computer and use it in GitHub Desktop.
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) {
const lyricsData = [];
var body = Buffer.concat(chunks);
const regex = /\[00:03.05].*\"\;/gm;
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, ""),
};
lyricsData.push(lyricStrip);
});
}
console.clear();
console.log(lyricsData);
});
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