A feature-rich command-line audio/video downloader
myvideo.de support
Philipp Hagemeister9b0a8bc1982a
diff --git a/youtube-dl b/youtube-dlindex 153d4132fa..f32716f1e1 100755--- a/youtube-dl+++ b/youtube-dl@@ -2954,6 +2954,82 @@ class BlipTVIE(InfoExtractor):self._downloader.trouble(u'\nERROR: unable to download video')+class MyVideoIE(InfoExtractor):+ """Information Extractor for myvideo.de."""++ _VALID_URL = r'(?:http://)?(?:www\.)?myvideo\.de/watch/([0-9]+)/([^?/]+).*'++ def __init__(self, downloader=None):+ InfoExtractor.__init__(self, downloader)++ @staticmethod+ def suitable(url):+ return (re.match(MyVideoIE._VALID_URL, url) is not None)++ def report_download_webpage(self, video_id):+ """Report webpage download."""+ self._downloader.to_screen(u'[myvideo] %s: Downloading webpage' % video_id)++ def report_extraction(self, video_id):+ """Report information extraction."""+ self._downloader.to_screen(u'[myvideo] %s: Extracting information' % video_id)++ def _real_initialize(self):+ return++ def _real_extract(self,url):+ mobj = re.match(self._VALID_URL, url)+ if mobj is None:+ self._download.trouble(u'ERROR: invalid URL: %s' % url)+ return++ video_id = mobj.group(1)+ simple_title = mobj.group(2).decode('utf-8')+ # should actually not be necessary+ simple_title = sanitize_title(simple_title)+ simple_title = re.sub(ur'(?u)([^%s]+)' % simple_title_chars, ur'_', simple_title)++ # Get video webpage+ request = urllib2.Request('http://www.myvideo.de/watch/%s' % video_id)+ try:+ self.report_download_webpage(video_id)+ webpage = urllib2.urlopen(request).read()+ except (urllib2.URLError, httplib.HTTPException, socket.error), err:+ self._downloader.trouble(u'ERROR: Unable to retrieve video webpage: %s' % str(err))+ return++ self.report_extraction(video_id)+ mobj = re.search(r'<link rel=\'image_src\' href=\'(http://is[0-9].myvideo\.de/de/movie[0-9]+/[a-f0-9]+)/thumbs/[^.]+\.jpg\' />',+ webpage)+ if mobj is None:+ self._downloader.trouble(u'ERROR: unable to extract media URL')+ return+ video_url = mobj.group(1) + ('/%s.flv' % video_id)++ mobj = re.search('<title>([^<]+)</title>', webpage)+ if mobj is None:+ self._downloader.trouble(u'ERROR: unable to extract title')+ return++ video_title = mobj.group(1)+ video_title = sanitize_title(video_title)++ try:+ print(video_url)+ self._downloader.process_info({+ 'id': video_id,+ 'url': video_url,+ 'uploader': u'NA',+ 'upload_date': u'NA',+ 'title': video_title,+ 'stitle': simple_title,+ 'ext': u'flv',+ 'format': u'NA',+ 'player_url': None,+ })+ except UnavailableVideoError:+ self._downloader.trouble(u'\nERROR: Unable to download video')+class PostProcessor(object):"""Post Processor class.@@ -3369,6 +3445,8 @@ def main():facebook_ie = FacebookIE()bliptv_ie = BlipTVIE()vimeo_ie = VimeoIE()+ myvideo_ie = MyVideoIE()+generic_ie = GenericIE()# File downloader@@ -3425,6 +3503,7 @@ def main():fd.add_info_extractor(facebook_ie)fd.add_info_extractor(bliptv_ie)fd.add_info_extractor(vimeo_ie)+ fd.add_info_extractor(myvideo_ie)# This must come last since it's the# fallback if none of the others work