[ringtv] Fix and add news extraction

pull/2191/head
Philipp Hagemeister 2014-01-22 02:16:40 +01:00
parent af1588c05f
commit d3a1c71917
1 changed files with 30 additions and 23 deletions

View File

@ -1,37 +1,44 @@
from __future__ import unicode_literals
import re import re
from .common import InfoExtractor from .common import InfoExtractor
class RingTVIE(InfoExtractor): class RingTVIE(InfoExtractor):
_VALID_URL = r'(?:http://)?(?:www\.)?ringtv\.craveonline\.com/videos/video/([^/]+)' _VALID_URL = r'(?:http://)?(?:www\.)?ringtv\.craveonline\.com/(?P<type>news|videos/video)/(?P<id>[^/?#]+)'
_TEST = { _TEST = {
u"url": u"http://ringtv.craveonline.com/videos/video/746619-canelo-alvarez-talks-about-mayweather-showdown", "url": "http://ringtv.craveonline.com/news/310833-luis-collazo-says-victor-ortiz-better-not-quit-on-jan-30",
u"file": u"746619.mp4", "file": "857645.mp4",
u"md5": u"7c46b4057d22de32e0a539f017e64ad3", "md5": "d25945f5df41cdca2d2587165ac28720",
u"info_dict": { "info_dict": {
u"title": u"Canelo Alvarez talks about Mayweather showdown", "title": 'Video: Luis Collazo says Victor Ortiz "better not quit on Jan. 30" - Ring TV',
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." "description": 'Luis Collazo is excited about his Jan. 30 showdown with fellow former welterweight titleholder Victor Ortiz at Barclays Center in his hometown of Brooklyn. The SuperBowl week fight headlines a Golden Boy Live! card on Fox Sports 1.',
} }
} }
def _real_extract(self, url): def _real_extract(self, url):
mobj = re.match(self._VALID_URL, url) mobj = re.match(self._VALID_URL, url)
video_id = mobj.group(1).split('-')[0] video_id = mobj.group('id').split('-')[0]
webpage = self._download_webpage(url, video_id) webpage = self._download_webpage(url, video_id)
title = self._search_regex(r'<title>(.+?)</title>',
webpage, 'video title').replace(' | RingTV','') if mobj.group('type') == 'news':
description = self._search_regex(r'<div class="blurb">(.+?)</div>', video_id = self._search_regex(
webpage, 'Description') r'''(?x)<iframe[^>]+src="http://cms\.springboardplatform\.com/
final_url = "http://ringtv.craveonline.springboardplatform.com/storage/ringtv.craveonline.com/conversion/%s.mp4" %(str(video_id)) embed_iframe/[0-9]+/video/([0-9]+)/''',
thumbnail_url = "http://ringtv.craveonline.springboardplatform.com/storage/ringtv.craveonline.com/snapshots/%s.jpg" %(str(video_id)) webpage, 'real video ID')
ext = final_url.split('.')[-1] title = self._og_search_title(webpage)
return [{ description = self._html_search_regex(
'id' : video_id, r'addthis:description="([^"]+)"',
'url' : final_url, webpage, 'description', fatal=False)
'ext' : ext, final_url = "http://ringtv.craveonline.springboardplatform.com/storage/ringtv.craveonline.com/conversion/%s.mp4" % video_id
'title' : title, thumbnail_url = "http://ringtv.craveonline.springboardplatform.com/storage/ringtv.craveonline.com/snapshots/%s.jpg" % video_id
'thumbnail' : thumbnail_url,
'description' : description, return {
}] 'id': video_id,
'url': final_url,
'title': title,
'thumbnail': thumbnail_url,
'description': description,
}