Fix xml danmaku content (fix #2875)

This commit is contained in:
the1812 2022-01-15 15:16:33 +08:00
parent a486792ea8
commit bc5be9fcce
2 changed files with 8 additions and 5 deletions

File diff suppressed because one or more lines are too long

View File

@ -247,9 +247,12 @@ export const getBlobByType = async (type: DanmakuDownloadType, input: {
const danmaku = await new JsonDanmaku(aid, cid).fetchInfo()
switch (type) {
case 'xml': {
return new Blob([
danmaku.xmlDanmakus.map(x => new XmlDanmaku(x).text()).join('\n'),
], {
const xmlText = `
<?xml version="1.0" encoding="UTF-8"?><i><chatserver>chat.bilibili.com</chatserver><chatid>${cid}</chatid><mission>0</mission><maxlimit>${danmaku.xmlDanmakus.length}</maxlimit><state>0</state><real_name>0</real_name><source>k-v</source>
${danmaku.xmlDanmakus.map(x => new XmlDanmaku(x).text()).join('\n')}
</i>
`.trim()
return new Blob([xmlText], {
type: 'text/xml',
})
}