From: Sergey M․ Date: Mon, 5 Oct 2015 15:53:01 +0000 (+0600) Subject: [tumblr] Simplify and extract duration X-Git-Url: http://git.oshgnacknak.de/?a=commitdiff_plain;h=140ac7396542d92a8ddd53be6c35c7a79db16180;p=youtube-dl [tumblr] Simplify and extract duration --- diff --git a/youtube_dl/extractor/tumblr.py b/youtube_dl/extractor/tumblr.py index 71cced562..449ba29fa 100644 --- a/youtube_dl/extractor/tumblr.py +++ b/youtube_dl/extractor/tumblr.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import re from .common import InfoExtractor +from ..utils import int_or_none class TumblrIE(InfoExtractor): @@ -83,8 +84,6 @@ class TumblrIE(InfoExtractor): video_id = m_url.group('id') blog = m_url.group('blog_name') - video_urls = [] - url = 'http://%s.tumblr.com/post/%s/' % (blog, video_id) webpage, urlh = self._download_webpage_handle(url, video_id) @@ -94,34 +93,38 @@ class TumblrIE(InfoExtractor): if iframe_url is None: return self.url_result(urlh.geturl(), 'Generic') - iframe = self._download_webpage(iframe_url, video_id, - 'Downloading iframe page') + iframe = self._download_webpage(iframe_url, video_id, 'Downloading iframe page') + + duration = None + sources = [] + + sd_url = self._search_regex( + r']+src=(["\'])(?P.+?)\1', iframe, + 'sd video url', default=None, group='url') + if sd_url: + sources.append((sd_url, 'sd')) + + options = self._parse_json( + self._search_regex( + r'data-crt-options=(["\'])(?P.+?)\1', iframe, + 'hd video url', default='', group='options'), + video_id, fatal=False) + if options: + duration = int_or_none(options.get('duration')) + hd_url = options.get('hdUrl') + if hd_url: + sources.append((hd_url, 'hd')) - sd_video_url = self._search_regex(r'