]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/instagram.py
Update changelog.
[youtubedl] / youtube_dl / extractor / instagram.py
1 from __future__ import unicode_literals
2
3 import re
4
5 from .common import InfoExtractor
6
7
8 class InstagramIE(InfoExtractor):
9 _VALID_URL = r'http://instagram\.com/p/(?P<id>.*?)/'
10 _TEST = {
11 'url': 'http://instagram.com/p/aye83DjauH/?foo=bar#abc',
12 'md5': '0d2da106a9d2631273e192b372806516',
13 'info_dict': {
14 'id': 'aye83DjauH',
15 'ext': 'mp4',
16 'uploader_id': 'naomipq',
17 'title': 'Video by naomipq',
18 'description': 'md5:1f17f0ab29bd6fe2bfad705f58de3cb8',
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 uploader_id = self._search_regex(r'"owner":{"username":"(.+?)"',
27 webpage, 'uploader id', fatal=False)
28 desc = self._search_regex(r'"caption":"(.*?)"', webpage, 'description',
29 fatal=False)
30
31 return {
32 'id': video_id,
33 'url': self._og_search_video_url(webpage, secure=False),
34 'ext': 'mp4',
35 'title': 'Video by %s' % uploader_id,
36 'thumbnail': self._og_search_thumbnail(webpage),
37 'uploader_id': uploader_id,
38 'description': desc,
39 }