Johnserf-Seed / f2

High-speed downloader for multiple platforms
https://johnserf-seed.github.io/f2/
Apache License 2.0
553 stars 109 forks source link

tiktok下载单个视频报错 #148

Open hunniman opened 4 months ago

hunniman commented 4 months ago

import asyncio

from f2.apps.tiktok.handler import TiktokHandler from f2.apps.tiktok.utils import SecUserIdFetcher, AwemeIdFetcher from f2.utils.utils import extract_valid_urls

async def main(): raw_url = ( "https://www.tiktok.com/@niiyamanaoto/video/7374702099826855175?is_from_webapp=1&sender_device=pc" ) aweme_id= await AwemeIdFetcher.get_aweme_id(raw_url)

print(aweme_id)
kwargs = {
    "headers": {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36 Edg/126.0.0.0",
        "Referer": "https://www.tiktok.com/",
    },
    "cookie": "real cookie xxx",
    "proxies": {"http://": None, "https://": None},
    "url": "https://www.tiktok.com/@niiyamanaoto/video/7374702099826855175?is_from_webapp=1&sender_device=pc",
    "interval": "all",
}

# video = await TiktokHandler(kwargs).fetch_one_video(itemId=aweme_id)
video2 = await TiktokHandler(kwargs).handle_one_video()

if name == "main": print(asyncio.run(main()))

aweme_id能拿到

ERROR 连接超时错误:
https://v16-webapp-prime.tiktok.com/video/tos/alisg/tos-alisg-pve-0037 /oIbgGIcVweMAmehb2rIQCLsErDvG0A7goQeqyC/?a=1988&bti=ODszNWYuMDE6&ch=0& cr=3&dr=0&lr=unwatermarked&cd=0%7C0%7C0%7C&cv=1&br=2792&bt=1396&cs=0&d s=6&ft=I~da4os3D12NvF0hfhIxRG2NglBF-UjNSkopiX&mime_type=video_mp4&qs=0 &rc=MzdnNzc5NjlpNDRpODZkO0BpajRrOXk5cnQ2czMzODgzNEAwYF81MGAxNi4xNWMwLW I2YSM2Zm5hMmRrYmBgLS1kLy1zcw%3D%3D&btag=e00090000&expire=1721213193&l= 20240717044509437D1B86BF3A11072591&ply_type=2&policy=2&signature=d6c0b 7d347b0e573aef2e8994762d762&tk=tt_chain_token

Johnserf-Seed commented 3 months ago

需要带headers去请求视频地址,包含ua cookie referer

SoDam-C commented 1 month ago

请问解决了吗,遇到了同样的问题