Closed Enes-Kayiklik closed 1 year ago
This isn't something I've encountered in my testing. It's possible you may need to use a proxy, which should be doable in version 0.1.11
. It's worth noting that these links do go stale after a time. I've seen them go stale after anywhere from 30 minutes to 2 hours.
It seems to be permanently blocked probably by some anti-bot mechanisms. 1-2 weeks ago I was able to download some videos (not all of them due to Forbidden
issue) but now all videos I'm trying to grab, are blocked. Even if I re-generate link (multiple trials) like @Enes-Kayiklik
Again, I'm not having this problem, so I don't have a good way to debug it. I need some more information:
If someone experiencing this issue can answer all of these questions I'll be better able to address the issue.
Also experiencing this issue, I tried re-generating the link multiple times with no luck.
import asyncio
import aiofiles
import aiohttp
from tiktokapipy.async_api import AsyncTikTokAPI
from tiktokapipy.models.video import Video
hashtag = "technews"
async def save_video(video: Video): async with aiohttp.ClientSession() as session: async with session.get(video.video.download_addr) as resp: content = await resp.content.read() async with aiofiles.open("video.mp4", mode="wb") as f: await f.write(content)
async def main(): async with AsyncTikTokAPI() as api: challenge = await api.challenge(hashtag) async for video in challenge.videos: creator = await video.creator() print("===================================") print("Username:", creator.unique_id) print("Caption:", video.desc) await save_video(video) break
if name == 'main': asyncio.run(main())
Videos
or The best
tab, TikTok requires signing in.403 - Forbidden
.
from tiktokapipy.api import TikTokAPI
import urllib.request as req
with TikTokAPI() as api: videos_wrapper = api.challenge("funnyvideos", video_limit=1) for video_el in videos_wrapper.videos: link = f"https://www.tiktok.com/@{video_el.author}/video/{video_el.id}" video = api.video(link) req.urlretrieve(video.video.download_addr, "output.mp4")
@papayyg found a solution that works for them in #35. Hopefully this can work for you. I'll add it to the documentation soon.
Yes #35 worked for me. Thank you for your response.
Some video links are returning '403 Forbidden' when I try to open them. After sending one more request to get video information, it fixes but it wasting time.
Here is my code:
I realize patterns between working videos and not working videos.
Sample working video link:
https://v16-webapp.tiktok.com/612dc7b3bd400a2ccd84af58fdbba950/63d15716/video/tos/useast2a/tos-useast2a-pve-0037c001-aiso/o8DYgoPAliHy5aGSOe2Erh0KfZrfkOEQAHGZeC/?a=1988&ch=0&cr=0&dr=0&lr=tiktok&cd=0%7C0%7C1%7C0&cv=1&br=4260&bt=2130&cs=0&ds=3&ft=4b~OyMlh8Zmo0Cd6I64jVhLWypWrKsdm&mime_type=video_mp4&qs=0&rc=MzY7NmY4OGZnZjY8ZzxmZkBpam87NWU6ZnA6aTMzZjgzM0A0YGIyM182XjExLWExNDUvYSNhLmwzcjRnMTVgLS1kL2Nzcw%3D%3D&l=20230125102117B681AB00030843ACF23F&btag=80000
Sample not working video link:
https://v16-webapp-prime.tiktok.com/video/tos/useast2a/tos-useast2a-pve-0037-aiso/oEbqy7f2KjVLQQDyUec8GCmnBHD80oVhnWPAgD/?a=1988&ch=0&cr=0&dr=0&lr=tiktok&cd=0%7C0%7C1%7C0&cv=1&br=2520&bt=1260&cs=0&ds=3&ft=4fUEKMlh8Zmo03d6I64jVVO1ZpWrKsdm&mime_type=video_mp4&qs=0&rc=NmY4NjNlZDM3M2VnOGU3aUBpM3d2czg6ZnRkaTMzZjgzM0BfMl9gLl9hXzQxMzUxXzQzYSNzcF9kcjRnZzVgLS1kL2Nzcw%3D%3D&btag=80000&expire=1674663675&l=202301251021026E4C2DACC26490AAE1A6&ply_type=2&policy=2&signature=e303281836dfc4b2b8d8acfe4beb9963&tk=tt_chain_token
not working videos are ends with
chain_token
I'll be happy if anybody can help me about this.
tiktokapipy
version is0.1.10.post1