you-get/src/you_get/extractors/w56.py

43 lines
1.4 KiB
Python
Raw Normal View History

2012-09-01 21:44:06 +04:00
#!/usr/bin/env python
__all__ = ['w56_download', 'w56_download_by_id']
from ..common import *
2016-02-10 04:26:43 +03:00
from .sohu import sohu_download
2012-09-01 21:44:06 +04:00
import json
def w56_download_by_id(id, title = None, output_dir = '.', merge = True, info_only = False):
2016-02-10 04:26:43 +03:00
content = json.loads(get_html('http://vxml.56.com/json/%s/?src=site' % id))
info = content['info']
2012-09-01 21:44:06 +04:00
title = title or info['Subject']
assert title
hd = info['hd']
assert hd in (0, 1, 2)
hd_types = [['normal', 'qvga'], ['clear', 'vga'], ['super', 'wvga']][hd]
2015-10-21 06:13:53 +03:00
files = [x for x in info['rfiles'] if x['type'] in hd_types]
2012-09-01 21:44:06 +04:00
assert len(files) == 1
size = int(files[0]['filesize'])
2015-12-31 10:06:30 +03:00
url = files[0]['url'] + '&prod=56'
2015-10-21 06:13:53 +03:00
ext = 'mp4'
2012-09-01 21:44:06 +04:00
print_info(site_info, title, ext, size)
if not info_only:
download_urls([url], title, ext, size, output_dir = output_dir, merge = merge)
def w56_download(url, output_dir = '.', merge = True, info_only = False, **kwargs):
2016-02-10 04:26:43 +03:00
content = get_content(url)
sohu_url = r1(r"url:\s*'([^']*)'", content)
if sohu_url:
sohu_download(sohu_url, output_dir, merge=merge, info_only=info_only, **kwargs)
return
2015-10-21 06:13:53 +03:00
id = r1(r'http://www.56.com/u\d+/v_(\w+).html', url) or \
r1(r'http://www.56.com/.*vid-(\w+).html', url)
2012-09-01 21:44:06 +04:00
w56_download_by_id(id, output_dir = output_dir, merge = merge, info_only = info_only)
site_info = "56.com"
download = w56_download
download_playlist = playlist_not_supported('56')