]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/statigram.py
d602e817a076cbfbdfb5c50da8e3b1f23583b8d0
[youtubedl] / youtube_dl / extractor / statigram.py
1 from __future__ import unicode_literals
2
3 import re
4
5 from .common import InfoExtractor
6
7
8 class StatigramIE(InfoExtractor):
9 _VALID_URL = r'https?://(www\.)?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 },
19 }
20
21 def _real_extract(self, url):
22 mobj = re.match(self._VALID_URL, url)
23 video_id = mobj.group('id')
24 webpage = self._download_webpage(url, video_id)
25 html_title = self._html_search_regex(
26 r'<title>(.+?)</title>',
27 webpage, 'title')
28 title = re.sub(r'(?: *\(Videos?\))? \| Statigram$', '', html_title)
29 uploader_id = self._html_search_regex(
30 r'@([^ ]+)', title, 'uploader name', fatal=False)
31
32 return {
33 'id': video_id,
34 'url': self._og_search_video_url(webpage),
35 'title': title,
36 'thumbnail': self._og_search_thumbnail(webpage),
37 'uploader_id': uploader_id
38 }