From 8758022ad9a0ac5ebe610c88c2d975833419b19b Mon Sep 17 00:00:00 2001 From: yhsphd Date: Mon, 7 Aug 2023 10:04:09 +0900 Subject: [PATCH] Initial Release --- .gitignore | 8 ++++ .gitmodules | 3 ++ README.md | 9 ++++- lib/fast-xml-parser | 1 + searcher/ALSong.js | 98 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 .gitignore create mode 100644 .gitmodules create mode 160000 lib/fast-xml-parser create mode 100644 searcher/ALSong.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4b2b431 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +* + +!*/ + +!/.gitignore +!/.gitmodules +!/lib/fast-xml-parser/* +!/searcher/ALSong.js \ No newline at end of file diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..6fe62d9 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "lib/fast-xml-parser"] + path = lib/fast-xml-parser + url = https://github.com/NaturalIntelligence/fast-xml-parser.git diff --git a/README.md b/README.md index 458b3cc..ca5d252 100644 --- a/README.md +++ b/README.md @@ -1 +1,8 @@ -# scripts +# Alsong Lyrics Searcher for ESLyrics +## Installation + +Copy `searcher` and `lib` folders to `scripts` folder of ESLyrics(Typically located at `%APPDATA%\foobar2000\eslyric-data`). Select to merge folders if prompted. + +## 설치 방법 + +`searcher`와 `lib` 폴더를 ESLyrics의 `scripts` 폴더에 넣으세요. ESLyrics 폴더는 일반적으로 `%APPDATA%\foobar2000\eslyric-data` 에 존재합니다. 폴더를 합칠지 물어보는 경우 합치기를 선택하세요. \ No newline at end of file diff --git a/lib/fast-xml-parser b/lib/fast-xml-parser new file mode 160000 index 0000000..ecf6016 --- /dev/null +++ b/lib/fast-xml-parser @@ -0,0 +1 @@ +Subproject commit ecf6016f9b48aec1a921e673158be0773d07283e diff --git a/searcher/ALSong.js b/searcher/ALSong.js new file mode 100644 index 0000000..84a07ab --- /dev/null +++ b/searcher/ALSong.js @@ -0,0 +1,98 @@ +/* + +*/ + +export function getConfig(cfg) { + cfg.name = "ALSong"; + cfg.version = "0.1"; + cfg.author = "yhsphd"; +} + +export function getLyrics(meta, man) { + if (meta.duration === 0) { + return; + } + + evalLib("fast-xml-parser/lib/fxparser.min.js"); + + const url = "http://lyrics.alsong.co.kr/alsongwebservice/service1.asmx"; + + const requestHeaders = { + "Accept-Charset": "utf-8", + "Content-Type": "application/soap+xml", + "User-Agent": "gSOAP/2.7", + "SOAPAction": "AlsongWebServer/GetResembleLyric2" + }; + + const encData = "8456ec35caba5c981e705b0c5d76e4593e020ae5e3d469c75d1c6714b6b1244c0732f1f19cc32ee5123ef7de574fc8bc6d3b6bd38dd3c097f5a4a1aa1b438fea0e413baf8136d2d7d02bfcdcb2da4990df2f28675a3bd621f8234afa84fb4ee9caa8f853a5b06f884ea086fd3ed3b4c6e14f1efac5a4edbf6f6cb475445390b0"; + + /*meta.title = "ずっとずっとずっと"; + meta.artist = "緑黄色社会";*/ + + const requestBody = ` + + + + ${encData} + ${meta.title} + ${meta.artist} + 0 + + + + `; + + const settings = { + url: url, + method: "POST", + headers: requestHeaders, + body: requestBody + }; + + request(settings, (err, res, body) => { + if (err || res.statusCode !== 200) { + log(res.statusCode); + return; + } + + let candidates; + try { + const parser = new XMLParser({ignoreAttributes: false}); + let parsed = parser.parse(body)["soap:Envelope"]["soap:Body"].GetResembleLyric2Response.GetResembleLyric2Result; + + if (!parsed.hasOwnProperty("ST_GET_RESEMBLELYRIC2_RETURN")) { + return; + } + + candidates = parsed.ST_GET_RESEMBLELYRIC2_RETURN; + for (let i = 0; i < candidates.length; i++) { + candidates[i].strLyric = candidates[i].strLyric.replaceAll("
", "\n"); + } + + log(JSON.stringify(candidates)); + } catch (e) { + log("parse exception: " + e.message); + } + + let lyricMeta = man.createLyric(); + for (const candidate of candidates) { + if (man.checkAbort()) { + return; + } + + lyricMeta.title = candidate.strTitle; + lyricMeta.artist = candidate.strArtistName; + lyricMeta.album = candidate.strAlbumName; + lyricMeta.lyricText = candidate.strLyric; + man.addLyric(lyricMeta); + } + }); +} + +function log(str) { + console.log("[alsong]" + str); +}