mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-27 17:51:20 -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) {
|
export function bilibiliDanmuParseFromXml(xmlString) {
|
||||||
if (typeof xmlString !== 'string') return [];
|
if (typeof xmlString !== 'string') return [];
|
||||||
const srtList = xmlString.match(/<d([\S ]*?>[\S ]*?)<\/d>/gi);
|
const srtList = xmlString.match(/<d([\S ]*?>[\S ]*?)<\/d>/gi);
|
||||||
return srtList.length
|
return srtList && srtList.length
|
||||||
? srtList.map(item => {
|
? srtList.map((item) => {
|
||||||
const [, attrStr, text] = item.match(/<d p="(.+)">(.+)<\/d>/);
|
const [, attrStr, text] = item.match(/<d p="(.+)">(.+)<\/d>/);
|
||||||
const attr = attrStr.split(',');
|
const attr = attrStr.split(',');
|
||||||
return attr.length === 8 && text.trim()
|
return attr.length === 8 && text.trim()
|
||||||
@@ -38,6 +38,6 @@ export function bilibiliDanmuParseFromXml(xmlString) {
|
|||||||
|
|
||||||
export function bilibiliDanmuParseFromUrl(url) {
|
export function bilibiliDanmuParseFromUrl(url) {
|
||||||
return fetch(url)
|
return fetch(url)
|
||||||
.then(res => res.text())
|
.then((res) => res.text())
|
||||||
.then(xmlString => bilibiliDanmuParseFromXml(xmlString));
|
.then((xmlString) => bilibiliDanmuParseFromXml(xmlString));
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user