From afef36c950fd158d7bcfb6a1990d666241949b63 Mon Sep 17 00:00:00 2001 From: Anna Bernardi Date: Mon, 20 May 2013 23:18:40 +0200 Subject: [PATCH] add support for Flickr videos - closes #261 --- test/tests.json | 11 +++++++ youtube_dl/InfoExtractors.py | 64 ++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) diff --git a/test/tests.json b/test/tests.json index 1ff9ad7ee..eed062813 100644 --- a/test/tests.json +++ b/test/tests.json @@ -461,5 +461,16 @@ "title": "Chicken.", "uploader": "Jack Dorsey" } + }, + { + "name": "Flickr", + "url": "http://www.flickr.com/photos/forestwander-nature-pictures/5645318632/in/photostream/", + "file": "5645318632.mp4", + "md5": "6fdc01adbc89d72fc9c4f15b4a4ba87b", + "info_dict":{ + "title": "Dark Hollow Waterfalls", + "uploader_id": "forestwander-nature-pictures", + "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." + } } ] diff --git a/youtube_dl/InfoExtractors.py b/youtube_dl/InfoExtractors.py index c38592e79..fe47e5254 100755 --- a/youtube_dl/InfoExtractors.py +++ b/youtube_dl/InfoExtractors.py @@ -4279,6 +4279,69 @@ class VineIE(InfoExtractor): 'uploader': uploader, }] +class FlickrIE(InfoExtractor): + """Information Extractor for Flickr videos""" + _VALID_URL = r'(?:https?://)?(?:www\.)?flickr\.com/photos/(?P[\w\-]+)/(?P\d+).*' + + def _real_extract(self, url): + mobj = re.match(self._VALID_URL, url) + + video_id = mobj.group('id') + video_uploader_id = mobj.group('uploader_id') + webpage_url = 'http://www.flickr.com/photos/' + video_uploader_id + '/' + video_id + webpage = self._download_webpage(webpage_url, video_id) + + self.report_extraction(video_id) + + mobj = re.search(r"photo_secret: '(\w+)'", webpage) + if mobj is None: + raise ExtractorError(u'Unable to extract video secret') + secret = mobj.group(1) + + first_url = 'https://secure.flickr.com/apps/video/video_mtl_xml.gne?v=x&photo_id=' + video_id + '&secret=' + secret + '&bitrate=700&target=_self' + first_xml = self._download_webpage(first_url, video_id) + + mobj = re.search(r'(\d+-\d+)', first_xml) + if mobj is None: + raise ExtractorError(u'Unable to extract node_id') + node_id = mobj.group(1) + + 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' + second_xml = self._download_webpage(second_url, video_id) + + mobj = re.search(r'