mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-10 21:06:15 -08:00
Update bilibili.js
This commit is contained in:
1 parent
0184683682
commit
b0ac1eaaaa
1 file changed
+4
-4
@@ -15,8 +15,8 @@ export function getMode(key) {
|
||||
export function bilibiliDanmuParseFromXml(xmlString) {
|
||||
if (typeof xmlString !== 'string') return [];
|
||||
const srtList = xmlString.match(/<d([\S ]*?>[\S ]*?)<\/d>/gi);
|
||||
return srtList.length
|
||||
? srtList.map(item => {
|
||||
return srtList && srtList.length
|
||||
? srtList.map((item) => {
|
||||
const [, attrStr, text] = item.match(/<d p="(.+)">(.+)<\/d>/);
|
||||
const attr = attrStr.split(',');
|
||||
return attr.length === 8 && text.trim()
|
||||
@@ -38,6 +38,6 @@ export function bilibiliDanmuParseFromXml(xmlString) {
|
||||
|
||||
export function bilibiliDanmuParseFromUrl(url) {
|
||||
return fetch(url)
|
||||
.then(res => res.text())
|
||||
.then(xmlString => bilibiliDanmuParseFromXml(xmlString));
|
||||
.then((res) => res.text())
|
||||
.then((xmlString) => bilibiliDanmuParseFromXml(xmlString));
|
||||
}
|
||||
Reference in new issue
Block a user