]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/flickr.py
791d5b61dd27efcaf0aa94d3bce2e1744aa72678
3 from .common
import InfoExtractor
10 class FlickrIE(InfoExtractor
):
11 """Information Extractor for Flickr videos"""
12 _VALID_URL
= r
'(?:https?://)?(?:www\.)?flickr\.com/photos/(?P<uploader_id>[\w\-_@]+)/(?P<id>\d+).*'
14 def _real_extract(self
, url
):
15 mobj
= re
.match(self
._VALID
_URL
, url
)
17 video_id
= mobj
.group('id')
18 video_uploader_id
= mobj
.group('uploader_id')
19 webpage_url
= 'http://www.flickr.com/photos/' + video_uploader_id
+ '/' + video_id
20 webpage
= self
._download
_webpage
(webpage_url
, video_id
)
22 secret
= self
._search
_regex
(r
"photo_secret: '(\w+)'", webpage
, u
'secret')
24 first_url
= 'https://secure.flickr.com/apps/video/video_mtl_xml.gne?v=x&photo_id=' + video_id
+ '&secret=' + secret
+ '&bitrate=700&target=_self'
25 first_xml
= self
._download
_webpage
(first_url
, video_id
, 'Downloading first data webpage')
27 node_id
= self
._html
_search
_regex
(r
'<Item id="id">(\d+-\d+)</Item>',
28 first_xml
, u
'node_id')
30 second_url
= 'https://secure.flickr.com/video_playlist.gne?node_id=' + node_id
+ '&tech=flash&mode=playlist&bitrate=700&secret=' + secret
+ '&rd=video.yahoo.com&noad=1'
31 second_xml
= self
._download
_webpage
(second_url
, video_id
, 'Downloading second data webpage')
33 self
.report_extraction(video_id
)
35 mobj
= re
.search(r
'<STREAM APP="(.+?)" FULLPATH="(.+?)"', second_xml
)
37 raise ExtractorError(u
'Unable to extract video url')
38 video_url
= mobj
.group(1) + unescapeHTML(mobj
.group(2))
40 video_title
= self
._html
_search
_regex
(r
'<meta property="og:title" content=(?:"([^"]+)"|\'([^
\']+)\')',
41 webpage, u'video title
')
43 video_description = self._html_search_regex(r'<meta
property="og:description" content
=(?
:"([^"]+)"|\'([^\']+)\')',
44 webpage, u'description', fatal=False)
46 thumbnail = self._html_search_regex(r'<meta property="og
:image
" content=(?:"([^
"]+)"|
\'([^
\']+)\')',
47 webpage, u'thumbnail
', fatal=False)
54 'description
': video_description,
55 'thumbnail
': thumbnail,
56 'uploader_id
': video_uploader_id,