bugfix 解决极少数album没有标题,正则匹配失败问题
This commit is contained in:
parent
6f359ae080
commit
6b560ef47a
@ -1,7 +1,7 @@
|
|||||||
if (process.argv.length <= 2) {
|
if (process.argv.length <= 2) {
|
||||||
let output = [
|
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",
|
// "node index --utils xxx --min xxx --max xxx --order ASC --limit 2000",
|
||||||
].join('\n');
|
].join('\n');
|
||||||
|
@ -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);
|
let regExResult = /\<script type\=\"application\/ld\+json\"\>([\S\s]*?)\<\/script\>/.exec(html);
|
||||||
let albumInfoJSONString = regExResult[1];
|
if (regExResult) {
|
||||||
let albumInfoDict = JSON.parse(albumInfoJSONString);
|
let albumInfoJSONString = regExResult[1];
|
||||||
|
albumInfoDict = JSON.parse(albumInfoJSONString);
|
||||||
|
} else {
|
||||||
|
// 极少数album没有 <script type="application/ld+json">......</script> 这块内容
|
||||||
|
// 例如:71715963,71738618。这些album都没有标题,所以下面这三项就直接保留空字符串
|
||||||
|
albumInfoDict = {
|
||||||
|
"title": "",
|
||||||
|
"description": "",
|
||||||
|
"pubDate": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
// console.log(albumInfoDict);
|
// console.log(albumInfoDict);
|
||||||
|
|
||||||
// 发行公司
|
// 发行公司
|
||||||
|
Loading…
Reference in New Issue
Block a user