mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
Improve video shot performance
This commit is contained in:
parent
221d6d160a
commit
286cf881f5
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
2
min/touch-player.min.js
vendored
2
min/touch-player.min.js
vendored
File diff suppressed because one or more lines are too long
@ -303,45 +303,24 @@
|
||||
{
|
||||
constructor()
|
||||
{
|
||||
const url = window.location.href;
|
||||
const aidMatch = url.match(/av([\d]+)/);
|
||||
this.aid = aidMatch[1];
|
||||
const pageMatch = url.match(/p=([\d]+)/);
|
||||
this.page = pageMatch ? pageMatch[1] : 1;
|
||||
|
||||
this.pagesData = null;
|
||||
this.cidMap = {};
|
||||
this.cidData = {};
|
||||
this.aid = unsafeWindow.aid;
|
||||
this.cid = unsafeWindow.cid;
|
||||
this.cidData = null;
|
||||
this.supportWebp = VideoShot.supportWebp;
|
||||
|
||||
downloadText(url, html => this.findCid(html));
|
||||
}
|
||||
findCid(html)
|
||||
{
|
||||
const match = html.match(/"pages":(\[[^\0]*\]),"embedPlayer"/);
|
||||
if (match)
|
||||
{
|
||||
this.pagesData = JSON.parse(match[1]);
|
||||
this.pagesData.forEach(pageData =>
|
||||
{
|
||||
this.cidMap[pageData.page] = pageData.cid;
|
||||
});
|
||||
}
|
||||
}
|
||||
getVideoshot(currentTime, done)
|
||||
{
|
||||
if (!this.cidData[this.page])
|
||||
if (!this.cidData)
|
||||
{
|
||||
downloadText(`https://api.bilibili.com/x/player/videoshot?aid=${this.aid}&cid=${this.cidMap[this.page]}&index=1`, response =>
|
||||
downloadText(`https://api.bilibili.com/x/player/videoshot?aid=${this.aid}&cid=${this.cid}&index=1`, response =>
|
||||
{
|
||||
this.cidData[this.page] = JSON.parse(response).data;
|
||||
this.cidData = JSON.parse(response).data;
|
||||
this.getVideoshot(currentTime, done);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
const data = this.cidData[this.page];
|
||||
|
||||
const data = this.cidData;
|
||||
const indexData = data.index;
|
||||
let shotIndex = 0;
|
||||
for (let index = 0; index < indexData.length - 2; index++)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user