This commit is contained in:
Mort Yao 2012-12-01 16:58:58 +01:00
parent f739bfa314
commit b89618d61d

View File

@ -13,7 +13,7 @@ def cntv_download_by_id(id, title = None, output_dir = '.', merge = True, info_o
title = title or info['title'] title = title or info['title']
video = info['video'] video = info['video']
alternatives = [x for x in video.keys() if x.startswith('chapters')] alternatives = [x for x in video.keys() if x.startswith('chapters')]
assert alternatives in (['chapters'], ['chapters', 'chapters2']), alternatives #assert alternatives in (['chapters'], ['chapters', 'chapters2']), alternatives
chapters = video['chapters2'] if 'chapters2' in video else video['chapters'] chapters = video['chapters2'] if 'chapters2' in video else video['chapters']
urls = [x['url'] for x in chapters] urls = [x['url'] for x in chapters]
ext = r1(r'\.([^.]+)$', urls[0]) ext = r1(r'\.([^.]+)$', urls[0])
@ -28,7 +28,7 @@ def cntv_download_by_id(id, title = None, output_dir = '.', merge = True, info_o
download_urls(urls, title, ext, size, output_dir = output_dir, merge = merge) download_urls(urls, title, ext, size, output_dir = output_dir, merge = merge)
def cntv_download(url, output_dir = '.', merge = True, info_only = False): 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): 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)) 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): elif re.match(r'http://xiyou.cntv.cn/v-[\w-]+\.html', url):
id = r1(r'http://xiyou.cntv.cn/v-([\w-]+)\.html', url) id = r1(r'http://xiyou.cntv.cn/v-([\w-]+)\.html', url)