diff --git a/addon/moch/moch.js b/addon/moch/moch.js index 2171f8b..5a0cd39 100644 --- a/addon/moch/moch.js +++ b/addon/moch/moch.js @@ -140,10 +140,9 @@ export async function getMochItemMeta(mochKey, itemId, config) { .then(meta => enrichMeta(meta)) .then(meta => { meta.videos - .map(video => video.streams) - .reduce((a, b) => a.concat(b), []) - .filter(stream => !stream.url.startsWith('http')) - .forEach(stream => stream.url = `${config.host}/${moch.key}/${stream.url}`) + .map(video => video.streams + .filter(stream => !stream.url.startsWith('http')) + .forEach(stream => stream.url = `${config.host}/${moch.key}/${stream.url}/${streamFilename(video)}`)) return meta; }); } diff --git a/addon/moch/mochHelper.js b/addon/moch/mochHelper.js index f1049aa..b3e16b0 100644 --- a/addon/moch/mochHelper.js +++ b/addon/moch/mochHelper.js @@ -12,10 +12,7 @@ export function chunkArray(arr, size) { export function streamFilename(stream) { const titleParts = stream.title.replace(/\n👤.*/s, '').split('\n'); - const filePath = titleParts.pop(); - const filename = titleParts.length - ? filePath.split('/').pop() - : filePath; + const filename = titleParts.pop().split('/').pop(); return encodeURIComponent(filename) }