From 29b232318e390cb487c0b70922454b6102daa9aa Mon Sep 17 00:00:00 2001 From: TheBeastLT Date: Wed, 9 Mar 2022 15:54:39 +0100 Subject: [PATCH] return only streams property for moch meta --- addon/moch/alldebrid.js | 2 +- addon/moch/debridlink.js | 2 +- addon/moch/moch.js | 11 +++++------ addon/moch/premiumize.js | 2 +- addon/moch/realdebrid.js | 2 +- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/addon/moch/alldebrid.js b/addon/moch/alldebrid.js index d4c4c5d..a1b1605 100644 --- a/addon/moch/alldebrid.js +++ b/addon/moch/alldebrid.js @@ -67,7 +67,7 @@ async function getItemMeta(itemId, apiKey) { id: `${KEY}:${torrent.id}:${index}`, title: file.filename, 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}` }] })) })) } diff --git a/addon/moch/debridlink.js b/addon/moch/debridlink.js index d3cd3ca..5e8c5cf 100644 --- a/addon/moch/debridlink.js +++ b/addon/moch/debridlink.js @@ -66,7 +66,7 @@ async function getItemMeta(itemId, apiKey, ip) { id: `${KEY}:${torrent.id}:${index}`, title: file.name, released: new Date(torrent.created * 1000 - index).toISOString(), - stream: { url: file.downloadUrl } + streams: [{ url: file.downloadUrl }] })) })) } diff --git a/addon/moch/moch.js b/addon/moch/moch.js index 290823f..abbbe3d 100644 --- a/addon/moch/moch.js +++ b/addon/moch/moch.js @@ -118,12 +118,11 @@ async function getMochItemMeta(mochKey, itemId, config) { return moch.instance.getItemMeta(itemId, config[moch.key], config.ip) .then(meta => { - meta.videos.forEach(video => { - if (!video.stream.url.startsWith('http')) { - video.stream.url = `${RESOLVER_HOST}/${moch.key}/${video.stream.url}` - } - video.streams = [video.stream]; - }); + meta.videos + .map(video => video.streams) + .reduce((a, b) => a.concat(b), []) + .filter(stream => !stream.url.startsWith('http')) + .forEach(stream => stream.url = `${RESOLVER_HOST}/${moch.key}/${stream.url}`) return meta; }); } diff --git a/addon/moch/premiumize.js b/addon/moch/premiumize.js index 522944c..0b6e2f5 100644 --- a/addon/moch/premiumize.js +++ b/addon/moch/premiumize.js @@ -71,7 +71,7 @@ async function getItemMeta(itemId, apiKey, ip) { id: `${KEY}:${file.id}:${index}`, title: file.name, released: new Date(file.created_at * 1000 - index).toISOString(), - stream: { url: file.link || file.stream_link } + streams: [{ url: file.link || file.stream_link }] })) })) } diff --git a/addon/moch/realdebrid.js b/addon/moch/realdebrid.js index b684a74..d8b51c6 100644 --- a/addon/moch/realdebrid.js +++ b/addon/moch/realdebrid.js @@ -137,7 +137,7 @@ async function getItemMeta(itemId, apiKey, ip) { id: `${KEY}:${torrent.id}:${file.id}`, title: file.path, 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}` }] })) })) }