2012-08-31 19:20:38 +04:00
|
|
|
#!/usr/bin/env python
|
2012-08-20 19:54:03 +04:00
|
|
|
|
|
|
|
__all__ = ['yinyuetai_download', 'yinyuetai_download_by_id']
|
|
|
|
|
2012-08-31 19:20:38 +04:00
|
|
|
from ..common import *
|
2012-08-20 19:54:03 +04:00
|
|
|
|
2015-09-03 20:54:07 +03:00
|
|
|
def yinyuetai_download_by_id(vid, title=None, output_dir='.', merge=True, info_only=False):
|
|
|
|
video_info = json.loads(get_html('http://www.yinyuetai.com/insite/get-video-info?json=true&videoId=%s' % vid))
|
|
|
|
url_models = video_info['videoInfo']['coreVideoInfo']['videoUrlModels']
|
|
|
|
url_models = sorted(url_models, key=lambda i: i['qualityLevel'])
|
|
|
|
url = url_models[-1]['videoUrl']
|
2014-09-06 05:29:52 +04:00
|
|
|
type = ext = r1(r'\.(flv|mp4)', url)
|
|
|
|
_, _, size = url_info(url)
|
|
|
|
|
2012-08-20 19:54:03 +04:00
|
|
|
print_info(site_info, title, type, size)
|
|
|
|
if not info_only:
|
|
|
|
download_urls([url], title, ext, size, output_dir, merge = merge)
|
|
|
|
|
2015-09-26 08:45:39 +03:00
|
|
|
def yinyuetai_download(url, output_dir='.', merge=True, info_only=False, **kwargs):
|
2015-10-18 04:58:25 +03:00
|
|
|
playlist = r1(r'http://\w+.yinyuetai.com/playlist/(\d+)', url)
|
|
|
|
if playlist:
|
|
|
|
html = get_html(url)
|
|
|
|
data_ids = re.findall(r'data-index="\d+"\s*data-id=(\d+)', html)
|
|
|
|
for data_id in data_ids:
|
|
|
|
yinyuetai_download('http://v.yinyuetai.com/video/' + data_id,
|
|
|
|
output_dir=output_dir, merge=merge, info_only=info_only)
|
|
|
|
return
|
|
|
|
|
|
|
|
id = r1(r'http://\w+.yinyuetai.com/video/(\d+)', url)
|
2012-08-20 19:54:03 +04:00
|
|
|
html = get_html(url, 'utf-8')
|
2015-10-18 04:25:40 +03:00
|
|
|
title = r1(r'<meta property="og:title"\s+content="([^"]+)"/>', html) or r1(r'<title>(.*)', html)
|
2012-08-20 19:54:03 +04:00
|
|
|
assert title
|
|
|
|
title = parse.unquote(title)
|
|
|
|
title = escape_file_path(title)
|
2015-10-18 04:58:25 +03:00
|
|
|
yinyuetai_download_by_id(id, title, output_dir, merge=merge, info_only=info_only)
|
2012-08-20 19:54:03 +04:00
|
|
|
|
|
|
|
site_info = "YinYueTai.com"
|
|
|
|
download = yinyuetai_download
|
|
|
|
download_playlist = playlist_not_supported('yinyuetai')
|