streamable: clean up + more patterns

This commit is contained in:
wukko 2023-08-20 15:18:21 +06:00
parent 9af60e1e6b
commit 890b7c8924
3 changed files with 25 additions and 19 deletions

View file

@ -1,21 +1,19 @@
export default async function(obj) { export default async function(obj) {
const video = await fetch(`https://api.streamable.com/videos/${obj.id}`) let video = await fetch(`https://api.streamable.com/videos/${obj.id}`).then((r) => { return r.status === 200 ? r.json() : false }).catch(() => { return false });
.then((r) => { if (!video) return { error: 'ErrorEmptyDownload' };
if (r.status === 404)
return undefined;
else
return r.json();
}).catch(() => { return false });
if (video === undefined) return { error: 'ErrorEmptyDownload' } ; let best = video.files['mp4-mobile'];
else if (!video) return { error: 'ErrorCouldntFetch' }; 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']; if (best) return {
else urls: best.url,
best = video.files['mp4-mobile'] ?? video.files.mp4; filename: `streamable_${obj.id}_${best.width}x${best.height}.mp4`,
audioFilename: `streamable_${obj.id}_audio`,
if (best) return { urls: best.url, filename: `streamable_${obj.id}_${best.width}x${best.height}.mp4`, audioFilename: `streamable_${obj.id}_audio` }; metadata: {
else return { error: 'ErrorEmptyDownload' } title: video.title
}
}
return { error: 'ErrorEmptyDownload' }
} }

View file

@ -2,7 +2,7 @@
"audioIgnore": ["vk"], "audioIgnore": ["vk"],
"config": { "config": {
"bilibili": { "bilibili": {
"alias": "bilibili (.com only)", "alias": "bilibili.com videos",
"patterns": ["video/:id"], "patterns": ["video/:id"],
"enabled": true "enabled": true
}, },
@ -70,7 +70,7 @@
}, },
"streamable": { "streamable": {
"alias": "streamable videos", "alias": "streamable videos",
"patterns": [":id", "o/:id"], "patterns": [":id", "o/:id", "e/:id", "s/:id"],
"enabled": true "enabled": true
} }
} }

View file

@ -992,6 +992,14 @@
"code": 200, "code": 200,
"status": "redirect" "status": "redirect"
} }
}, {
"name": "embedded link",
"url": "https://streamable.com/e/rsmo56",
"params": {},
"expected": {
"code": 200,
"status": "redirect"
}
}, { }, {
"name": "regular video (isAudioOnly)", "name": "regular video (isAudioOnly)",
"url": "https://streamable.com/03r3c2", "url": "https://streamable.com/03r3c2",