mirror of
https://github.com/soimort/you-get.git
synced 2025-01-23 13:35:16 +03:00
add support for CNTV
This commit is contained in:
parent
c2d103ac5b
commit
086bd6db9f
@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
from .cntv import *
|
||||
from .ku6 import *
|
||||
from .sohu import *
|
||||
from .tudou import *
|
||||
|
42
you_get/downloader/cntv.py
Normal file
42
you_get/downloader/cntv.py
Normal file
@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
__all__ = ['cntv_download', 'cntv_download_by_id']
|
||||
|
||||
from ..common import *
|
||||
|
||||
import json
|
||||
import re
|
||||
|
||||
def cntv_download_by_id(id, title = None, output_dir = '.', merge = True, info_only = False):
|
||||
assert id
|
||||
info = json.loads(get_html('http://vdn.apps.cntv.cn/api/getHttpVideoInfo.do?pid=' + id))
|
||||
title = title or info['title']
|
||||
video = info['video']
|
||||
alternatives = [x for x in video.keys() if x.startswith('chapters')]
|
||||
assert alternatives in (['chapters'], ['chapters', 'chapters2']), alternatives
|
||||
chapters = video['chapters2'] if 'chapters2' in video else video['chapters']
|
||||
urls = [x['url'] for x in chapters]
|
||||
ext = r1(r'\.([^.]+)$', urls[0])
|
||||
assert ext in ('flv', 'mp4')
|
||||
size = 0
|
||||
for url in urls:
|
||||
_, _, temp = url_info(url)
|
||||
size += temp
|
||||
|
||||
print_info(site_info, title, ext, size)
|
||||
if not info_only:
|
||||
download_urls(urls, title, ext, size, output_dir = output_dir, merge = merge)
|
||||
|
||||
def cntv_download(url, output_dir = '.', merge = True, info_only = False):
|
||||
if re.match(r'http://\w+\.cntv\.cn/(\w+/\w+/classpage/video/)?\d+/\d+\.shtml', url):
|
||||
id = r1(r'<!--repaste.video.code.begin-->(\w+)<!--repaste.video.code.end-->', get_html(url))
|
||||
elif re.match(r'http://xiyou.cntv.cn/v-[\w-]+\.html', url):
|
||||
id = r1(r'http://xiyou.cntv.cn/v-([\w-]+)\.html', url)
|
||||
else:
|
||||
raise NotImplementedError(url)
|
||||
|
||||
cntv_download_by_id(id, output_dir = output_dir, merge = merge, info_only = info_only)
|
||||
|
||||
site_info = "CNTV.com"
|
||||
download = cntv_download
|
||||
download_playlist = playlist_not_supported('cntv')
|
@ -16,6 +16,7 @@ def url_to_module(url):
|
||||
|
||||
k = r1(r'([^.]+)', domain)
|
||||
downloads = {
|
||||
'cntv': cntv,
|
||||
'ku6': ku6,
|
||||
'sohu': sohu,
|
||||
'tudou': tudou,
|
||||
@ -31,7 +32,6 @@ def url_to_module(url):
|
||||
# 'pptv': pptv,
|
||||
# 'iqiyi': iqiyi,
|
||||
# '56': w56,
|
||||
# 'cntv': cntv,
|
||||
}
|
||||
if k in downloads:
|
||||
return downloads[k]
|
||||
|
Loading…
Reference in New Issue
Block a user