Code Monkey home page Code Monkey logo

douyin's Introduction

注:项目已不可用...

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

douyin's People

Contributors

germey avatar hacksman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

douyin's Issues

Exception ??

Exception <class 'requests.exceptions.ConnectionError'> occurred, retrying...

视频下载数,不是10的倍数,就不会下载?

downloader.download(item.videos(max=2))

# downloaders/base.py
        if isinstance(inputs, types.GeneratorType):
            temps = []
            for result in inputs:
                print('Processing', result, '...')
                temps.append(result)
                if len(temps) == self.batch:
                    self.process_items(temps)
                    temps = []

Python 3.7.2 has issue of "Exception <class 'requests.exceptions.ConnectionError'> occurred, retrying..."?

Python 3.7.2 has issue of "Exception <class 'requests.exceptions.ConnectionError'> occurred, retrying..."?

D:\Program Files (x86)\Python\Python37-32\apps\DouYin-master\examples>python save_hot_videos_and_musics_to_file.py
Exception <class 'requests.exceptions.ConnectionError'> occurred, retrying...
Exception <class 'requests.exceptions.ConnectionError'> occurred, retrying...
Exception <class 'requests.exceptions.ConnectionError'> occurred, retrying...
Exception <class 'requests.exceptions.ConnectionError'> occurred, retrying...
Exception <class 'requests.exceptions.ConnectionError'> occurred, retrying...
Exception <class 'requests.exceptions.ConnectionError'> occurred, retrying...
Exception <class 'requests.exceptions.ConnectionError'> occurred, retrying...
Exception <class 'requests.exceptions.ConnectionError'> occurred, retrying...
Exception <class 'requests.exceptions.ConnectionError'> occurred, retrying...
Exception <class 'requests.exceptions.ConnectionError'> occurred, retrying...
0it [00:00, ?it/s]
Exception <class 'requests.exceptions.ConnectionError'> occurred, retrying...
Exception <class 'requests.exceptions.ConnectionError'> occurred, retrying...
Exception <class 'requests.exceptions.ConnectionError'> occurred, retrying...
Exception <class 'requests.exceptions.ConnectionError'> occurred, retrying...

uid

如果只知道一个人的uid,怎么自动化的把她所有的视频都爬下来,谢谢

import douyin报错

import douyin
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2881, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "", line 1, in
import douyin
File "C:\Program Files\JetBrains\PyCharm Community Edition 181.3986.3\helpers\pydev_pydev_bundle\pydev_import_hook.py", line 20, in do_import
module = self.system_import(name, *args, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\douyin_init
.py", line 2, in
import douyin.handlers
File "C:\Program Files\JetBrains\PyCharm Community Edition 181.3986.3\helpers\pydev_pydev_bundle\pydev_import_hook.py", line 20, in do_import
module = self.system_import(name, *args, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\douyin\handlers_init
.py", line 2, in
from douyin.handlers.file import FileHandler
File "C:\Program Files\JetBrains\PyCharm Community Edition 181.3986.3\helpers\pydev_pydev_bundle\pydev_import_hook.py", line 20, in do_import
module = self._system_import(name, *args, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\douyin\handlers\file.py", line 5, in
import aiohttp
File "C:\Program Files\JetBrains\PyCharm Community Edition 181.3986.3\helpers\pydev_pydev_bundle\pydev_import_hook.py", line 20, in do_import
module = self.system_import(name, *args, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\aiohttp_init
.py", line 6, in
from .client import * # noqa
File "C:\Program Files\JetBrains\PyCharm Community Edition 181.3986.3\helpers\pydev_pydev_bundle\pydev_import_hook.py", line 20, in do_import
module = self._system_import(name, *args, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\aiohttp\client.py", line 18, in
from . import client_exceptions, client_reqrep
File "C:\Program Files\JetBrains\PyCharm Community Edition 181.3986.3\helpers\pydev_pydev_bundle\pydev_import_hook.py", line 20, in do_import
module = self._system_import(name, *args, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\aiohttp\client_reqrep.py", line 17, in
from . import hdrs, helpers, http, multipart, payload
File "C:\Program Files\JetBrains\PyCharm Community Edition 181.3986.3\helpers\pydev_pydev_bundle\pydev_import_hook.py", line 20, in do_import
module = self._system_import(name, *args, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\aiohttp\helpers.py", line 166, in
@attr.s(frozen=True, slots=True)
TypeError: attributes() got an unexpected keyword argument 'frozen'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.