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 'file': '54196191430.mp4',
16 'md5': '479bb068e5b16462f5176a6828829767',
18 "title": "tatiana maslany news"
22 def _real_extract(self, url):
23 m_url = re.match(self._VALID_URL, url)
24 video_id = m_url.group('id')
25 blog = m_url.group('blog_name')
27 url = 'http://%s.tumblr.com/post/%s/' % (blog, video_id)
28 webpage = self._download_webpage(url, video_id)
30 re_video = r'src=\\x22(?P<video_url>http://%s\.tumblr\.com/video_file/%s/(.*?))\\x22 type=\\x22video/(?P<ext>.*?)\\x22' % (blog, video_id)
31 video = re.search(re_video, webpage)
33 raise ExtractorError('Unable to extract video')
34 video_url = video.group('video_url')
35 ext = video.group('ext')
37 video_thumbnail = self._search_regex(
38 r'posters.*?\[\\x22(.*?)\\x22',
39 webpage, 'thumbnail', fatal=False) # We pick the first poster
41 video_thumbnail = video_thumbnail.replace('\\\\/', '/')
43 # The only place where you can get a title, it's not complete,
44 # but searching in other places doesn't work for all videos
45 video_title = self._html_search_regex(r'<title>(?P<title>.*?)(?: \| Tumblr)?</title>',
46 webpage, 'title', flags=re.DOTALL)
48 return [{'id': video_id,
51 'thumbnail': video_thumbnail,