add douyin support

This commit is contained in:
iawia002 2017-12-15 17:21:34 +08:00
parent 3032ec9679
commit 4ce28ac2b5
5 changed files with 48 additions and 0 deletions

View File

@ -414,6 +414,7 @@ Use `--url`/`-u` to get a list of downloadable resource URLs extracted from the
| 全民直播 | <http://www.quanmin.tv/> |✓| | |
| 阳光宽频网 | <http://www.365yg.com/> |✓| | |
| 西瓜视频 | <https://www.ixigua.com/> |✓| | |
| 抖音 | <https://www.douyin.com/> |✓| | |
For all other sites not on the list, the universal extractor will take care of finding and downloading interesting resources from the page.

View File

@ -38,6 +38,7 @@ SITES = {
'dailymotion' : 'dailymotion',
'dilidili' : 'dilidili',
'douban' : 'douban',
'douyin' : 'douyin',
'douyu' : 'douyutv',
'ehow' : 'ehow',
'facebook' : 'facebook',

View File

@ -15,6 +15,7 @@ from .coub import *
from .dailymotion import *
from .dilidili import *
from .douban import *
from .douyin import *
from .douyutv import *
from .ehow import *
from .facebook import *

View File

@ -0,0 +1,38 @@
# coding=utf-8
import re
import json
from ..common import (
url_size,
print_info,
get_content,
download_urls,
playlist_not_supported,
)
__all__ = ['douyin_download_by_url']
def douyin_download_by_url(url, **kwargs):
page_content = get_content(url)
match_rule = re.compile(r'var data = \[(.*?)\];')
video_info = json.loads(match_rule.findall(page_content)[0])
video_url = video_info['video']['play_addr']['url_list'][0]
title = video_info['cha_list'][0]['cha_name']
video_format = 'mp4'
size = url_size(video_url)
print_info(
site_info='douyin.com', title=title,
type=video_format, size=size
)
if not kwargs['info_only']:
download_urls(
urls=[video_url], title=title, ext=video_format, total_size=size,
**kwargs
)
download = douyin_download_by_url
download_playlist = playlist_not_supported('douyin')

View File

@ -8,6 +8,7 @@ from you_get.extractors import (
youtube,
yixia,
bilibili,
douyin,
)
@ -46,6 +47,12 @@ class YouGetTests(unittest.TestCase):
'https://www.bilibili.com/video/av13228063/', info_only=True
)
def test_douyin(self):
douyin.download(
'https://www.douyin.com/share/video/6492273288897629454',
info_only=True
)
if __name__ == '__main__':
unittest.main()