This document contains code to download videos from Douyin (TikTok) accounts. It uses the Douyin API to retrieve a list of videos from a user's account based on their user ID. Each video URL, ID, description, and channel are added to an array. It then loops through the array, downloading each video as an MP4 file after a 5 second delay between downloads.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
117 views2 pages
Douyin Cod 2
This document contains code to download videos from Douyin (TikTok) accounts. It uses the Douyin API to retrieve a list of videos from a user's account based on their user ID. Each video URL, ID, description, and channel are added to an array. It then loops through the array, downloading each video as an MP4 file after a 5 second delay between downloads.
var result = []; var hasMore = 1; var sec_user_id = location.pathname.replace("/user/", ""); var max_cursor = 0; var download_from = prompt("Enter the video ID (Enter 0 if you want to download all videos):", ""); if (download_from == null || download_from == "") { alert("Please enter the video ID!"); return; } var channel = prompt("Enter the channel link:", ""); if (channel == null || channel == "") { alert("Please enter the channel link!"); return; } while (hasMore == 1) { var moredata = await getid(sec_user_id, max_cursor); hasMore = moredata['has_more']; max_cursor = moredata['max_cursor']; for (var i in moredata['aweme_list']) { if (moredata['aweme_list'][i]['aweme_id'] == download_from) { hasMore = 0; break; } if (moredata['aweme_list'][i]['video']['play_addr']['url_list'] [0].startsWith("https")) result.push([moredata['aweme_list'][i]['video']['play_addr']['url_list'] [0], moredata['aweme_list'][i]['aweme_id'], moredata['aweme_list'][i]['desc'], channel]); else result.push([moredata['aweme_list'][i]['video']['play_addr']['url_list'] [0].replace("http", "https"), moredata['aweme_list'][i]['aweme_id'], moredata['aweme_list'][i]['desc'], channel]); console.clear(); console.log("Number of videos: " + result.length); } } for (var i = result.length - 1; i >= 0; i--) { await waitforme(5000); try { download(result[i][0], result[i][1], result[i][2], result[i][3]); } catch {} } } run();