Open Mitix-EPI opened 3 years ago
This may be an issue with the avilash TikTokAPI or could be Token Related not sure right now. If you peer into the "Broken" mp4 that get outputted into the VideoFiles folder you'll see the following. (Open with Text Editor or view with VSCode)
`
You don't have permission to access "http://v16-web.tiktok.com/video/tos/useast2a/tos-useast2a-ve-0068c003/266a4097bbec490ebbb277817c074f2a/?" on this server.
Reference #18.54a8ce17.1616762934.62c4c265 ` [EDIT] Upon further Inspection the issue is with the .downloadVideoById method in the avilash TikTokAPI Here is a quick fix until the API can be properly fixed
tiktok.py
[Top Imports Section Add]
import requests
import time
[Replace]
try:
api.downloadVideoById(clip.id, f"{settings.vid_filepath}/{clip.author_name}-{clip.id}.mp4")
media_info = MediaInfo.parse(
f"{settings.vid_filepath}/{clip.author_name}-{clip.id}.mp4")
duration = media_info.tracks[0].duration
clip.vid_duration = float(duration) / 1000
database.updateStatusWithClip(clip.id, "DOWNLOADED", clip)
[With]
try:
#api.downloadVideoById(clip.id, f"{settings.vid_filepath}/{clip.author_name}-{clip.id}.mp4")
download_file = requests.get(clip.url)
with open(f"{settings.vid_filepath}/{clip.author_name}-{clip.id}.mp4", 'wb') as f:
f.write(download_file.content)
media_info = MediaInfo.parse(
f"{settings.vid_filepath}/{clip.author_name}-{clip.id}.mp4")
duration = media_info.tracks[0].duration
clip.vid_duration = float(duration) / 1000
database.updateStatusWithClip(clip.id, "DOWNLOADED", clip)
time.sleep(1)
Note: I added a 1 second sleep after each video download as TikTok has been started banning residential IPs and/or throttling, this slight delay should help keep them off your back
In TikTokServer, when I try to dl (clicking on
Start Downloading
), there are some errors on the terminal. I added some print to debug the thingTikTokServer/tiktok.py
I think the error is from the MediaInfo.
MediaInfo.parse
does not read correctly the file.Also, when I open Clip Bin, I can't play the videos. I don't know why ? Format mp4, ~380ko. I also try to read the informations inside the videos with the MediaInfo software but impossible to read any information.