twitter: remux all videos

- increased stream link lifespan to 90 seconds
- decreased max video duration back to 3 hours
This commit is contained in:
wukko
2023-12-02 20:44:19 +06:00
parent aef9b390b0
commit 5bd50fd55f
10 changed files with 78 additions and 54 deletions

View File

@ -40,6 +40,7 @@ export default function(r, host, audioFormat, isAudioOnly, lang, isAudioMuted, d
case "bilibili":
params = { type: "render" };
break;
case "twitter":
case "youtube":
params = { type: r.type };
break;
@ -64,7 +65,6 @@ export default function(r, host, audioFormat, isAudioOnly, lang, isAudioMuted, d
case "vine":
case "instagram":
case "tumblr":
case "twitter":
case "pinterest":
case "streamable":
responseType = 1;
@ -72,7 +72,7 @@ export default function(r, host, audioFormat, isAudioOnly, lang, isAudioMuted, d
}
break;
case "singleM3U8":
params = { type: "videoM3U8" }
params = { type: "remux" }
break;
case "muteVideo":
params = {
@ -107,14 +107,17 @@ export default function(r, host, audioFormat, isAudioOnly, lang, isAudioMuted, d
break;
case "audio":
if ((host === "reddit" && r.typeId === 1) || audioIgnore.includes(host)) return apiJSON(0, { t: loc(lang, 'ErrorEmptyDownload') });
if ((host === "reddit" && r.typeId === 1) || audioIgnore.includes(host)) {
return apiJSON(0, { t: loc(lang, 'ErrorEmptyDownload') })
}
let processType = "render";
let copy = false;
if (!supportedAudio.includes(audioFormat)) audioFormat = "best";
if ((host === "tiktok" || host === "douyin") && services.tiktok.audioFormats.includes(audioFormat)) {
if ((host === "tiktok" || host === "douyin")
&& services.tiktok.audioFormats.includes(audioFormat)) {
if (r.isMp3) {
if (audioFormat === "mp3" || audioFormat === "best") {
audioFormat = "mp3";
@ -125,11 +128,13 @@ export default function(r, host, audioFormat, isAudioOnly, lang, isAudioMuted, d
processType = "bridge"
}
}
if (host === "tumblr" && !r.filename && (audioFormat === "best" || audioFormat === "mp3")) {
if (host === "tumblr" && !r.filename
&& (audioFormat === "best" || audioFormat === "mp3")) {
audioFormat = "mp3";
processType = "bridge"
}
if ((audioFormat === "best" && services[host]["bestAudio"]) || (services[host]["bestAudio"] && (audioFormat === services[host]["bestAudio"]))) {
if ((audioFormat === "best" && services[host]["bestAudio"])
|| (services[host]["bestAudio"] && (audioFormat === services[host]["bestAudio"]))) {
audioFormat = services[host]["bestAudio"];
if (host === "soundcloud") {
processType = "render"

View File

@ -1,4 +1,5 @@
import { genericUserAgent } from "../../config.js";
import { createStream } from "../../stream/manage.js";
function bestQuality(arr) {
return arr.filter(v => v["content_type"] === "video/mp4").sort((a, b) => Number(b.bitrate) - Number(a.bitrate))[0]["url"]
@ -39,7 +40,7 @@ export default async function(obj) {
let tweet = await fetch(query, { headers: _headers }).then((r) => {
return r.status === 200 ? r.json() : false
}).catch((e) => { return false });
}).catch(() => { return false });
// {"data":{"tweetResult":{"result":{"__typename":"TweetUnavailable","reason":"Protected"}}}}
if (tweet?.data?.tweetResult?.result?.__typename !== "Tweet") {
@ -64,7 +65,12 @@ export default async function(obj) {
multiple.push({
type: "video",
thumb: media[i]["media_url_https"],
url: bestQuality(media[i]["video_info"]["variants"])
url: createStream({
service: "twitter",
type: "remux",
u: bestQuality(media[i]["video_info"]["variants"]),
filename: `twitter_${obj.id}_${Number(i) + 1}.mp4`
})
})
}
} else if (media.length === 1) {
@ -75,6 +81,7 @@ export default async function(obj) {
if (single) {
return {
type: "remux",
urls: single,
filename: `twitter_${obj.id}.mp4`,
audioFilename: `twitter_${obj.id}_audio`