]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/flickr.py
1 from __future__
import unicode_literals
5 from . common
import InfoExtractor
13 class FlickrIE ( InfoExtractor
):
14 _VALID_URL
= r
'https?://(?:www\.|secure\.)?flickr\.com/photos/(?P<uploader_id>[\w\-_@]+)/(?P<id>\d+).*'
16 'url' : 'http://www.flickr.com/photos/forestwander-nature-pictures/5645318632/in/photostream/' ,
17 'md5' : '6fdc01adbc89d72fc9c4f15b4a4ba87b' ,
21 "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." ,
22 "uploader_id" : "forestwander-nature-pictures" ,
23 "title" : "Dark Hollow Waterfalls"
27 def _real_extract ( self
, url
):
28 mobj
= re
. match ( self
._ VALID
_U RL
, url
)
30 video_id
= mobj
. group ( 'id' )
31 video_uploader_id
= mobj
. group ( 'uploader_id' )
32 webpage_url
= 'http://www.flickr.com/photos/' + video_uploader_id
+ '/' + video_id
33 req
= sanitized_Request ( webpage_url
)
36 # it needs a more recent version
37 'Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20150101 Firefox/38.0 (Chrome)' )
38 webpage
= self
._ download
_ webpage
( req
, video_id
)
40 secret
= self
._ search
_ regex
( r
'secret"\s*:\s*"(\w+)"' , webpage
, 'secret' )
42 first_url
= 'https://secure.flickr.com/apps/video/video_mtl_xml.gne?v=x&photo_id=' + video_id
+ '&secret=' + secret
+ '&bitrate=700&target=_self'
43 first_xml
= self
._ download
_ xml
( first_url
, video_id
, 'Downloading first data webpage' )
45 node_id
= find_xpath_attr (
46 first_xml
, './/{http://video.yahoo.com/YEP/1.0/}Item' , 'id' ,
49 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'
50 second_xml
= self
._ download
_ xml
( second_url
, video_id
, 'Downloading second data webpage' )
52 self
. report_extraction ( video_id
)
54 stream
= second_xml
. find ( './/STREAM' )
56 raise ExtractorError ( 'Unable to extract video url' )
57 video_url
= stream
. attrib
[ 'APP' ] + stream
. attrib
[ 'FULLPATH' ]
63 'title' : self
._ og
_ search
_ title
( webpage
),
64 'description' : self
._ og
_ search
_ description
( webpage
),
65 'thumbnail' : self
._ og
_ search
_ thumbnail
( webpage
),
66 'uploader_id' : video_uploader_id
,