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

39 lines
1.1 KiB
Python
Raw Normal View History

2012-09-25 02:27:28 +04:00
#!/usr/bin/env python
__all__ = ['dailymotion_download']
from ..common import *
def extract_m3u(url):
content = get_content(url)
m3u_url = re.findall(r'http://.*', content)[0]
return match1(m3u_url, r'([^#]+)')
def dailymotion_download(url, output_dir = '.', merge = True, info_only = False, **kwargs):
2013-07-18 20:14:05 +04:00
"""Downloads Dailymotion videos by URL.
"""
2014-02-10 05:16:03 +04:00
2015-08-28 19:23:29 +03:00
html = get_content(url)
info = json.loads(match1(html, r'qualities":({.+?}),"'))
2015-12-16 17:39:21 +03:00
title = match1(html, r'"video_title"\s*:\s*"([^"]+)"') or \
match1(html, r'"title"\s*:\s*"([^"]+)"')
2014-02-10 05:16:03 +04:00
for quality in ['1080','720','480','380','240','auto']:
try:
real_url = info[quality][0]["url"]
if real_url:
break
except KeyError:
pass
2014-02-10 05:16:03 +04:00
m3u_url = extract_m3u(real_url)
mime, ext, size = 'video/mp4', 'mp4', 0
2014-02-10 05:16:03 +04:00
print_info(site_info, title, mime, size)
2012-09-25 02:27:28 +04:00
if not info_only:
download_url_ffmpeg(m3u_url, title, ext, output_dir=output_dir, merge=merge)
2012-09-25 02:27:28 +04:00
site_info = "Dailymotion.com"
download = dailymotion_download
download_playlist = playlist_not_supported('dailymotion')