]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/instagram.py
Prepare for upload.
[youtubedl] / youtube_dl / extractor / instagram.py
1 import re
2
3 from .common import InfoExtractor
4
5 class InstagramIE(InfoExtractor):
6 _VALID_URL = r'(?:http://)?instagram.com/p/(.*?)/'
7 _TEST = {
8 u'url': u'http://instagram.com/p/aye83DjauH/?foo=bar#abc',
9 u'file': u'aye83DjauH.mp4',
10 u'md5': u'0d2da106a9d2631273e192b372806516',
11 u'info_dict': {
12 u"uploader_id": u"naomipq",
13 u"title": u"Video by naomipq",
14 u'description': u'md5:1f17f0ab29bd6fe2bfad705f58de3cb8',
15 }
16 }
17
18 def _real_extract(self, url):
19 mobj = re.match(self._VALID_URL, url)
20 video_id = mobj.group(1)
21 webpage = self._download_webpage(url, video_id)
22 uploader_id = self._search_regex(r'"owner":{"username":"(.+?)"',
23 webpage, u'uploader id', fatal=False)
24 desc = self._search_regex(r'"caption":"(.*?)"', webpage, u'description',
25 fatal=False)
26
27 return [{
28 'id': video_id,
29 'url': self._og_search_video_url(webpage),
30 'ext': 'mp4',
31 'title': u'Video by %s' % uploader_id,
32 'thumbnail': self._og_search_thumbnail(webpage),
33 'uploader_id' : uploader_id,
34 'description': desc,
35 }]