]> git.bitcoin.ninja Git - youtube-dl/blob - youtube_dl/extractor/iconosquare.py
Merge branch 'ustream-embed-recorded2' of https://github.com/anovicecodemonkey/youtub...
[youtube-dl] / youtube_dl / extractor / iconosquare.py
1 from __future__ import unicode_literals
2
3 import re
4
5 from .common import InfoExtractor
6
7
8 class IconosquareIE(InfoExtractor):
9     _VALID_URL = r'https?://(www\.)?(?:iconosquare\.com|statigr\.am)/p/(?P<id>[^/]+)'
10     _TEST = {
11         'url': 'http://statigr.am/p/522207370455279102_24101272',
12         'md5': '6eb93b882a3ded7c378ee1d6884b1814',
13         'info_dict': {
14             'id': '522207370455279102_24101272',
15             'ext': 'mp4',
16             'uploader_id': 'aguynamedpatrick',
17             'title': 'Instagram photo by @aguynamedpatrick (Patrick Janelle)',
18             'description': 'md5:644406a9ec27457ed7aa7a9ebcd4ce3d',
19         },
20     }
21
22     def _real_extract(self, url):
23         mobj = re.match(self._VALID_URL, url)
24         video_id = mobj.group('id')
25         webpage = self._download_webpage(url, video_id)
26         html_title = self._html_search_regex(
27             r'<title>(.+?)</title>',
28             webpage, 'title')
29         title = re.sub(r'(?: *\(Videos?\))? \| (?:Iconosquare|Statigram)$', '', html_title)
30         uploader_id = self._html_search_regex(
31             r'@([^ ]+)', title, 'uploader name', fatal=False)
32
33         return {
34             'id': video_id,
35             'url': self._og_search_video_url(webpage),
36             'title': title,
37             'description': self._og_search_description(webpage),
38             'thumbnail': self._og_search_thumbnail(webpage),
39             'uploader_id': uploader_id
40         }