1 from __future__ import unicode_literals
3 from .common import InfoExtractor
4 from ..compat import compat_urllib_parse
11 class FlickrIE(InfoExtractor):
12 _VALID_URL = r'https?://(?:www\.|secure\.)?flickr\.com/photos/[\w\-_@]+/(?P<id>\d+)'
14 'url': 'http://www.flickr.com/photos/forestwander-nature-pictures/5645318632/in/photostream/',
15 'md5': '164fe3fa6c22e18d448d4d5af2330f31',
19 'description': 'Waterfalls in the Springtime at Dark Hollow Waterfalls. These are located just off of Skyline Drive in Virginia. They are only about 6/10 of a mile hike but it is a pretty steep hill and a good climb back up.',
20 'uploader_id': 'forestwander-nature-pictures',
21 'title': 'Dark Hollow Waterfalls',
23 'timestamp': 1303528740,
24 'upload_date': '20110423',
25 'uploader_id': '10922353@N03',
26 'uploader': 'Forest Wander',
31 _API_BASE_URL = 'https://api.flickr.com/services/rest?'
32 _API_KEY = '61b16865f916058e63580a912d9143be'
34 def _call_api(self, method, video_id, secret=None):
37 'method': 'flickr.%s' % method,
38 'api_key': self._API_KEY,
43 query['secret'] = secret
44 return self._download_json(self._API_BASE_URL + compat_urllib_parse.urlencode(query), video_id)
46 def _real_extract(self, url):
47 video_id = self._match_id(url)
49 video_info = self._call_api('photos.getInfo', video_id)['photo']
50 if video_info['media'] == 'video':
51 streams = self._call_api('video.getStreamInfo', video_id, video_info['secret'])['streams']
53 preference = qualities(['iphone_wifi', '700', 'appletv', 'orig'])
56 for stream in streams['stream']:
57 stream_type = str(stream.get('type'))
59 'format_id': stream_type,
60 'url': stream['_content'],
61 'preference': preference(stream_type),
63 self._sort_formats(formats)
65 owner = video_info.get('owner', {})
69 'title': video_info['title']['_content'],
70 'description': video_info.get('description', {}).get('_content'),
72 'timestamp': int_or_none(video_info.get('dateuploaded')),
73 'duration': int_or_none(video_info.get('video', {}).get('duration')),
74 'uploader_id': owner.get('nsid'),
75 'uploader': owner.get('realname'),
76 'comment_count': int_or_none(video_info.get('comments', {}).get('_content')),