summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJaime Marquínez Ferrándiz <[email protected]>2013-04-22 21:07:49 +0200
committerJaime Marquínez Ferrándiz <[email protected]>2013-04-22 21:27:27 +0200
commitc15e024141727e5eed8056d3b2732f4f7553b2b4 (patch)
treeeb668592d912882966f8f4150f69d79345258a87
parent8cb94542f407a748d75e39a0f7730c68f02d23cf (diff)
downloadyoutube-dl-c15e024141727e5eed8056d3b2732f4f7553b2b4.tar.gz
youtube-dl-c15e024141727e5eed8056d3b2732f4f7553b2b4.zip
TumblrIE
I haven't found many videos to test, so it may not work for all.
-rw-r--r--test/tests.json9
-rwxr-xr-xyoutube_dl/InfoExtractors.py35
2 files changed, 44 insertions, 0 deletions
diff --git a/test/tests.json b/test/tests.json
index 7808a07de..2b56738a0 100644
--- a/test/tests.json
+++ b/test/tests.json
@@ -337,6 +337,15 @@
"title": "11.04.2013 09:23 Uhr - Tagesschau in 100 Sekunden"
},
"skip": "Requires rtmpdump"
+ },
+ {
+ "name": "Tumblr",
+ "url": "http://birthdayproject2012.tumblr.com/post/17258355236/a-sample-video-from-leeann-if-you-need-an-idea",
+ "file": "17258355236.mp4",
+ "md5": "7c6a514d691b034ccf8567999e9e88a3",
+ "info_dict": {
+ "title": "A sample video from LeeAnn. (If you need an idea..."
+ }
}
]
diff --git a/youtube_dl/InfoExtractors.py b/youtube_dl/InfoExtractors.py
index ff1f07e9b..6a6545c9b 100755
--- a/youtube_dl/InfoExtractors.py
+++ b/youtube_dl/InfoExtractors.py
@@ -4327,6 +4327,40 @@ class ARDIE(InfoExtractor):
info["url"] = stream["video_url"]
return [info]
+class TumblrIE(InfoExtractor):
+ _VALID_URL = r'http://(?P<blog_name>.*?).tumblr.com/((post)|(video))/(?P<id>\d*)/(.*?)'
+
+ def _real_extract(self, url):
+ m_url = re.match(self._VALID_URL, url)
+ video_id = m_url.group('id')
+ blog = m_url.group('blog_name')
+
+ url = 'http://%s.tumblr.com/post/%s/' % (blog, video_id)
+ webpage = self._download_webpage(url, video_id)
+
+ re_video = r'src=\\x22(?P<video_url>http://%s.tumblr.com/video_file/%s/(.*?))\\x22 type=\\x22video/(?P<ext>.*?)\\x22' % (blog, video_id)
+ video = re.search(re_video, webpage)
+ if video is None:
+ self.to_screen("No video founded")
+ return []
+ video_url = video.group('video_url')
+ ext = video.group('ext')
+
+ re_thumb = r'posters(.*?)\[\\x22(?P<thumb>.*?)\\x22' # We pick the first poster
+ thumb = re.search(re_thumb, webpage).group('thumb').replace('\\', '')
+
+ # The only place where you can get a title, it's not complete,
+ # but searching in other places doesn't work for all videos
+ re_title = r'<title>(.*?) - (?P<title>.*?)</title>'
+ title = unescapeHTML(re.search(re_title, webpage).group('title'))
+
+ return [{'id': video_id,
+ 'url': video_url,
+ 'title': title,
+ 'thumbnail': thumb,
+ 'ext': ext
+ }]
+
def gen_extractors():
""" Return a list of an instance of every supported extractor.
@@ -4381,6 +4415,7 @@ def gen_extractors():
SpiegelIE(),
LiveLeakIE(),
ARDIE(),
+ TumblrIE(),
GenericIE()
]