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

@@ -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 albumInfoJSONString = regExResult[1];
let albumInfoDict = JSON.parse(albumInfoJSONString);
if (regExResult) {
let albumInfoJSONString = regExResult[1];
albumInfoDict = JSON.parse(albumInfoJSONString);
} else {
// 极少数album没有 <script type="application/ld+json">......</script> 这块内容
// 例如7171596371738618。这些album都没有标题所以下面这三项就直接保留空字符串
albumInfoDict = {
"title": "",
"description": "",
"pubDate": ""
}
}
// console.log(albumInfoDict);
// 发行公司