mirror of
https://github.com/wukko/cobalt.git
synced 2025-06-13 13:47:38 +02:00
tiktok: use new cookie for each request (#514)
* api: allow passing headers from service handler * tiktok: use new cookie for each request
This commit is contained in:
@ -9,6 +9,7 @@ export default function(r, host, userFormat, isAudioOnly, lang, isAudioMuted, di
|
||||
responseType = "stream",
|
||||
defaultParams = {
|
||||
u: r.urls,
|
||||
headers: r.headers,
|
||||
service: host,
|
||||
filename: r.filenameAttributes ?
|
||||
createFilename(r.filenameAttributes, filenamePattern, isAudioOnly, isAudioMuted) : r.filename,
|
||||
@ -80,6 +81,7 @@ export default function(r, host, userFormat, isAudioOnly, lang, isAudioMuted, di
|
||||
service: "tiktok",
|
||||
type: audioStreamType,
|
||||
u: r.urls,
|
||||
headers: r.headers,
|
||||
filename: r.audioFilename,
|
||||
isAudioOnly: true,
|
||||
audioFormat,
|
||||
|
@ -4,9 +4,9 @@ import { extract } from "../url.js";
|
||||
import Cookie from "../cookie/cookie.js";
|
||||
|
||||
const shortDomain = "https://vt.tiktok.com/";
|
||||
export const cookie = new Cookie({});
|
||||
|
||||
export default async function(obj) {
|
||||
const cookie = new Cookie({});
|
||||
let postId = obj.postId;
|
||||
|
||||
if (!postId) {
|
||||
@ -75,32 +75,46 @@ export default async function(obj) {
|
||||
if (audio.includes("mime_type=audio_mpeg")) bestAudio = 'mp3';
|
||||
}
|
||||
|
||||
if (video) return {
|
||||
urls: video,
|
||||
filename: videoFilename
|
||||
if (video) {
|
||||
return {
|
||||
urls: video,
|
||||
filename: videoFilename,
|
||||
headers: { cookie }
|
||||
}
|
||||
}
|
||||
if (images && obj.isAudioOnly) return {
|
||||
urls: audio,
|
||||
audioFilename: audioFilename,
|
||||
isAudioOnly: true,
|
||||
bestAudio
|
||||
|
||||
if (images && obj.isAudioOnly) {
|
||||
return {
|
||||
urls: audio,
|
||||
audioFilename: audioFilename,
|
||||
isAudioOnly: true,
|
||||
bestAudio,
|
||||
headers: { cookie }
|
||||
}
|
||||
}
|
||||
|
||||
if (images) {
|
||||
let imageLinks = images
|
||||
.map(i => i.imageURL.urlList.find(p => p.includes(".jpeg?")))
|
||||
.map(url => ({ url }))
|
||||
.map(url => ({ url }));
|
||||
|
||||
return {
|
||||
picker: imageLinks,
|
||||
urls: audio,
|
||||
audioFilename: audioFilename,
|
||||
isAudioOnly: true,
|
||||
bestAudio
|
||||
bestAudio,
|
||||
headers: { cookie }
|
||||
}
|
||||
}
|
||||
if (audio) return {
|
||||
urls: audio,
|
||||
audioFilename: audioFilename,
|
||||
isAudioOnly: true,
|
||||
bestAudio
|
||||
|
||||
if (audio) {
|
||||
return {
|
||||
urls: audio,
|
||||
audioFilename: audioFilename,
|
||||
isAudioOnly: true,
|
||||
bestAudio,
|
||||
headers: { cookie }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user