rouze-d / tiktok-download

Simple TikTok Video / Photo Downloader
43 stars 8 forks source link

It works fine! #4

Closed UnixCro closed 3 years ago

UnixCro commented 3 years ago

Hi rouze-d, I tested your program. It works really well and is very simple, maybe I could ask you how you did it? I tried to download videos with the terminal via wget with the video address and the Tiktok link but it didn't work.

Do you also know how to do that manually with the terminal haha? I am looking forward to your answer

rouze-d commented 3 years ago

Hi UnixCro, I just import cookies from internet browser. See line 32 tiktok.sh script. wget --load-cookies https://github.com/rouze-d/tiktok-download/blob/master/tiktok.png

UnixCro commented 3 years ago

First, thanks for your answer.

I see you have used an add-on on Chrome to download the cookies. I also downloaded that and executed the Tiktok cookie text file from "https://www.tiktok.com/@lisaandlena" and deleted everything that began with "#" and moved the rest of the cookie up.

I then wrote wget --no-check-certificate --load-cookies=mycookiefile.txt https://www.tiktok.com/@lisaandlena/video/6903207306465398017.mp4

loads that down but the file does not take up any memory and cannot be opened

Could you maybe tell me what i did wrong

rouze-d commented 3 years ago

Hi UnixCro,

https://www.tiktok.com/@lisaandlena/video/6903207306465398017 is not are video format. it's URL address page contains with video URL address..

first, open URL address with curl : don't forget to set --user-agent and --cookie filter curl output with 'tr / grep / tail / sed' (| tr '"' '\n' | grep -i -E 'video/[a-z]'|'.mp4' | tail -n 1 | sed 's/\u0026/\&/g')

Example curl request command:

curl -s -k --cookie mycookiefile.txt --url https://www.tiktok.com/node/share/video/@lisaandlena/6903207306465398017 --user-agent 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36' | tr '"' '\n' | grep -i -E 'video/[a-z]'\|'.mp4' | tail -n 1 | sed 's/\\u0026/\&/g'

output (real video URL address):

https://v16-web.tiktok.com/video/tos/alisg/tos-alisg-pve-0037c001/4f69fa2b1da544f996cf8b20972c0a9c/?a=1988&br=2500&bt=1250&cd=0%7C0%7C1&cr=0&cs=0&cv=1&dr=0&ds=3&er=&expire=1607382920&l=202012071714520101890651405802820E&lr=tiktok_m&mime_type=video_mp4&policy=2&qs=0&rc=ajhvbWU4aHZreTMzNDczM0ApOzRpZ2Q2Zzw6NzM6aDxoOWc0YGRyNC5gcDNfLS0tMTRzcy81MjQ1NDNhLzEzYDUxNT



now we get the video URL address with curl output: https://v16-web.tiktok.com/video/tos/alisg/tos-alisg-pve-0037c001/4f69fa2b1da544f996cf8b20972c0a9c/?a=1988&br=2500&bt=1250&cd=0%7C0%7C1&cr=0&cs=0&cv=1&dr=0&ds=3&er=&expire=1607382920&l=202012071714520101890651405802820E&lr=tiktok_m&mime_type=video_mp4&policy=2&qs=0&rc=ajhvbWU4aHZreTMzNDczM0ApOzRpZ2Q2Zzw6NzM6aDxoOWc0YGRyNC5gcDNfLS0tMTRzcy81MjQ1NDNhLzEzYDUxNT

now download video with URL address with wget: don't forget to set --load-cookie, --user-agent, --referer (set with URL address page 'https://www.tiktok.com/@lisaandlena/video/6903207306465398017' it's mean we request video from this page..

Example wget request command:

wget --load-cookies mycookiefile.txt --referer=https://www.tiktok.com/@lisaandlena/video/6903207306465398017 --user-agent 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36' -c 'https://v16-web.tiktok.com/video/tos/alisg/tos-alisg-pve-0037c001/4f69fa2b1da544f996cf8b20972c0a9c/?a=1988&br=2500&bt=1250&cd=0%7C0%7C1&cr=0&cs=0&cv=1&dr=0&ds=3&er=&expire=1607382790&l=202012071712420101901851302A02684C&lr=tiktok_m&mime_type=video_mp4&policy=2&qs=0&rc=ajhvbWU4aHZreTMzNDczM0ApOzRpZ2Q2Zzw6NzM6aDxoOWc0YGRyNC5gcDNfLS0tMTRzcy81MjQ1NDNhLzEzYDUxNTU6Yw%3D%3D&signature=606e6ad0103fd74c3243600779a0e679&tk=tt_webid_v2&vl=&vr=' -O output.mp4

Output:

--2020-12-08 01:28:40--  https://v16-web.tiktok.com/video/tos/alisg/tos-alisg-pve-0037c001/4f69fa2b1da544f996cf8b20972c0a9c/?a=1988&br=2500&bt=1250&cd=0%7C0%7C1&cr=0&cs=0&cv=1&dr=0&ds=3&er=&expire=1607382790&l=202012071712420101901851302A02684C&lr=tiktok_m&mime_type=video_mp4&policy=2&qs=0&rc=ajhvbWU4aHZreTMzNDczM0ApOzRpZ2Q2Zzw6NzM6aDxoOWc0YGRyNC5gcDNfLS0tMTRzcy81MjQ1NDNhLzEzYDUxNTU6Yw%3D%3D&signature=606e6ad0103fd74c3243600779a0e679&tk=tt_webid_v2&vl=&vr=
Resolving v16-web.tiktok.com (v16-web.tiktok.com)... 23.59.168.56
Connecting to v16-web.tiktok.com (v16-web.tiktok.com)|23.59.168.56|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 4569959 (4.4M) [video/mp4]
Saving to: ‘output.mp4’

output.mp4  100%[====================================================>]   4.36M
2020-12-08 01:28:50 (588 KB/s) - ‘output.mp4’ saved [4569959/4569959]

if you open tik.sh script, you can see this command on line 47 and 52. thanks for asking.

UnixCro commented 3 years ago

Wow, how much time and nerves you have invested in this post. Thank you so much

I tried this with curl and was able to see the video address and then download it with wget. It worked immediately!

Thank you