mirror of
https://github.com/imputnet/cobalt.git
synced 2025-12-17 13:38:52 +00:00
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
This commit is contained in:
@@ -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 }
|
||||
|
||||
@@ -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) === '<a href="https://' && html.includes('/video/')) {
|
||||
obj.postId = html.split('/video/')[1].split('?')[0].replace("/", '')
|
||||
} else if (html.slice(0, 32) === '<a href="https://m.tiktok.com/v/' && html.includes('/v/')) {
|
||||
@@ -59,10 +59,10 @@ export default async function(obj) {
|
||||
}
|
||||
|
||||
if (!obj.isAudioOnly && !images) {
|
||||
video = obj.host === "tiktok" ? detail["video"]["download_addr"]["url_list"][0] : detail['video']['play_addr']['url_list'][0];
|
||||
video = obj.host === "tiktok" ? detail["video"]["download_addr"]["url_list"][0] : detail["video"]["play_addr"]["url_list"][2].replace("/play/", "/playwm/");
|
||||
videoFilename = `${filenameBase}_video.mp4`;
|
||||
if (obj.noWatermark) {
|
||||
video = obj.host === "tiktok" ? detail["video"]["play_addr"]["url_list"][0] : detail["video"]["play_addr"]["url_list"][0].replace("playwm", "play");
|
||||
video = obj.host === "tiktok" ? detail["video"]["play_addr"]["url_list"][0] : detail["video"]["play_addr"]["url_list"][0];
|
||||
videoFilename = `${filenameBase}_video_nw.mp4` // nw - no watermark
|
||||
}
|
||||
} else {
|
||||
@@ -80,13 +80,11 @@ export default async function(obj) {
|
||||
urls: video,
|
||||
filename: videoFilename
|
||||
}
|
||||
if (images && obj.isAudioOnly) {
|
||||
return {
|
||||
urls: audio,
|
||||
audioFilename: audioFilename,
|
||||
isAudioOnly: true,
|
||||
isMp3: isMp3,
|
||||
}
|
||||
if (images && obj.isAudioOnly) return {
|
||||
urls: audio,
|
||||
audioFilename: audioFilename,
|
||||
isAudioOnly: true,
|
||||
isMp3: isMp3
|
||||
}
|
||||
if (images) {
|
||||
let imageLinks = [];
|
||||
@@ -100,13 +98,13 @@ export default async function(obj) {
|
||||
urls: audio,
|
||||
audioFilename: audioFilename,
|
||||
isAudioOnly: true,
|
||||
isMp3: isMp3,
|
||||
isMp3: isMp3
|
||||
}
|
||||
}
|
||||
if (audio) return {
|
||||
urls: audio,
|
||||
audioFilename: audioFilename,
|
||||
isAudioOnly: true,
|
||||
isMp3: isMp3,
|
||||
isMp3: isMp3
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user