mirror of
https://github.com/wukko/cobalt.git
synced 2025-01-12 20:25:06 +01:00
feat: streamable.com support
merge pull request #179 from blobadoodle/streamable-support
This commit is contained in:
commit
7376cd88e1
6 changed files with 82 additions and 2 deletions
|
@ -18,6 +18,7 @@ import soundcloud from "./services/soundcloud.js";
|
||||||
import instagram from "./services/instagram.js";
|
import instagram from "./services/instagram.js";
|
||||||
import vine from "./services/vine.js";
|
import vine from "./services/vine.js";
|
||||||
import pinterest from "./services/pinterest.js";
|
import pinterest from "./services/pinterest.js";
|
||||||
|
import streamable from "./services/streamable.js";
|
||||||
|
|
||||||
export default async function (host, patternMatch, url, lang, obj) {
|
export default async function (host, patternMatch, url, lang, obj) {
|
||||||
try {
|
try {
|
||||||
|
@ -114,6 +115,13 @@ export default async function (host, patternMatch, url, lang, obj) {
|
||||||
case "pinterest":
|
case "pinterest":
|
||||||
r = await pinterest({ id: patternMatch["id"] });
|
r = await pinterest({ id: patternMatch["id"] });
|
||||||
break;
|
break;
|
||||||
|
case "streamable":
|
||||||
|
r = await streamable({
|
||||||
|
id: patternMatch["id"],
|
||||||
|
quality: obj.vQuality,
|
||||||
|
isAudioOnly: isAudioOnly,
|
||||||
|
});
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return apiJSON(0, { t: errorUnsupported(lang) });
|
return apiJSON(0, { t: errorUnsupported(lang) });
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,6 +56,7 @@ export default function(r, host, audioFormat, isAudioOnly, lang, isAudioMuted) {
|
||||||
case "tumblr":
|
case "tumblr":
|
||||||
case "twitter":
|
case "twitter":
|
||||||
case "pinterest":
|
case "pinterest":
|
||||||
|
case "streamable":
|
||||||
responseType = 1;
|
responseType = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
19
src/modules/processing/services/streamable.js
Normal file
19
src/modules/processing/services/streamable.js
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
export default async function(obj) {
|
||||||
|
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' };
|
||||||
|
|
||||||
|
let best = video.files['mp4-mobile'];
|
||||||
|
if (video.files.mp4 && (obj.isAudioOnly || obj.quality === "max" || obj.quality >= Number("720"))) {
|
||||||
|
best = video.files.mp4;
|
||||||
|
}
|
||||||
|
|
||||||
|
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"],
|
"audioIgnore": ["vk"],
|
||||||
"config": {
|
"config": {
|
||||||
"bilibili": {
|
"bilibili": {
|
||||||
"alias": "bilibili (.com only)",
|
"alias": "bilibili.com videos",
|
||||||
"patterns": ["video/:id"],
|
"patterns": ["video/:id"],
|
||||||
"enabled": true
|
"enabled": true
|
||||||
},
|
},
|
||||||
|
@ -67,6 +67,11 @@
|
||||||
"alias": "pinterest videos & stories",
|
"alias": "pinterest videos & stories",
|
||||||
"patterns": ["pin/:id"],
|
"patterns": ["pin/:id"],
|
||||||
"enabled": true
|
"enabled": true
|
||||||
|
},
|
||||||
|
"streamable": {
|
||||||
|
"alias": "streamable videos",
|
||||||
|
"patterns": [":id", "o/:id", "e/:id", "s/:id"],
|
||||||
|
"enabled": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,5 +30,7 @@ export const testers = {
|
||||||
|
|
||||||
"vine": (patternMatch) => (patternMatch["id"] && patternMatch["id"].length <= 12),
|
"vine": (patternMatch) => (patternMatch["id"] && patternMatch["id"].length <= 12),
|
||||||
|
|
||||||
"pinterest": (patternMatch) => (patternMatch["id"] && patternMatch["id"].length <= 128)
|
"pinterest": (patternMatch) => (patternMatch["id"] && patternMatch["id"].length <= 128),
|
||||||
|
|
||||||
|
"streamable": (patternMatch) => (patternMatch["id"] && patternMatch["id"].length === 6)
|
||||||
}
|
}
|
||||||
|
|
|
@ -983,5 +983,50 @@
|
||||||
"code": 200,
|
"code": 200,
|
||||||
"status": "redirect"
|
"status": "redirect"
|
||||||
}
|
}
|
||||||
|
}],
|
||||||
|
"streamable": [{
|
||||||
|
"name": "regular video",
|
||||||
|
"url": "https://streamable.com/03r3c2",
|
||||||
|
"params": {},
|
||||||
|
"expected": {
|
||||||
|
"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",
|
||||||
|
"params": {
|
||||||
|
"isAudioOnly": true
|
||||||
|
},
|
||||||
|
"expected": {
|
||||||
|
"code": 200,
|
||||||
|
"status": "stream"
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
"name": "regular video (isAudioMuted)",
|
||||||
|
"url": "https://streamable.com/03r3c2",
|
||||||
|
"params": {
|
||||||
|
"isAudioMuted": true
|
||||||
|
},
|
||||||
|
"expected": {
|
||||||
|
"code": 200,
|
||||||
|
"status": "stream"
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
"name": "inexistent video",
|
||||||
|
"url": "https://streamable.com/XXXXXX",
|
||||||
|
"params": {},
|
||||||
|
"expected": {
|
||||||
|
"code": 400,
|
||||||
|
"status": "error"
|
||||||
|
}
|
||||||
}]
|
}]
|
||||||
}
|
}
|
Loading…
Reference in a new issue