mirror of
https://github.com/wukko/cobalt.git
synced 2025-06-12 21:27:39 +02:00
twitter: add option to convert .mp4 to .gif
This commit is contained in:
@ -37,7 +37,8 @@ export default async function(host, patternMatch, url, lang, obj) {
|
||||
case "twitter":
|
||||
r = await twitter({
|
||||
id: patternMatch.id,
|
||||
index: patternMatch.index - 1
|
||||
index: patternMatch.index - 1,
|
||||
toGif: obj.twitterGif
|
||||
});
|
||||
break;
|
||||
case "vk":
|
||||
@ -166,7 +167,11 @@ export default async function(host, patternMatch, url, lang, obj) {
|
||||
: loc(lang, r.error)
|
||||
})
|
||||
|
||||
return matchActionDecider(r, host, obj.aFormat, isAudioOnly, lang, isAudioMuted, disableMetadata, obj.filenamePattern)
|
||||
return matchActionDecider(
|
||||
r, host, obj.aFormat, isAudioOnly,
|
||||
lang, isAudioMuted, disableMetadata,
|
||||
obj.filenamePattern, obj.twitterGif
|
||||
)
|
||||
} catch (e) {
|
||||
return apiJSON(0, { t: genericError(lang, host) })
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ import { apiJSON } from "../sub/utils.js";
|
||||
import loc from "../../localization/manager.js";
|
||||
import createFilename from "./createFilename.js";
|
||||
|
||||
export default function(r, host, userFormat, isAudioOnly, lang, isAudioMuted, disableMetadata, filenamePattern) {
|
||||
export default function(r, host, userFormat, isAudioOnly, lang, isAudioMuted, disableMetadata, filenamePattern, toGif) {
|
||||
let action,
|
||||
responseType = 2,
|
||||
defaultParams = {
|
||||
@ -14,13 +14,14 @@ export default function(r, host, userFormat, isAudioOnly, lang, isAudioMuted, di
|
||||
fileMetadata: !disableMetadata ? r.fileMetadata : false
|
||||
},
|
||||
params = {},
|
||||
audioFormat = String(userFormat)
|
||||
audioFormat = String(userFormat);
|
||||
|
||||
if (r.isPhoto) action = "photo";
|
||||
else if (r.picker) action = "picker"
|
||||
else if (isAudioMuted) action = "muteVideo";
|
||||
else if (isAudioOnly) action = "audio";
|
||||
else if (r.isM3U8) action = "singleM3U8";
|
||||
else if (r.isGif && toGif) action = "gif";
|
||||
else action = "video";
|
||||
|
||||
if (action === "picker" || action === "audio") {
|
||||
@ -39,6 +40,10 @@ export default function(r, host, userFormat, isAudioOnly, lang, isAudioMuted, di
|
||||
case "photo":
|
||||
responseType = 1;
|
||||
break;
|
||||
|
||||
case "gif":
|
||||
params = { type: "gif" }
|
||||
break;
|
||||
|
||||
case "singleM3U8":
|
||||
params = { type: "remux" }
|
||||
|
@ -72,7 +72,7 @@ const requestTweet = (tweetId, token) => {
|
||||
})
|
||||
}
|
||||
|
||||
export default async function({ id, index }) {
|
||||
export default async function({ id, index, toGif }) {
|
||||
let guestToken = await getGuestToken();
|
||||
if (!guestToken) return { error: 'ErrorCouldntFetch' };
|
||||
|
||||
@ -110,7 +110,8 @@ export default async function({ id, index }) {
|
||||
type: needsFixing(media[0]) ? "remux" : "normal",
|
||||
urls: bestQuality(media[0].video_info.variants),
|
||||
filename: `twitter_${id}.mp4`,
|
||||
audioFilename: `twitter_${id}_audio`
|
||||
audioFilename: `twitter_${id}_audio`,
|
||||
isGif: media[0].type === "animated_gif"
|
||||
};
|
||||
default:
|
||||
const picker = media.map((video, i) => {
|
||||
@ -120,7 +121,9 @@ export default async function({ id, index }) {
|
||||
service: 'twitter',
|
||||
type: 'remux',
|
||||
u: url,
|
||||
filename: `twitter_${id}_${i + 1}.mp4`
|
||||
filename: `twitter_${id}_${i + 1}.mp4`,
|
||||
isGif: media[0].type === "animated_gif",
|
||||
toGif: toGif ?? false
|
||||
})
|
||||
}
|
||||
return {
|
||||
|
Reference in New Issue
Block a user