Skip to main content

Api of douyin for humans

Project description


# DouYin

API of DouYin App for humans.

## Installation

```
pip3 install douyin
```

## Usage

Here is the sample code:

```python
import douyin
from douyin.structures import Topic, Music

# define file handler and specify folder
file_handler = douyin.handlers.FileHandler(folder='./videos')
# define mongodb handler
mongo_handler = douyin.handlers.MongoHandler()
# define downloader
downloader = douyin.downloaders.VideoDownloader([mongo_handler, file_handler])

for result in douyin.hot.trend():
for item in result.data:
# download videos of topic/music for 200 max per
if isinstance(item, Topic):
print('Item', item)
downloader.download(item.videos(max=100))
if isinstance(item, Music):
print('Item', item)
downloader.download(item.videos(max=30))
```

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]
```

![](https://ws2.sinaimg.cn/large/006tNbRwgy1fwmad1yh6wj30lf0p3aaf.jpg)

## Examples

See [examples](./examples)


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

douyin-0.3.4.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

douyin-0.3.4-py2.py3-none-any.whl (22.9 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file douyin-0.3.4.tar.gz.

File metadata

  • Download URL: douyin-0.3.4.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.17.1 CPython/3.6.1

File hashes

Hashes for douyin-0.3.4.tar.gz
Algorithm Hash digest
SHA256 8c068dbbe3da8530024e8fe9d90a184e37f1accc4b8b4712d6f96acdd7bf92e5
MD5 fac98f00bdd997b5f506979401c7ffd6
BLAKE2b-256 e859a677f7f3b67842cdc4ac705bbc8674935f63237b6db143e568a22b42abc4

See more details on using hashes here.

File details

Details for the file douyin-0.3.4-py2.py3-none-any.whl.

File metadata

  • Download URL: douyin-0.3.4-py2.py3-none-any.whl
  • Upload date:
  • Size: 22.9 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.17.1 CPython/3.6.1

File hashes

Hashes for douyin-0.3.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 565f2f0f2172303584351729a4204fb6e663d6d8667b880b32472fa5fd042553
MD5 4821d92a6432d0548db6b8df9f71015e
BLAKE2b-256 0e4ccc83c2c83f4ad7cda8f1ffb6780c450dba9bf423b91676c7a8dc1f8a9ad2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page