From 9a87f83c7060b66f7f95f2823db11b5e86a4fd67 Mon Sep 17 00:00:00 2001 From: Mort Yao Date: Fri, 19 Jul 2013 00:14:05 +0800 Subject: [PATCH] Dailymotion: fix #210 --- src/you_get/downloader/dailymotion.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/you_get/downloader/dailymotion.py b/src/you_get/downloader/dailymotion.py index 5d42cbb9..99d586c8 100644 --- a/src/you_get/downloader/dailymotion.py +++ b/src/you_get/downloader/dailymotion.py @@ -5,16 +5,22 @@ __all__ = ['dailymotion_download'] from ..common import * def dailymotion_download(url, output_dir = '.', merge = True, info_only = False): - html = get_html(url) - html = parse.unquote(html).replace('\/', '/') + """Downloads Dailymotion videos by URL. + """ - title = r1(r'meta property="og:title" content="([^"]+)"', html) - title = escape_file_path(title) + id = match1(url, r'/video/([^\?]+)') + embed_url = 'http://www.dailymotion.com/embed/video/%s' % id + html = get_content(embed_url) - for quality in ['hd720URL', 'hqURL', 'sdURL']: - real_url = r1(r',\"' + quality + '\"\:\"([^\"]+?)\",', html) + info = json.loads(match1(html, r'var\s*info\s*=\s*({.+}),\n')) + + title = info['title'] + + for quality in ['stream_h264_hd1080_url', 'stream_h264_hd_url', 'stream_h264_hq_url', 'stream_h264_url', 'stream_h264_ld_url']: + real_url = info[quality] if real_url: break + type, ext, size = url_info(real_url) print_info(site_info, title, type, size)