n0l3r / tiktok-downloader

tiktok downloader is a tool to download video from tiktok with watermark or without watermark. There are two features that is, mass download (by username/urls) and single download (by url).
MIT License
327 stars 130 forks source link

I have a suggestion #31

Open daltonjames777 opened 1 year ago

daltonjames777 commented 1 year ago

your code works quite well, is it possible to find 1 api which can download videos in hd format, similar to the api that https://musicaldown.com/en uses, to download videos in hd format? Thank you

timmbobb commented 4 months ago

Hmm, I didn't even realize that it was possible to get them in a higher resolution. Wonder what would need to be done to do that here...

jgore077 commented 4 months ago

I thought they were already pretty high in resolution

timmbobb commented 4 months ago

The ones downloaded using this are in 576x1024, whereas the site he mentioned above allows you to download them at 1080x1920. Would be pretty neat if we could get it to do that.

timmbobb commented 4 months ago

Tiktoks are also stored at 1080x1920 so it's odd that it gets a lower resolution.

timmbobb commented 4 months ago

The yt-dl tiktok.py (https://github.com/yt-dlp/yt-dlp/blob/master/yt_dlp/extractor/tiktok.py) is capable of downloading in 1080x1920. I'm not sure I'm smart enough to figure out what they're doing differently in it to get it at 1080x1920, but it would be nice to figure out. If anyone wants to try and implement what they're doing here I would love to help.

jgore077 commented 4 months ago

I can try to help

jgore077 commented 4 months ago

Also I couldnt get the scraper to work without loading my own cookies

ltm7725 commented 4 months ago

The yt-dl tiktok.py (https://github.com/yt-dlp/yt-dlp/blob/master/yt_dlp/extractor/tiktok.py) is capable of downloading in 1080x1920. I'm not sure I'm smart enough to figure out what they're doing differently in it to get it at 1080x1920, but it would be nice to figure out. If anyone wants to try and implement what they're doing here I would love to help.

I tried to dig into yt-dl a little, and was actually only able to extracting a 1080p video using OUR current API hostname (api16-normal-c-useast2a.tiktokv.com) with it instead of theirs (api22-normal-c-useast2a.tiktokv.com) which I was only receiving that 576x1024 from that we get already.

I may be missing something in the our API's return block; I'm making requests & looking through the JSON on Postman to test. But in that data I can only find direct links for a couple of the 574p formats, as opposed to ALL of these that show up using our host address on yt-dl:

image

So I'm a bit more confused than when I started rn. If you wanna try digging into these to see if anything's sitting there you can use "api16-normal-c-useast2a.tiktokv.com/aweme/v1/feed/?aweme_id=[VIDEO_ID]" or "api22-normal-c-useast2a.tiktokv.com/aweme/v1/feed/?aweme_id=[VIDEO_ID]" otherwise I'll try more when I get a chance. Idk much beyond the basics when it comes to APIs themselves, but if it's not directly in the JSON block then maybe someone a little more experienced in Python than myself could look through that yt-dl code a bit more to uncover what they're extracting out of there.

jgore077 commented 4 months ago

When you swap the endpoint with https://api22-normal-c-useast2a.tiktokv.com/aweme/v1/feed/?aweme_id=${idVideo} the .mp4s no longer have any content perhaps the video is some kind of bytestring? Also I had to use cookies to get my mass download to work but have you gotten it working without cookies?

timmbobb commented 4 months ago

I think it's the way they setup their cookies that might be why it works? Another thing; This repo can successfully download all tiktoks, even ones with the sound removed. The yt-dlp program will fail to download tiktoks that have had the sound removed. Not entirely sure why this is, just something I noticed.

It would be interesting to see if we could get someone from that repo that's worked on the tiktok extractor to explain what they are doing specifically to get the higher resolutions.