1
0
Code Issues Pull Requests Projects Releases Wiki Activity GitHub Gitee

bugfix 解决极少数album没有标题,正则匹配失败问题

This commit is contained in:
程序员小墨 2022-10-31 15:54:48 +08:00
parent 6f359ae080
commit 6b560ef47a
2 changed files with 14 additions and 3 deletions

View File

@ -1,7 +1,7 @@
if (process.argv.length <= 2) {
let output = [
"参数不够",
"node index --utils [song|album|artist|lyric|comment] --min [number] --max [number] --order [false|ASC|DESC] --limit [number]",
"node index --utils [song|album|artist|lyric|comment|playlist|assistant] --min [number] --max [number] --order [false|ASC|DESC] --limit [number]",
// "",
// "node index --utils xxx --min xxx --max xxx --order ASC --limit 2000",
].join('\n');

View File

@ -82,9 +82,20 @@ async function fetch({ albumId, debug = false, update = false }) {
}
// 正则匹配
let albumInfoDict;
let regExResult = /\<script type\=\"application\/ld\+json\"\>([\S\s]*?)\<\/script\>/.exec(html);
if (regExResult) {
let albumInfoJSONString = regExResult[1];
let albumInfoDict = JSON.parse(albumInfoJSONString);
albumInfoDict = JSON.parse(albumInfoJSONString);
} else {
// 极少数album没有 <script type="application/ld+json">......</script> 这块内容
// 例如7171596371738618。这些album都没有标题所以下面这三项就直接保留空字符串
albumInfoDict = {
"title": "",
"description": "",
"pubDate": ""
}
}
// console.log(albumInfoDict);
// 发行公司