]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/ringtv.py
Merge tag 'upstream/2013.08.02'
[youtubedl] / youtube_dl / extractor / ringtv.py
1 import re
2
3 from .common import InfoExtractor
4
5
6 class RingTVIE(InfoExtractor):
7 _VALID_URL = r'(?:http://)?(?:www\.)?ringtv\.craveonline\.com/videos/video/([^/]+)'
8 _TEST = {
9 u"url": u"http://ringtv.craveonline.com/videos/video/746619-canelo-alvarez-talks-about-mayweather-showdown",
10 u"file": u"746619.mp4",
11 u"md5": u"7c46b4057d22de32e0a539f017e64ad3",
12 u"info_dict": {
13 u"title": u"Canelo Alvarez talks about Mayweather showdown",
14 u"description": u"Saul \\\"Canelo\\\" Alvarez spoke to the media about his Sept. 14 showdown with Floyd Mayweather after their kick-off presser in NYC. Canelo is motivated and confident that he will have the speed and gameplan to beat the pound-for-pound king."
15 }
16 }
17
18 def _real_extract(self, url):
19 mobj = re.match(self._VALID_URL, url)
20 video_id = mobj.group(1).split('-')[0]
21 webpage = self._download_webpage(url, video_id)
22 title = self._search_regex(r'<title>(.+?)</title>',
23 webpage, 'video title').replace(' | RingTV','')
24 description = self._search_regex(r'<div class="blurb">(.+?)</div>',
25 webpage, 'Description')
26 final_url = "http://ringtv.craveonline.springboardplatform.com/storage/ringtv.craveonline.com/conversion/%s.mp4" %(str(video_id))
27 thumbnail_url = "http://ringtv.craveonline.springboardplatform.com/storage/ringtv.craveonline.com/snapshots/%s.jpg" %(str(video_id))
28 ext = final_url.split('.')[-1]
29 return [{
30 'id' : video_id,
31 'url' : final_url,
32 'ext' : ext,
33 'title' : title,
34 'thumbnail' : thumbnail_url,
35 'description' : description,
36 }]
37