Api of douyin for humans


Keywords
crawler, douyin, spider, videos
License
MIT
Install
pip install douyin==0.3.5

Documentation

ๆณจ๏ผš้กน็›ฎๅทฒไธๅฏ็”จ...

DouYin

API of DouYin App for humans.

Installation

pip3 install douyin

Usage

Here is the sample code:

import douyin
from douyin.structures import Topic, Music

# define file handler and specify folder
video_file_handler = douyin.handlers.VideoFileHandler(folder='./videos')
music_file_handler = douyin.handlers.MusicFileHandler(folder='./musics')
# define mongodb handler
mongo_handler = douyin.handlers.MongoHandler()
# define downloader
downloader = douyin.downloaders.VideoDownloader([mongo_handler, video_file_handler, music_file_handler])

for result in douyin.hot.trend():
    for item in result.data:
        # download videos of topic/music for 100 max per
        downloader.download(item.videos(max=100))

then you can get:

Item <Topic: <1565818716518401, panama>>
Processing <Video: <6616517521098935565, ็œŸ้ฆ™#panama>> ...
Processing <Video: <6500385230921141518, ๅ“ˆๅ“ˆๅ“ˆๅ“ˆๅ“ˆ>> ...
...
Processing <Video: <6479958542747962637, ๐Ÿ‘…เธเนˆเธญเธ™เธเธดเธ™เธ‚เน‰>> ...
Processing <Video: <6473811426107460878, ๐Ÿ˜>> ...
0%|                                                      | 0/10 [00:00<?, ?it/s]
Processing 1-10 of files
Processing <Video: <6616517521098935565, ็œŸ้ฆ™#panama>> ...
Saving <Video: <6616517521098935565, ็œŸ้ฆ™#panama>> to mongodb...
Processing <Video: <6500385230921141518, ๅ“ˆๅ“ˆๅ“ˆๅ“ˆๅ“ˆ>> ...
Saving <Video: <6500385230921141518, ๅ“ˆๅ“ˆๅ“ˆๅ“ˆๅ“ˆ>> to mongodb...
Processing <Video: <6562690160868199693, ็š‡ๅŸŽ็›ธๅบœ็‰ˆCๅ“ฉCๅ“ฉ่ทจ>> ...
....
Downloading <Video: <6580510322468064526, ็ฌฌไบŒ้ ๅŽ้ข็š„ๅฐๅ“ฅๅ“ฅ>> ...
Saved <Video: <6479958542747962637, ๐Ÿ‘…เธเนˆเธญเธ™เธเธดเธ™เธ‚เน‰>> to mongodb successfully
Downloading <Video: <6479958542747962637, ๐Ÿ‘…เธเนˆเธญเธ™เธเธดเธ™เธ‚เน‰>> ...
Saved <Video: <6473811426107460878, ๐Ÿ˜>> to mongodb successfully
Downloading <Video: <6473811426107460878, ๐Ÿ˜>> ...
Downloaded file to ./videos/6580510322468064526.mp4
10%|โ–ˆโ–ˆโ–ˆโ–ˆโ–Œ                                         | 1/10 [00:01<00:16,  1.84s/it]
Downloaded file to ./videos/6516746291806997763.mp4
20%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–                                    | 2/10 [00:01<00:10,  1.33s/it]
Downloaded file to ./videos/6600742831352974596.mp4
40%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–                           | 4/10 [00:02<00:05,  1.03it/s]
Downloaded file to ./videos/6484393014599879950.mp4
50%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ                       | 5/10 [00:02<00:04,  1.15it/s]
Downloaded file to ./videos/6616517521098935565.mp4
60%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–Œ                  | 6/10 [00:03<00:03,  1.27it/s]
Downloaded file to ./videos/6479958542747962637.mp4
70%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–             | 7/10 [00:03<00:01,  1.68it/s]
Downloaded file to ./videos/6472305134377372941.mp4
80%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–Š         | 8/10 [00:03<00:00,  2.05it/s]
Downloaded file to ./videos/6562690160868199693.mp4
90%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–    | 9/10 [00:04<00:00,  2.27it/s]
Downloaded file to ./videos/6500385230921141518.mp4
100%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 10/10 [00:04<00:00,  2.33it/s]

Examples

See examples