Sohu: Fix vid get error

This commit is contained in:
Fwolf 2013-09-17 21:42:46 +08:00
parent 5a92ae53c4
commit 7da3cb3b94

View File

@ -12,7 +12,10 @@ def real_url(host, prot, file, new):
return '%s%s?key=%s' % (start[:-1], new, key) return '%s%s?key=%s' % (start[:-1], new, key)
def sohu_download(url, output_dir = '.', merge = True, info_only = False): def sohu_download(url, output_dir = '.', merge = True, info_only = False):
vid = r1('vid\s*=\s*"(\d+)"', get_html(url)) html = get_html(url)
vid = r1('vid\s*=\s*"(\d+)"', html)
if not vid:
vid = r1('vid\s*:\s*"(\d+)"', html)
if vid: if vid:
data = json.loads(get_decoded_html('http://hot.vrs.sohu.com/vrs_flash.action?vid=%s' % vid)) data = json.loads(get_decoded_html('http://hot.vrs.sohu.com/vrs_flash.action?vid=%s' % vid))
@ -33,6 +36,7 @@ def sohu_download(url, output_dir = '.', merge = True, info_only = False):
assert data['clipsURL'][0].endswith('.mp4') assert data['clipsURL'][0].endswith('.mp4')
else: else:
# my.tv link doesn't include clip info anymore, below block is useless
vid = r1('vid\s*=\s*\'(\d+)\'', get_html(url)) vid = r1('vid\s*=\s*\'(\d+)\'', get_html(url))
data = json.loads(get_decoded_html('http://my.tv.sohu.com/videinfo.jhtml?m=viewnew&vid=%s' % vid)) data = json.loads(get_decoded_html('http://my.tv.sohu.com/videinfo.jhtml?m=viewnew&vid=%s' % vid))
host = data['allot'] host = data['allot']