diff --git a/src/modules/processing/services/streamable.js b/src/modules/processing/services/streamable.js index 7a70d4bb..29b6dece 100644 --- a/src/modules/processing/services/streamable.js +++ b/src/modules/processing/services/streamable.js @@ -1,21 +1,19 @@ export default async function(obj) { - const video = await fetch(`https://api.streamable.com/videos/${obj.id}`) - .then((r) => { - if (r.status === 404) - return undefined; - else - return r.json(); - }).catch(() => { return false }); + let video = await fetch(`https://api.streamable.com/videos/${obj.id}`).then((r) => { return r.status === 200 ? r.json() : false }).catch(() => { return false }); + if (!video) return { error: 'ErrorEmptyDownload' }; - if (video === undefined) return { error: 'ErrorEmptyDownload' } ; - else if (!video) return { error: 'ErrorCouldntFetch' }; + let best = video.files['mp4-mobile']; + if (video.files.mp4 && (obj.isAudioOnly || obj.quality === "max" || obj.quality >= Number("720"))) { + best = video.files.mp4; + } - let best; - if (obj.isAudioOnly || obj.quality === "max" || obj.quality >= "720") // audio seems to be compressed on the mp4-mobile version so isAudioOnly only uses the higest quality - best = video.files.mp4 ?? video.files['mp4-mobile']; - else - best = video.files['mp4-mobile'] ?? video.files.mp4; - - if (best) return { urls: best.url, filename: `streamable_${obj.id}_${best.width}x${best.height}.mp4`, audioFilename: `streamable_${obj.id}_audio` }; - else return { error: 'ErrorEmptyDownload' } + if (best) return { + urls: best.url, + filename: `streamable_${obj.id}_${best.width}x${best.height}.mp4`, + audioFilename: `streamable_${obj.id}_audio`, + metadata: { + title: video.title + } + } + return { error: 'ErrorEmptyDownload' } } diff --git a/src/modules/processing/servicesConfig.json b/src/modules/processing/servicesConfig.json index 69dad6ab..aadc3926 100644 --- a/src/modules/processing/servicesConfig.json +++ b/src/modules/processing/servicesConfig.json @@ -2,7 +2,7 @@ "audioIgnore": ["vk"], "config": { "bilibili": { - "alias": "bilibili (.com only)", + "alias": "bilibili.com videos", "patterns": ["video/:id"], "enabled": true }, @@ -70,7 +70,7 @@ }, "streamable": { "alias": "streamable videos", - "patterns": [":id", "o/:id"], + "patterns": [":id", "o/:id", "e/:id", "s/:id"], "enabled": true } } diff --git a/src/test/tests.json b/src/test/tests.json index c777f9e4..e72421df 100644 --- a/src/test/tests.json +++ b/src/test/tests.json @@ -992,6 +992,14 @@ "code": 200, "status": "redirect" } + }, { + "name": "embedded link", + "url": "https://streamable.com/e/rsmo56", + "params": {}, + "expected": { + "code": 200, + "status": "redirect" + } }, { "name": "regular video (isAudioOnly)", "url": "https://streamable.com/03r3c2",