]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/instagram.py
b020e2621a5cc3c8d7ef6a1bc2cb6aaea989f779
1 from __future__
import unicode_literals
5 from .common
import InfoExtractor
11 class InstagramIE(InfoExtractor
):
12 _VALID_URL
= r
'http://instagram\.com/p/(?P<id>.*?)/'
14 'url': 'http://instagram.com/p/aye83DjauH/?foo=bar#abc',
15 'md5': '0d2da106a9d2631273e192b372806516',
19 'uploader_id': 'naomipq',
20 'title': 'Video by naomipq',
21 'description': 'md5:1f17f0ab29bd6fe2bfad705f58de3cb8',
25 def _real_extract(self
, url
):
26 mobj
= re
.match(self
._VALID
_URL
, url
)
27 video_id
= mobj
.group('id')
28 webpage
= self
._download
_webpage
(url
, video_id
)
29 uploader_id
= self
._search
_regex
(r
'"owner":{"username":"(.+?)"',
30 webpage
, 'uploader id', fatal
=False)
31 desc
= self
._search
_regex
(r
'"caption":"(.*?)"', webpage
, 'description',
36 'url': self
._og
_search
_video
_url
(webpage
, secure
=False),
38 'title': 'Video by %s' % uploader_id
,
39 'thumbnail': self
._og
_search
_thumbnail
(webpage
),
40 'uploader_id': uploader_id
,
45 class InstagramUserIE(InfoExtractor
):
46 _VALID_URL
= r
'http://instagram\.com/(?P<username>[^/]{2,})/?(?:$|[?#])'
47 IE_DESC
= 'Instagram user profile'
48 IE_NAME
= 'instagram:user'
50 'url': 'http://instagram.com/porsche',
55 'playlist_mincount': 2,
58 'id': '614605558512799803_462752227',
60 'title': '#Porsche Intelligent Performance.',
61 'thumbnail': 're:^https?://.*\.jpg',
62 'uploader': 'Porsche',
63 'uploader_id': 'porsche',
64 'timestamp': 1387486713,
65 'upload_date': '20131219',
70 'skip_download': True,
74 def _real_extract(self
, url
):
75 mobj
= re
.match(self
._VALID
_URL
, url
)
76 uploader_id
= mobj
.group('username')
80 media_url
= 'http://instagram.com/%s/media' % uploader_id
82 page
= self
._download
_json
(
83 media_url
, uploader_id
,
84 note
='Downloading page %d ' % (page_count
+ 1),
88 for it
in page
['items']:
89 if it
.get('type') != 'video':
91 like_count
= int_or_none(it
.get('likes', {}).get('count'))
92 user
= it
.get('user', {})
96 'height': v
.get('height'),
97 'width': v
.get('width'),
99 } for k
, v
in it
['videos'].items()]
100 self
._sort
_formats
(formats
)
102 thumbnails_el
= it
.get('images', {})
103 thumbnail
= thumbnails_el
.get('thumbnail', {}).get('url')
105 title
= it
.get('caption', {}).get('text', it
['id'])
111 'thumbnail': thumbnail
,
112 'webpage_url': it
.get('link'),
113 'uploader': user
.get('full_name'),
114 'uploader_id': user
.get('username'),
115 'like_count': like_count
,
116 'timestamp': int_or_none(it
.get('created_time')),
119 if not page
['items']:
121 max_id
= page
['items'][-1]['id']
123 'http://instagram.com/%s/media?max_id=%s' % (
124 uploader_id
, max_id
))
130 'title': uploader_id
,