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