]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/iconosquare.py
a39f422e985bf4c97ac63b28418317d7288c85ca
1 from __future__
import unicode_literals
3 from .common
import InfoExtractor
11 class IconosquareIE(InfoExtractor
):
12 _VALID_URL
= r
'https?://(?:www\.)?(?:iconosquare\.com|statigr\.am)/p/(?P<id>[^/]+)'
14 'url': 'http://statigr.am/p/522207370455279102_24101272',
15 'md5': '6eb93b882a3ded7c378ee1d6884b1814',
17 'id': '522207370455279102_24101272',
19 'title': 'Instagram photo by @aguynamedpatrick (Patrick Janelle)',
20 'description': 'md5:644406a9ec27457ed7aa7a9ebcd4ce3d',
21 'timestamp': 1376471991,
22 'upload_date': '20130814',
23 'uploader': 'aguynamedpatrick',
24 'uploader_id': '24101272',
30 def _real_extract(self
, url
):
31 video_id
= self
._match
_id
(url
)
33 webpage
= self
._download
_webpage
(url
, video_id
)
35 media
= self
._parse
_json
(
36 get_element_by_id('mediaJson', webpage
),
41 'format_id': format_id
,
42 'width': int_or_none(f
.get('width')),
43 'height': int_or_none(f
.get('height'))
44 } for format_id
, f
in media
['videos'].items()]
45 self
._sort
_formats
(formats
)
47 title
= remove_end(self
._og
_search
_title
(webpage
), ' - via Iconosquare')
49 timestamp
= int_or_none(media
.get('created_time') or media
.get('caption', {}).get('created_time'))
50 description
= media
.get('caption', {}).get('text')
52 uploader
= media
.get('user', {}).get('username')
53 uploader_id
= media
.get('user', {}).get('id')
55 comment_count
= int_or_none(media
.get('comments', {}).get('count'))
56 like_count
= int_or_none(media
.get('likes', {}).get('count'))
61 'width': int_or_none(t
.get('width')),
62 'height': int_or_none(t
.get('height'))
63 } for thumbnail_id
, t
in media
.get('images', {}).items()]
66 'id': comment
.get('id'),
67 'text': comment
['text'],
68 'timestamp': int_or_none(comment
.get('created_time')),
69 'author': comment
.get('from', {}).get('full_name'),
70 'author_id': comment
.get('from', {}).get('username'),
71 } for comment
in media
.get('comments', {}).get('data', []) if 'text' in comment
]
76 'description': description
,
77 'thumbnails': thumbnails
,
78 'timestamp': timestamp
,
80 'uploader_id': uploader_id
,
81 'comment_count': comment_count
,
82 'like_count': like_count
,