tiktok: remove unnecessary username from the download process

This commit is contained in:
Damir Modyarov 2024-05-21 21:00:50 +03:00
parent 606eb6212d
commit d801d57a65
No known key found for this signature in database
2 changed files with 3 additions and 6 deletions

View File

@ -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

View File

@ -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,