mirror of
https://github.com/imputnet/cobalt.git
synced 2025-07-18 11:18:28 +00:00
tiktok: remove unnecessary username from the download process
This commit is contained in:
parent
606eb6212d
commit
d801d57a65
@ -111,7 +111,6 @@ export default async function(host, patternMatch, lang, obj) {
|
|||||||
r = await tiktok({
|
r = await tiktok({
|
||||||
postId: patternMatch.postId,
|
postId: patternMatch.postId,
|
||||||
id: patternMatch.id,
|
id: patternMatch.id,
|
||||||
user: patternMatch.user,
|
|
||||||
fullAudio: obj.isTTFullAudio,
|
fullAudio: obj.isTTFullAudio,
|
||||||
isAudioOnly: isAudioOnly,
|
isAudioOnly: isAudioOnly,
|
||||||
h265: obj.tiktokH265
|
h265: obj.tiktokH265
|
||||||
|
@ -8,9 +8,8 @@ export const cookie = new Cookie({})
|
|||||||
|
|
||||||
export default async function(obj) {
|
export default async function(obj) {
|
||||||
let postId = obj.postId
|
let postId = obj.postId
|
||||||
let username = obj.user
|
|
||||||
|
|
||||||
if (!username || !postId) {
|
if (!postId) {
|
||||||
let html = await fetch(`${shortDomain}${obj.id}`, {
|
let html = await fetch(`${shortDomain}${obj.id}`, {
|
||||||
redirect: "manual",
|
redirect: "manual",
|
||||||
headers: {
|
headers: {
|
||||||
@ -22,14 +21,13 @@ export default async function(obj) {
|
|||||||
|
|
||||||
if (html.startsWith('<a href="https://')) {
|
if (html.startsWith('<a href="https://')) {
|
||||||
const { patternMatch } = extract(html.split('<a href="https://')[1].split('?')[0])
|
const { patternMatch } = extract(html.split('<a href="https://')[1].split('?')[0])
|
||||||
username = patternMatch.user
|
|
||||||
postId = patternMatch.postId
|
postId = patternMatch.postId
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!username || !postId) return { error: 'ErrorCantGetID' };
|
if (!postId) return { error: 'ErrorCantGetID' };
|
||||||
|
|
||||||
// should always be /video/, even for photos
|
// should always be /video/, even for photos
|
||||||
const res = await fetch(`https://tiktok.com/${username}/video/${postId}`, {
|
const res = await fetch(`https://tiktok.com/@i/video/${postId}`, {
|
||||||
headers: {
|
headers: {
|
||||||
"user-agent": genericUserAgent,
|
"user-agent": genericUserAgent,
|
||||||
cookie,
|
cookie,
|
||||||
|
Loading…
Reference in New Issue
Block a user