]>
Commit | Line | Data |
---|---|---|
9b27e6c3 | 1 | # -*- coding: utf-8 -*- |
c060b774 PH |
2 | from __future__ import unicode_literals |
3 | ||
ae287755 PH |
4 | import re |
5 | ||
6 | from .common import InfoExtractor | |
ae287755 PH |
7 | |
8 | ||
9 | class TumblrIE(InfoExtractor): | |
3da0e1f8 | 10 | _VALID_URL = r'http://(?P<blog_name>.*?)\.tumblr\.com/(?:post|video)/(?P<id>[0-9]+)(?:$|[/?#])' |
62f1f950 | 11 | _TESTS = [{ |
c060b774 | 12 | 'url': 'http://tatianamaslanydaily.tumblr.com/post/54196191430/orphan-black-dvd-extra-behind-the-scenes', |
c060b774 PH |
13 | 'md5': '479bb068e5b16462f5176a6828829767', |
14 | 'info_dict': { | |
62f1f950 PP |
15 | 'id': '54196191430', |
16 | 'ext': 'mp4', | |
17 | 'title': 'tatiana maslany news, Orphan Black || DVD extra - behind the scenes ↳...', | |
681b9caa | 18 | 'description': 'md5:37db8211e40b50c7c44e95da14f630b7', |
62f1f950 | 19 | 'thumbnail': 're:http://.*\.jpg', |
6f5ac90c | 20 | } |
62f1f950 PP |
21 | }, { |
22 | 'url': 'http://5sostrum.tumblr.com/post/90208453769/yall-forgetting-the-greatest-keek-of-them-all', | |
23 | 'md5': 'bf348ef8c0ef84fbf1cbd6fa6e000359', | |
24 | 'info_dict': { | |
25 | 'id': '90208453769', | |
26 | 'ext': 'mp4', | |
681b9caa | 27 | 'title': '5SOS STRUM ;]', |
62f1f950 PP |
28 | 'description': 'md5:dba62ac8639482759c8eb10ce474586a', |
29 | 'thumbnail': 're:http://.*\.jpg', | |
30 | } | |
31 | }] | |
ae287755 PH |
32 | |
33 | def _real_extract(self, url): | |
34 | m_url = re.match(self._VALID_URL, url) | |
35 | video_id = m_url.group('id') | |
36 | blog = m_url.group('blog_name') | |
37 | ||
38 | url = 'http://%s.tumblr.com/post/%s/' % (blog, video_id) | |
39 | webpage = self._download_webpage(url, video_id) | |
40 | ||
681b9caa JMF |
41 | iframe_url = self._search_regex( |
42 | r'src=\'(https?://www\.tumblr\.com/video/[^\']+)\'', | |
43 | webpage, 'iframe url') | |
44 | iframe = self._download_webpage(iframe_url, video_id) | |
45 | video_url = self._search_regex(r'<source src="([^"]+)"', | |
9e1a5b84 | 46 | iframe, 'video url') |
ae287755 PH |
47 | |
48 | # The only place where you can get a title, it's not complete, | |
49 | # but searching in other places doesn't work for all videos | |
3da0e1f8 PH |
50 | video_title = self._html_search_regex( |
51 | r'(?s)<title>(?P<title>.*?)(?: \| Tumblr)?</title>', | |
52 | webpage, 'title') | |
ae287755 | 53 | |
3da0e1f8 PH |
54 | return { |
55 | 'id': video_id, | |
681b9caa JMF |
56 | 'url': video_url, |
57 | 'ext': 'mp4', | |
58 | 'title': video_title, | |
59 | 'description': self._og_search_description(webpage), | |
60 | 'thumbnail': self._og_search_thumbnail(webpage), | |
3da0e1f8 | 61 | } |