return only streams property for moch meta

This commit is contained in:
TheBeastLT
2022-03-09 15:54:39 +01:00
parent 5100751c19
commit 29b232318e
5 changed files with 9 additions and 10 deletions

View File

@@ -67,7 +67,7 @@ async function getItemMeta(itemId, apiKey) {
id: `${KEY}:${torrent.id}:${index}`, id: `${KEY}:${torrent.id}:${index}`,
title: file.filename, title: file.filename,
released: new Date(torrent.uploadDate * 1000 - index).toISOString(), released: new Date(torrent.uploadDate * 1000 - index).toISOString(),
stream: { url: `${apiKey}/${torrent.hash.toLowerCase()}/${encodeURIComponent(file.filename)}/${index}` } streams: [{ url: `${apiKey}/${torrent.hash.toLowerCase()}/${encodeURIComponent(file.filename)}/${index}` }]
})) }))
})) }))
} }

View File

@@ -66,7 +66,7 @@ async function getItemMeta(itemId, apiKey, ip) {
id: `${KEY}:${torrent.id}:${index}`, id: `${KEY}:${torrent.id}:${index}`,
title: file.name, title: file.name,
released: new Date(torrent.created * 1000 - index).toISOString(), released: new Date(torrent.created * 1000 - index).toISOString(),
stream: { url: file.downloadUrl } streams: [{ url: file.downloadUrl }]
})) }))
})) }))
} }

View File

@@ -118,12 +118,11 @@ async function getMochItemMeta(mochKey, itemId, config) {
return moch.instance.getItemMeta(itemId, config[moch.key], config.ip) return moch.instance.getItemMeta(itemId, config[moch.key], config.ip)
.then(meta => { .then(meta => {
meta.videos.forEach(video => { meta.videos
if (!video.stream.url.startsWith('http')) { .map(video => video.streams)
video.stream.url = `${RESOLVER_HOST}/${moch.key}/${video.stream.url}` .reduce((a, b) => a.concat(b), [])
} .filter(stream => !stream.url.startsWith('http'))
video.streams = [video.stream]; .forEach(stream => stream.url = `${RESOLVER_HOST}/${moch.key}/${stream.url}`)
});
return meta; return meta;
}); });
} }

View File

@@ -71,7 +71,7 @@ async function getItemMeta(itemId, apiKey, ip) {
id: `${KEY}:${file.id}:${index}`, id: `${KEY}:${file.id}:${index}`,
title: file.name, title: file.name,
released: new Date(file.created_at * 1000 - index).toISOString(), released: new Date(file.created_at * 1000 - index).toISOString(),
stream: { url: file.link || file.stream_link } streams: [{ url: file.link || file.stream_link }]
})) }))
})) }))
} }

View File

@@ -137,7 +137,7 @@ async function getItemMeta(itemId, apiKey, ip) {
id: `${KEY}:${torrent.id}:${file.id}`, id: `${KEY}:${torrent.id}:${file.id}`,
title: file.path, title: file.path,
released: new Date(new Date(torrent.added).getTime() - index).toISOString(), released: new Date(new Date(torrent.added).getTime() - index).toISOString(),
stream: { url: `${apiKey}/${torrent.hash.toLowerCase()}/null/${file.id - 1}` } streams: [{ url: `${apiKey}/${torrent.hash.toLowerCase()}/null/${file.id - 1}` }]
})) }))
})) }))
} }