mirror of
https://github.com/wukko/cobalt.git
synced 2024-11-05 07:49:58 +00:00
streamable: clean up + more patterns
This commit is contained in:
parent
9af60e1e6b
commit
890b7c8924
3 changed files with 25 additions and 19 deletions
|
@ -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' }
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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",
|
||||
|
|
Loading…
Reference in a new issue