1 # -*- coding: utf-8 -*-
2 from __future__ import unicode_literals
6 from .common import InfoExtractor
7 from .pornhub import PornHubIE
8 from .vimeo import VimeoIE
11 class TumblrIE(InfoExtractor):
12 _VALID_URL = r'http://(?P<blog_name>.*?)\.tumblr\.com/(?:post|video)/(?P<id>[0-9]+)(?:$|[/?#])'
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:37db8211e40b50c7c44e95da14f630b7',
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',
34 'url': 'http://naked-yogi.tumblr.com/post/118312946248/naked-smoking-stretching',
35 'md5': 'de07e5211d60d4f3a2c3df757ea9f6ab',
39 'title': 'naked smoking & stretching',
40 'upload_date': '20150506',
41 'timestamp': 1430931613,
45 'url': 'http://camdamage.tumblr.com/post/98846056295/',
46 'md5': 'a9e0c8371ea1ca306d6554e3fecf50b6',
50 'title': 'Cam Damage-HD 720p',
51 'uploader': 'John Moyer',
52 'uploader_id': 'user32021558',
57 def _real_extract(self, url):
58 m_url = re.match(self._VALID_URL, url)
59 video_id = m_url.group('id')
60 blog = m_url.group('blog_name')
62 url = 'http://%s.tumblr.com/post/%s/' % (blog, video_id)
63 webpage = self._download_webpage(url, video_id)
65 vid_me_embed_url = self._search_regex(
66 r'src=[\'"](https?://vid\.me/[^\'"]+)[\'"]',
67 webpage, 'vid.me embed', default=None)
68 if vid_me_embed_url is not None:
69 return self.url_result(vid_me_embed_url, 'Vidme')
71 pornhub_url = PornHubIE._extract_url(webpage)
73 return self.url_result(pornhub_url, 'PornHub')
75 vimeo_url = VimeoIE._extract_vimeo_url(url, webpage)
77 return self.url_result(vimeo_url, 'Vimeo')
79 iframe_url = self._search_regex(
80 r'src=\'(https?://www\.tumblr\.com/video/[^\']+)\'',
81 webpage, 'iframe url')
82 iframe = self._download_webpage(iframe_url, video_id)
83 video_url = self._search_regex(r'<source src="([^"]+)"',
86 # The only place where you can get a title, it's not complete,
87 # but searching in other places doesn't work for all videos
88 video_title = self._html_search_regex(
89 r'(?s)<title>(?P<title>.*?)(?: \| Tumblr)?</title>',
97 'description': self._og_search_description(webpage, default=None),
98 'thumbnail': self._og_search_thumbnail(webpage, default=None),