You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am encountering an issue when trying to download videos using the example provided in the documentation. When calling video.bytes(), I receive the following error:
The buggy code
import asyncio
from TikTokApi import TikTokApi
import os
ms_token = "XXX"
proxy = {
"server": "http://XXX:XX",
"username": "XXX",
"password": "XXX",
}
async def download_videos():
async with TikTokApi() as api:
await api.create_sessions(
ms_tokens=ms_token,
num_sessions=1,
sleep_after=3,
browser=os.getenv("TIKTOK_BROWSER", "chromium"),
proxies=[proxy],
)
video_bytes = await api.video(id="11111111").bytes()
with open("video.mp4", "wb") as f:
f.write(video_bytes)
if __name__ == "__main__":
asyncio.run(download_videos())
Expected behavior
The script should successfully fetch and download the video.
**Error Trace **
Put the error trace below if there's any error thrown.
Traceback (most recent call last):
File "/Users/francesco/Documents/FH-Salzburg/Work/video_download/download.py", line 32, in <module>
asyncio.run(download_videos())
~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/[email protected]/3.13.1/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/runners.py", line 194, in run
return runner.run(main)
~~~~~~~~~~^^^^^^
File "/usr/local/Cellar/[email protected]/3.13.1/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "/usr/local/Cellar/[email protected]/3.13.1/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/base_events.py", line 720, in run_until_complete
return future.result()
~~~~~~~~~~~~~^^
File "/Users/francesco/Documents/FH-Salzburg/Work/video_download/download.py", line 26, in download_videos
video_bytes = await api.video(id="7439089243546193174").bytes()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/francesco/Documents/FH-Salzburg/Work/video_download/.venv/lib/python3.13/site-packages/TikTokApi/api/video.py", line 188, in bytes
downloadAddr = self.as_dict["video"]["downloadAddr"]
^^^^^^^^^^^^
AttributeError: 'Video' object has no attribute 'as_dict'
Desktop (please complete the following information):
OS: Macos 15.3
TikTokApi Version: 7.0.0
The text was updated successfully, but these errors were encountered:
I am encountering an issue when trying to download videos using the example provided in the documentation. When calling video.bytes(), I receive the following error:
The buggy code
Expected behavior
The script should successfully fetch and download the video.
**Error Trace **
Put the error trace below if there's any error thrown.
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: