From 75a85972aa281903f14bc5f44dacc7531dd8cdde Mon Sep 17 00:00:00 2001 From: wukko Date: Mon, 13 Feb 2023 19:44:58 +0600 Subject: [PATCH] 5.0 - finished writing tests for all services - fixed douyin support - fixed tiktok picker that was broken by previous commit - temporarily removed douyin photos from list of supported services - fixed support for "user view" vk clip links - slightly improved the testing script --- package.json | 2 +- src/modules/api.js | 10 +- src/modules/processing/matchActionDecider.js | 6 +- src/modules/processing/services/bilibili.js | 2 +- src/modules/processing/services/tiktok.js | 32 +- src/modules/processing/servicesConfig.json | 6 +- src/modules/sub/utils.js | 1 + src/test/services.json | 256 ------- src/test/test.js | 23 +- src/test/tests.json | 742 +++++++++++++++++++ 10 files changed, 784 insertions(+), 296 deletions(-) delete mode 100644 src/test/services.json create mode 100644 src/test/tests.json diff --git a/package.json b/package.json index 581536d..a271a70 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "cobalt", "description": "save what you love", - "version": "5.0-dev1", + "version": "5.0-dev2", "author": "wukko", "exports": "./src/cobalt.js", "type": "module", diff --git a/src/modules/api.js b/src/modules/api.js index 1e0d9a9..9dc8a23 100644 --- a/src/modules/api.js +++ b/src/modules/api.js @@ -36,16 +36,14 @@ export async function getJSON(originalURL, lang, obj) { } break; } - if (!(host && host.length < 20 && host in patterns && patterns[host]["enabled"])) { - return apiJSON(0, { t: errorUnsupported(lang) }); - } + if (!(host && host.length < 20 && host in patterns && patterns[host]["enabled"])) return apiJSON(0, { t: errorUnsupported(lang) }); + for (let i in patterns[host]["patterns"]) { patternMatch = new UrlPattern(patterns[host]["patterns"][i]).match(cleanURL(url, host).split(".com/")[1]); if (patternMatch) break; } - if (!patternMatch) { - return apiJSON(0, { t: errorUnsupported(lang) }); - } + if (!patternMatch) return apiJSON(0, { t: errorUnsupported(lang) }); + return await match(host, patternMatch, url, lang, obj); } catch (e) { return apiJSON(0, { t: loc(lang, 'ErrorSomethingWentWrong') }); diff --git a/src/modules/processing/matchActionDecider.js b/src/modules/processing/matchActionDecider.js index 7e76d60..fb0892a 100644 --- a/src/modules/processing/matchActionDecider.js +++ b/src/modules/processing/matchActionDecider.js @@ -12,11 +12,11 @@ export default function(r, host, ip, audioFormat, isAudioOnly, lang, isAudioMute filename: r.filename, }, params = {} - - if (isAudioMuted) action = "muteVideo"; + if (!isAudioOnly && !r.picker && !isAudioMuted) action = "video"; + if (isAudioOnly && !r.picker) action = "audio"; if (r.picker) action = "picker"; - if (isAudioOnly) action = "audio"; + if (isAudioMuted) action = "muteVideo"; if (action === "picker" || action === "audio") { defaultParams.filename = r.audioFilename; diff --git a/src/modules/processing/services/bilibili.js b/src/modules/processing/services/bilibili.js index 8f9ab28..82964a3 100644 --- a/src/modules/processing/services/bilibili.js +++ b/src/modules/processing/services/bilibili.js @@ -1,6 +1,6 @@ import { genericUserAgent, maxVideoDuration } from "../../config.js"; -// TO-DO: quality picking & bilibili.tv support +// TO-DO: quality picking, bilibili.tv support, and higher quality downloads (currently requires an account) export default async function(obj) { let html = await fetch(`https://bilibili.com/video/${obj.id}`, { headers: { "user-agent": genericUserAgent } diff --git a/src/modules/processing/services/tiktok.js b/src/modules/processing/services/tiktok.js index 4ac0d19..ccd10f2 100644 --- a/src/modules/processing/services/tiktok.js +++ b/src/modules/processing/services/tiktok.js @@ -8,7 +8,7 @@ let userAgent = genericUserAgent.split(' Chrome/1')[0], }, douyin: { short: "https://v.douyin.com/", - api: "https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/?item_ids={postId}", + api: "https://www.iesdouyin.com/aweme/v1/web/aweme/detail/?aweme_id={postId}", } } @@ -17,14 +17,14 @@ function selector(j, h, id) { let t; switch (h) { case "tiktok": - t = j["aweme_list"].filter((v) => { if (v["aweme_id"] === id) return true }); + t = j["aweme_list"].filter((v) => { if (v["aweme_id"] === id) return true })[0]; break; case "douyin": - t = j['item_list'].filter((v) => { if (v["aweme_id"] === id) return true }); + t = j['aweme_detail']; break; } - if (!t.length > 0) return false; - return t[0]; + if (t.length < 3) return false; + return t; } export default async function(obj) { @@ -34,7 +34,7 @@ export default async function(obj) { headers: { "user-agent": userAgent } }).then((r) => { return r.text() }).catch(() => { return false }); if (!html) return { error: 'ErrorCouldntFetch' }; - + if (html.slice(0, 17) === '', '<', '^', '*', '!', '~', ';', ':', ',', '`', '[', ']', '#', '$', '"', "'", "@"] switch(host) { + case "vk": case "youtube": url = url.split('&')[0]; break; diff --git a/src/test/services.json b/src/test/services.json deleted file mode 100644 index fcf3841..0000000 --- a/src/test/services.json +++ /dev/null @@ -1,256 +0,0 @@ -{ - "twitter": [{ - "name": "regular video", - "url": "https://twitter.com/TwitterSpaces/status/1526955853743546372?s=20", - "params": { - "aFormat": "mp3", - "isAudioOnly": false, - "isAudioMuted": false - }, - "expected": { - "code": 200, - "status": "redirect" - } - }, { - "name": "embedded twitter video", - "url": "https://twitter.com/dustbin_nie/status/1624596567188717568?s=20", - "params": { - "aFormat": "mp3", - "isAudioOnly": false, - "isAudioMuted": false - }, - "expected": { - "code": 200, - "status": "redirect" - } - }, { - "name": "mixed media (image + gif)", - "url": "https://twitter.com/Twitter/status/1580661436132757506?s=20", - "params": { - "aFormat": "mp3", - "isAudioOnly": false, - "isAudioMuted": false - }, - "expected": { - "code": 200, - "status": "redirect" - } - }, { - "name": "picker: mixed media (3 gifs + image)", - "url": "https://twitter.com/emerald_pedrod/status/1582418163521581063?s=20", - "params": { - "aFormat": "mp3", - "isAudioOnly": false, - "isAudioMuted": false - }, - "expected": { - "code": 200, - "status": "picker" - } - }, { - "name": "audio from embedded twitter video (mp3, isAudioOnly)", - "url": "https://twitter.com/dustbin_nie/status/1624596567188717568?s=20", - "params": { - "aFormat": "mp3", - "isAudioOnly": true, - "isAudioMuted": false - }, - "expected": { - "code": 200, - "status": "stream" - } - }, { - "name": "audio from embedded twitter video (best, isAudioOnly)", - "url": "https://twitter.com/dustbin_nie/status/1624596567188717568?s=20", - "params": { - "aFormat": "best", - "isAudioOnly": true, - "isAudioMuted": false - }, - "expected": { - "code": 200, - "status": "stream" - } - }, { - "name": "audio from embedded twitter video (ogg, isAudioOnly, isAudioMuted)", - "url": "https://twitter.com/dustbin_nie/status/1624596567188717568?s=20", - "params": { - "aFormat": "best", - "isAudioOnly": true, - "isAudioMuted": true - }, - "expected": { - "code": 200, - "status": "stream" - } - }, { - "name": "muted embedded twitter video", - "url": "https://twitter.com/dustbin_nie/status/1624596567188717568?s=20", - "params": { - "aFormat": "mp3", - "isAudioOnly": false, - "isAudioMuted": true - }, - "expected": { - "code": 200, - "status": "stream" - } - }, { - "name": "inexistent post", - "url": "https://twitter.com/test/status/9487653", - "params": { - "aFormat": "best", - "isAudioOnly": false, - "isAudioMuted": false - }, - "expected": { - "code": 400, - "status": "error" - } - }, { - "name": "post with no media content", - "url": "https://twitter.com/elonmusk/status/1604617643973124097?s=20", - "params": { - "aFormat": "best", - "isAudioOnly": false, - "isAudioMuted": false - }, - "expected": { - "code": 400, - "status": "error" - } - }, { - "name": "recorded space by nyc (best)", - "url": "https://twitter.com/i/spaces/1gqxvyLoYQkJB", - "params": { - "aFormat": "best", - "isAudioOnly": false, - "isAudioMuted": false - }, - "expected": { - "code": 200, - "status": "stream" - } - }, { - "name": "recorded space by nyc (mp3)", - "url": "https://twitter.com/i/spaces/1gqxvyLoYQkJB", - "params": { - "aFormat": "mp3", - "isAudioOnly": false, - "isAudioMuted": false - }, - "expected": { - "code": 200, - "status": "stream" - } - }, { - "name": "recorded space by nyc (wav, isAudioMuted)", - "url": "https://twitter.com/i/spaces/1gqxvyLoYQkJB", - "params": { - "aFormat": "wav", - "isAudioOnly": false, - "isAudioMuted": true - }, - "expected": { - "code": 200, - "status": "stream" - } - }, { - "name": "recorded space by service95 & dualipa (mp3, isAudioMuted, isAudioOnly)", - "url": "https://twitter.com/i/spaces/1nAJErvvVXgxL", - "params": { - "aFormat": "mp3", - "isAudioOnly": true, - "isAudioMuted": true - }, - "expected": { - "code": 200, - "status": "stream" - } - }, { - "name": "unavailable space", - "url": "https://twitter.com/i/spaces/1OwGWwjRjVVGQ?s=20", - "params": { - "aFormat": "mp3", - "isAudioOnly": false, - "isAudioMuted": false - }, - "expected": { - "code": 400, - "status": "error" - } - }, { - "name": "inexistent space", - "url": "https://twitter.com/i/spaces/10Wkie2j29iiI", - "params": { - "aFormat": "mp3", - "isAudioOnly": false, - "isAudioMuted": false - }, - "expected": { - "code": 400, - "status": "error" - } - }], - "soundcloud": [{ - "name": "public song (best)", - "url": "https://soundcloud.com/l2share77/loona-butterfly?utm_source=clipboard&utm_medium=text&utm_campaign=social_sharing", - "params": { - "aFormat": "best", - "isAudioOnly": false, - "isAudioMuted": false - }, - "expected": { - "code": 200, - "status": "stream" - } - }, { - "name": "public song (mp3, isAudioMuted)", - "url": "https://soundcloud.com/l2share77/loona-butterfly?utm_source=clipboard&utm_medium=text&utm_campaign=social_sharing", - "params": { - "aFormat": "mp3", - "isAudioOnly": false, - "isAudioMuted": true - }, - "expected": { - "code": 200, - "status": "stream" - } - }, { - "name": "private song", - "url": "https://soundcloud.com/4kayy/unhappy-new-year-prod4kay/s-9bKbvwLdRWG", - "params": { - "aFormat": "mp3", - "isAudioOnly": false, - "isAudioMuted": false - }, - "expected": { - "code": 200, - "status": "stream" - } - }, { - "name": "private song (wav, isAudioMuted)", - "url": "https://soundcloud.com/4kayy/unhappy-new-year-prod4kay/s-9bKbvwLdRWG", - "params": { - "aFormat": "wav", - "isAudioOnly": false, - "isAudioMuted": true - }, - "expected": { - "code": 200, - "status": "stream" - } - }, { - "name": "private song (ogg, isAudioMuted, isAudioOnly)", - "url": "https://soundcloud.com/4kayy/unhappy-new-year-prod4kay/s-9bKbvwLdRWG", - "params": { - "aFormat": "ogg", - "isAudioOnly": true, - "isAudioMuted": true - }, - "expected": { - "code": 200, - "status": "stream" - } - }] -} \ No newline at end of file diff --git a/src/test/test.js b/src/test/test.js index ff4dc95..f03c8db 100644 --- a/src/test/test.js +++ b/src/test/test.js @@ -5,17 +5,18 @@ import { services } from "../modules/config.js"; import loadJSON from "../modules/sub/loadJSON.js"; import { checkJSONPost } from "../modules/sub/utils.js"; -let tests = loadJSON('./src/test/services.json'); +let tests = loadJSON('./src/test/tests.json'); let noTest = []; let failed = []; let success = 0; -function addToFail(service, testName, url, response) { +function addToFail(service, testName, url, status, response) { failed.push({ service: service, name: testName, url: url, + status: status, response: response }) } @@ -41,11 +42,11 @@ for (let i in services) { success++ } else { console.log(`\n❌ Fail. Expected: ${test.expected.code} & ${test.expected.status}, received: ${j.status} & ${j.body.status}\n`); - addToFail(i, test.name, test.url, j) + addToFail(i, test.name, test.url, j.body.status, j) } } else { console.log("\n❌ couldn't validate the request JSON.\n"); - addToFail(i, test.name, test.url, {}) + addToFail(i, test.name, test.url, "unknown", {}) } } console.log("\n\n") @@ -55,12 +56,16 @@ for (let i in services) { } } -console.log(`\n✅ ${success} tests succeeded.`); +console.log(`✅ ${success} tests succeeded.`); console.log(`❌ ${failed.length} tests failed.`); console.log(`❔ ${noTest.length} services weren't tested.`); -console.log(`\nFailed tests:`); -console.log(failed) +if (failed.length > 0) { + console.log(`\nFailed tests:`); + console.log(failed) +} -console.log(`\nMissing tests:`); -console.log(noTest) +if (noTest.length > 0) { + console.log(`\nMissing tests:`); + console.log(noTest) +} diff --git a/src/test/tests.json b/src/test/tests.json new file mode 100644 index 0000000..e493517 --- /dev/null +++ b/src/test/tests.json @@ -0,0 +1,742 @@ +{ + "twitter": [{ + "name": "regular video", + "url": "https://twitter.com/TwitterSpaces/status/1526955853743546372?s=20", + "params": { + "aFormat": "mp3", + "isAudioOnly": false, + "isAudioMuted": false + }, + "expected": { + "code": 200, + "status": "redirect" + } + }, { + "name": "embedded twitter video", + "url": "https://twitter.com/dustbin_nie/status/1624596567188717568?s=20", + "params": { + "aFormat": "mp3", + "isAudioOnly": false, + "isAudioMuted": false + }, + "expected": { + "code": 200, + "status": "redirect" + } + }, { + "name": "mixed media (image + gif)", + "url": "https://twitter.com/Twitter/status/1580661436132757506?s=20", + "params": { + "aFormat": "mp3", + "isAudioOnly": false, + "isAudioMuted": false + }, + "expected": { + "code": 200, + "status": "redirect" + } + }, { + "name": "picker: mixed media (3 gifs + image)", + "url": "https://twitter.com/emerald_pedrod/status/1582418163521581063?s=20", + "params": { + "aFormat": "mp3", + "isAudioOnly": false, + "isAudioMuted": false + }, + "expected": { + "code": 200, + "status": "picker" + } + }, { + "name": "audio from embedded twitter video (mp3, isAudioOnly)", + "url": "https://twitter.com/dustbin_nie/status/1624596567188717568?s=20", + "params": { + "aFormat": "mp3", + "isAudioOnly": true, + "isAudioMuted": false + }, + "expected": { + "code": 200, + "status": "stream" + } + }, { + "name": "audio from embedded twitter video (best, isAudioOnly)", + "url": "https://twitter.com/dustbin_nie/status/1624596567188717568?s=20", + "params": { + "aFormat": "best", + "isAudioOnly": true, + "isAudioMuted": false + }, + "expected": { + "code": 200, + "status": "stream" + } + }, { + "name": "audio from embedded twitter video (ogg, isAudioOnly, isAudioMuted)", + "url": "https://twitter.com/dustbin_nie/status/1624596567188717568?s=20", + "params": { + "aFormat": "best", + "isAudioOnly": true, + "isAudioMuted": true + }, + "expected": { + "code": 200, + "status": "stream" + } + }, { + "name": "muted embedded twitter video", + "url": "https://twitter.com/dustbin_nie/status/1624596567188717568?s=20", + "params": { + "aFormat": "mp3", + "isAudioOnly": false, + "isAudioMuted": true + }, + "expected": { + "code": 200, + "status": "stream" + } + }, { + "name": "inexistent post", + "url": "https://twitter.com/test/status/9487653", + "params": { + "aFormat": "best", + "isAudioOnly": false, + "isAudioMuted": false + }, + "expected": { + "code": 400, + "status": "error" + } + }, { + "name": "post with no media content", + "url": "https://twitter.com/elonmusk/status/1604617643973124097?s=20", + "params": { + "aFormat": "best", + "isAudioOnly": false, + "isAudioMuted": false + }, + "expected": { + "code": 400, + "status": "error" + } + }, { + "name": "recorded space by nyc (best)", + "url": "https://twitter.com/i/spaces/1gqxvyLoYQkJB", + "params": { + "aFormat": "best", + "isAudioOnly": false, + "isAudioMuted": false + }, + "expected": { + "code": 200, + "status": "stream" + } + }, { + "name": "recorded space by nyc (mp3)", + "url": "https://twitter.com/i/spaces/1gqxvyLoYQkJB", + "params": { + "aFormat": "mp3", + "isAudioOnly": false, + "isAudioMuted": false + }, + "expected": { + "code": 200, + "status": "stream" + } + }, { + "name": "recorded space by nyc (wav, isAudioMuted)", + "url": "https://twitter.com/i/spaces/1gqxvyLoYQkJB", + "params": { + "aFormat": "wav", + "isAudioOnly": false, + "isAudioMuted": true + }, + "expected": { + "code": 200, + "status": "stream" + } + }, { + "name": "recorded space by service95 & dualipa (mp3, isAudioMuted, isAudioOnly)", + "url": "https://twitter.com/i/spaces/1nAJErvvVXgxL", + "params": { + "aFormat": "mp3", + "isAudioOnly": true, + "isAudioMuted": true + }, + "expected": { + "code": 200, + "status": "stream" + } + }, { + "name": "unavailable space", + "url": "https://twitter.com/i/spaces/1OwGWwjRjVVGQ?s=20", + "params": {}, + "expected": { + "code": 400, + "status": "error" + } + }, { + "name": "inexistent space", + "url": "https://twitter.com/i/spaces/10Wkie2j29iiI", + "params": {}, + "expected": { + "code": 400, + "status": "error" + } + }], + "soundcloud": [{ + "name": "public song (best)", + "url": "https://soundcloud.com/l2share77/loona-butterfly?utm_source=clipboard&utm_medium=text&utm_campaign=social_sharing", + "params": { + "aFormat": "best", + "isAudioOnly": false, + "isAudioMuted": false + }, + "expected": { + "code": 200, + "status": "stream" + } + }, { + "name": "public song (mp3, isAudioMuted)", + "url": "https://soundcloud.com/l2share77/loona-butterfly?utm_source=clipboard&utm_medium=text&utm_campaign=social_sharing", + "params": { + "aFormat": "mp3", + "isAudioOnly": false, + "isAudioMuted": true + }, + "expected": { + "code": 200, + "status": "stream" + } + }, { + "name": "private song", + "url": "https://soundcloud.com/4kayy/unhappy-new-year-prod4kay/s-9bKbvwLdRWG", + "params": { + "aFormat": "mp3", + "isAudioOnly": false, + "isAudioMuted": false + }, + "expected": { + "code": 200, + "status": "stream" + } + }, { + "name": "private song (wav, isAudioMuted)", + "url": "https://soundcloud.com/4kayy/unhappy-new-year-prod4kay/s-9bKbvwLdRWG", + "params": { + "aFormat": "wav", + "isAudioOnly": false, + "isAudioMuted": true + }, + "expected": { + "code": 200, + "status": "stream" + } + }, { + "name": "private song (ogg, isAudioMuted, isAudioOnly)", + "url": "https://soundcloud.com/4kayy/unhappy-new-year-prod4kay/s-9bKbvwLdRWG", + "params": { + "aFormat": "ogg", + "isAudioOnly": true, + "isAudioMuted": true + }, + "expected": { + "code": 200, + "status": "stream" + } + }], + "youtube": [{ + "name": "4k video (mp4, hig)", + "url": "https://www.youtube.com/watch?v=vPwaXytZcgI", + "params": { + "vFormat": "mp4", + "vQuality": "hig", + "aFormat": "mp3", + "isAudioOnly": false, + "isAudioMuted": false + }, + "expected": { + "code": 200, + "status": "stream" + } + }, { + "name": "4k video (webm, mid)", + "url": "https://www.youtube.com/watch?v=vPwaXytZcgI", + "params": { + "vFormat": "webm", + "vQuality": "mid", + "aFormat": "mp3", + "isAudioOnly": false, + "isAudioMuted": false + }, + "expected": { + "code": 200, + "status": "stream" + } + }, { + "name": "4k video (mp4, max)", + "url": "https://www.youtube.com/watch?v=vPwaXytZcgI", + "params": { + "vFormat": "mp4", + "vQuality": "max", + "aFormat": "mp3", + "isAudioOnly": false, + "isAudioMuted": false + }, + "expected": { + "code": 200, + "status": "stream" + } + }, { + "name": "4k video (webm, max)", + "url": "https://www.youtube.com/watch?v=vPwaXytZcgI", + "params": { + "vFormat": "webm", + "vQuality": "max", + "aFormat": "mp3", + "isAudioOnly": false, + "isAudioMuted": false + }, + "expected": { + "code": 200, + "status": "stream" + } + }, { + "name": "4k video (webm, max, isAudioMuted)", + "url": "https://www.youtube.com/watch?v=vPwaXytZcgI", + "params": { + "vFormat": "webm", + "vQuality": "max", + "aFormat": "mp3", + "isAudioOnly": false, + "isAudioMuted": true + }, + "expected": { + "code": 200, + "status": "stream" + } + }, { + "name": "4k video (mp4, max, isAudioMuted)", + "url": "https://www.youtube.com/watch?v=vPwaXytZcgI", + "params": { + "vFormat": "webm", + "vQuality": "max", + "aFormat": "mp3", + "isAudioOnly": true, + "isAudioMuted": true + }, + "expected": { + "code": 200, + "status": "stream" + } + }, { + "name": "4k video (mp4, max, isAudioMuted, isAudioOnly, mp3)", + "url": "https://www.youtube.com/watch?v=vPwaXytZcgI", + "params": { + "vFormat": "webm", + "vQuality": "max", + "aFormat": "mp3", + "isAudioOnly": true, + "isAudioMuted": true + }, + "expected": { + "code": 200, + "status": "stream" + } + }, { + "name": "4k video (mp4, max, isAudioMuted, isAudioOnly, best)", + "url": "https://www.youtube.com/watch?v=vPwaXytZcgI", + "params": { + "vFormat": "webm", + "vQuality": "max", + "aFormat": "best", + "isAudioOnly": true, + "isAudioMuted": true + }, + "expected": { + "code": 200, + "status": "stream" + } + }, { + "name": "music (mp3, isAudioOnly, isAudioMuted)", + "url": "https://music.youtube.com/watch?v=5rGTsvZCEdk&feature=share", + "params": { + "aFormat": "mp3", + "isAudioOnly": true, + "isAudioMuted": true + }, + "expected": { + "code": 200, + "status": "stream" + } + }, { + "name": "music (mp3)", + "url": "https://music.youtube.com/watch?v=5rGTsvZCEdk&feature=share", + "params": { + "aFormat": "mp3", + "isAudioOnly": false, + "isAudioMuted": false + }, + "expected": { + "code": 200, + "status": "stream" + } + }, { + "name": "short, defaults", + "url": "https://www.youtube.com/shorts/r5FpeOJItbw", + "params": {}, + "expected": { + "code": 200, + "status": "stream" + } + }, { + "name": "inexistent video", + "url": "https://youtube.com/watch?v=gnjuHYWGEW", + "params": {}, + "expected": { + "code": 400, + "status": "error" + } + }], + "vk": [{ + "name": "clip, defaults", + "url": "https://vk.com/clip-57274055_456239788", + "params": {}, + "expected": { + "code": 200, + "status": "stream" + } + }, { + "name": "clip, low", + "url": "https://vk.com/clip-57274055_456239788", + "params": { + "vQuality": "low" + }, + "expected": { + "code": 200, + "status": "stream" + } + }, { + "name": "clip different link, max", + "url": "https://vk.com/clips-57274055?z=clip-57274055_456239788", + "params": { + "vQuality": "max" + }, + "expected": { + "code": 200, + "status": "stream" + } + }, { + "name": "video, defaults", + "url": "https://vk.com/video-57274055_456239399", + "params": {}, + "expected": { + "code": 200, + "status": "stream" + } + }, { + "name": "inexistent video", + "url": "https://vk.com/video-53333333_456233333", + "params": {}, + "expected": { + "code": 400, + "status": "error" + } + }], + "douyin": [{ + "name": "short link video, with watermark", + "url": "https://v.douyin.com/2p4Aya7/", + "params": {}, + "expected": { + "code": 200, + "status": "stream" + } + }, { + "name": "short link video (isNoTTWatermark)", + "url": "https://v.douyin.com/2p4Aya7/", + "params": { + "isNoTTWatermark": true + }, + "expected": { + "code": 200, + "status": "stream" + } + }, { + "name": "short link video (isAudioOnly)", + "url": "https://v.douyin.com/2p4Aya7/", + "params": { + "isAudioOnly": true + }, + "expected": { + "code": 200, + "status": "stream" + } + }, { + "name": "short link video (isAudioOnly, isTTFullAudio)", + "url": "https://v.douyin.com/2p4Aya7/", + "params": { + "isAudioOnly": true, + "isTTFullAudio": true + }, + "expected": { + "code": 200, + "status": "stream" + } + }, { + "name": "long link video (isNoTTWatermark)", + "url": "https://www.douyin.com/video/7120601033314716968", + "params": { + "isNoTTWatermark": true + }, + "expected": { + "code": 200, + "status": "stream" + } + }, { + "name": "images", + "url": "https://v.douyin.com/MdVwo31/", + "params": {}, + "expected": { + "code": 200, + "status": "picker" + } + }, { + "name": "long link inexistent", + "url": "https://www.douyin.com/video/7120851458451417478", + "params": {}, + "expected": { + "code": 400, + "status": "error" + } + }, { + "name": "short link inexistent", + "url": "https://v.douyin.com/2p4ewa7/", + "params": {}, + "expected": { + "code": 400, + "status": "error" + } + }], + "tiktok": [{ + "name": "short link (vt) video, with watermark", + "url": "https://vt.tiktok.com/ZS85U86aa/", + "params": {}, + "expected": { + "code": 200, + "status": "stream" + } + }, { + "name": "short link (vt) video (isNoTTWatermark)", + "url": "https://vt.tiktok.com/ZS85U86aa/", + "params": { + "isNoTTWatermark": true + }, + "expected": { + "code": 200, + "status": "stream" + } + }, { + "name": "short link (vm) video (isAudioOnly)", + "url": "https://vm.tiktok.com/ZMYrYAf34/", + "params": { + "isAudioOnly": true + }, + "expected": { + "code": 200, + "status": "stream" + } + }, { + "name": "short link (vm) video (isAudioOnly, isTTFullAudio)", + "url": "https://vm.tiktok.com/ZMYrYAf34/", + "params": { + "isAudioOnly": true, + "isTTFullAudio": true + }, + "expected": { + "code": 200, + "status": "stream" + } + }, { + "name": "long link video (isNoTTWatermark)", + "url": "https://www.tiktok.com/@fatfatmillycat/video/7195741644585454894", + "params": { + "isNoTTWatermark": true + }, + "expected": { + "code": 200, + "status": "stream" + } + }, { + "name": "images", + "url": "https://vt.tiktok.com/ZS8JP89eB/", + "params": {}, + "expected": { + "code": 200, + "status": "picker" + } + }, { + "name": "long link inexistent", + "url": "https://www.tiktok.com/@blablabla/video/7120851458451417478", + "params": {}, + "expected": { + "code": 400, + "status": "error" + } + }, { + "name": "short link inexistent", + "url": "https://vt.tiktok.com/2p4ewa7/", + "params": {}, + "expected": { + "code": 400, + "status": "error" + } + }], + "bilibili": [{ + "name": "1080p video", + "url": "https://www.bilibili.com/video/BV18i4y1m7xV/", + "params": {}, + "expected": { + "code": 200, + "status": "stream" + } + }, { + "name": "1080p video muted", + "url": "https://www.bilibili.com/video/BV18i4y1m7xV/", + "params": { + "isAudioMuted": true + }, + "expected": { + "code": 200, + "status": "stream" + } + }, { + "name": "1080p vertical video", + "url": "https://www.bilibili.com/video/BV1uu411z7VV/", + "params": {}, + "expected": { + "code": 200, + "status": "stream" + } + }, { + "name": "1080p vertical video muted", + "url": "https://www.bilibili.com/video/BV1uu411z7VV/", + "params": { + "isAudioMuted": true + }, + "expected": { + "code": 200, + "status": "stream" + } + }], + "tumblr": [{ + "name": "at.tumblr link", + "url": "https://at.tumblr.com/music/704177038274281472/n7x7pr7x4w2b", + "params": {}, + "expected": { + "code": 200, + "status": "redirect" + } + }, { + "name": "user subdomain link", + "url": "https://garfield-69.tumblr.com/post/696499862852780032", + "params": {}, + "expected": { + "code": 200, + "status": "redirect" + } + }, { + "name": "web app link", + "url": "https://www.tumblr.com/rongzhi/707729381162958848/english-added-by-me?source=share", + "params": {}, + "expected": { + "code": 200, + "status": "redirect" + } + }], + "vimeo": [{ + "name": "4k progressive", + "url": "https://vimeo.com/288386543", + "params": { + "vQuality": "max" + }, + "expected": { + "code": 200, + "status": "redirect" + } + }, { + "name": "720p progressive", + "url": "https://vimeo.com/288386543", + "params": { + "vQuality": "mid" + }, + "expected": { + "code": 200, + "status": "redirect" + } + }, { + "name": "1080p dash parcel", + "url": "https://vimeo.com/774694040", + "params": { + "vQuality": "hig" + }, + "expected": { + "code": 200, + "status": "stream" + } + }, { + "name": "720p dash parcel", + "url": "https://vimeo.com/774694040", + "params": { + "vQuality": "mid" + }, + "expected": { + "code": 200, + "status": "stream" + } + }], + "reddit": [{ + "name": "video with audio", + "url": "https://www.reddit.com/r/catvideos/comments/b2rygq/my_new_kittens_1st_day_checking_out_his_new_home/?utm_source=share&utm_medium=web2x&context=3", + "params": {}, + "expected": { + "code": 200, + "status": "stream" + } + }, { + "name": "video with audio (isAudioOnly)", + "url": "https://www.reddit.com/r/catvideos/comments/b2rygq/my_new_kittens_1st_day_checking_out_his_new_home/?utm_source=share&utm_medium=web2x&context=3", + "params": { + "isAudioOnly": true + }, + "expected": { + "code": 200, + "status": "stream" + } + }, { + "name": "video with audio (isAudioMuted)", + "url": "https://www.reddit.com/r/catvideos/comments/b2rygq/my_new_kittens_1st_day_checking_out_his_new_home/?utm_source=share&utm_medium=web2x&context=3", + "params": { + "isAudioMuted": true + }, + "expected": { + "code": 200, + "status": "stream" + } + }, { + "name": "video without audio", + "url": "https://www.reddit.com/r/catvideos/comments/ftoeo7/luna_doesnt_want_to_be_bothered_while_shes_napping/?utm_source=share&utm_medium=web2x&context=3", + "params": {}, + "expected": { + "code": 200, + "status": "redirect" + } + }, { + "name": "actual gif, not looping video", + "url": "https://www.reddit.com/r/whenthe/comments/109wqy1/god_really_did_some_trolling/?utm_source=share&utm_medium=web2x&context=3", + "params": {}, + "expected": { + "code": 200, + "status": "redirect" + } + }] +} \ No newline at end of file