Fix exploration for multiple videos

This commit is contained in:
Mattéo Delabre 2020-11-29 21:54:35 +01:00
parent bd2300303b
commit bf2730f991
Signed by: matteo
GPG Key ID: AE3FBD02DC583ABB
1 changed files with 14 additions and 13 deletions

View File

@ -28,21 +28,22 @@ export const exploreVideos = async (videoId, onUpdate) =>
while (queue.length > 0) while (queue.length > 0)
{ {
const currentId = queue.shift(); const currentId = queue.shift();
const config = await api.getPlayerConfig(currentId);
const meta = api.getVideoMeta(config);
videosNodes[currentId] = meta; if (!(currentId in videosNodes))
nextVideos[currentId] = new Set();
// Add links between this video and the linked ones
api.getEndScreenVideos(config)
.forEach(nextId => nextVideos[meta.videoId].add(nextId));
api.getCardVideos(config)
.forEach(nextId => nextVideos[meta.videoId].add(nextId));
for (let nextId of nextVideos[meta.videoId])
{ {
if (!(nextId in videosNodes)) const config = await api.getPlayerConfig(currentId);
const meta = api.getVideoMeta(config);
videosNodes[currentId] = meta;
nextVideos[currentId] = new Set();
// Add links between this video and the linked ones
api.getEndScreenVideos(config)
.forEach(nextId => nextVideos[meta.videoId].add(nextId));
api.getCardVideos(config)
.forEach(nextId => nextVideos[meta.videoId].add(nextId));
for (let nextId of nextVideos[meta.videoId])
{ {
queue.push(nextId); queue.push(nextId);
} }