1 from __future__ import unicode_literals
5 from .common import InfoExtractor
11 class TumblrIE(InfoExtractor):
12 _VALID_URL = r'http://(?P<blog_name>.*?)\.tumblr\.com/((post)|(video))/(?P<id>\d*)($|/)'
14 'url': 'http://tatianamaslanydaily.tumblr.com/post/54196191430/orphan-black-dvd-extra-behind-the-scenes',
15 'md5': '479bb068e5b16462f5176a6828829767',
19 'title': 'tatiana maslany news, Orphan Black || DVD extra - behind the scenes ↳...',
20 'description': 'md5:dfac39636969fe6bf1caa2d50405f069',
21 'thumbnail': 're:http://.*\.jpg',
24 'url': 'http://5sostrum.tumblr.com/post/90208453769/yall-forgetting-the-greatest-keek-of-them-all',
25 'md5': 'bf348ef8c0ef84fbf1cbd6fa6e000359',
29 'title': '5SOS STRUM ;)',
30 'description': 'md5:dba62ac8639482759c8eb10ce474586a',
31 'thumbnail': 're:http://.*\.jpg',
35 def _real_extract(self, url):
36 m_url = re.match(self._VALID_URL, url)
37 video_id = m_url.group('id')
38 blog = m_url.group('blog_name')
40 url = 'http://%s.tumblr.com/post/%s/' % (blog, video_id)
41 webpage = self._download_webpage(url, video_id)
43 re_video = r'src=\\x22(?P<video_url>http://%s\.tumblr\.com/video_file/%s/(.*?))\\x22 type=\\x22video/(?P<ext>.*?)\\x22' % (blog, video_id)
44 video = re.search(re_video, webpage)
46 raise ExtractorError('Unable to extract video')
47 video_url = video.group('video_url')
48 ext = video.group('ext')
50 video_thumbnail = self._search_regex(
51 r'posters.*?\[\\x22(.*?)\\x22',
52 webpage, 'thumbnail', fatal=False) # We pick the first poster
54 video_thumbnail = video_thumbnail.replace('\\\\/', '/')
56 # The only place where you can get a title, it's not complete,
57 # but searching in other places doesn't work for all videos
58 video_title = self._html_search_regex(r'<title>(?P<title>.*?)(?: \| Tumblr)?</title>',
59 webpage, 'title', flags=re.DOTALL)
61 return [{'id': video_id,
64 'description': self._html_search_meta('description', webpage),
65 'thumbnail': video_thumbnail,