1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2024-12-22 14:36:34 +01:00
yt-dlp/youtube_dl/extractor/ringtv.py

45 lines
1.9 KiB
Python
Raw Normal View History

2014-01-22 02:16:40 +01:00
from __future__ import unicode_literals
2013-06-28 17:44:06 +02:00
import re
from .common import InfoExtractor
class RingTVIE(InfoExtractor):
2015-02-01 15:21:02 +01:00
_VALID_URL = r'http://(?:www\.)?ringtv\.craveonline\.com/(?P<type>news|videos/video)/(?P<id>[^/?#]+)'
2013-06-28 17:44:06 +02:00
_TEST = {
2014-01-22 02:16:40 +01:00
"url": "http://ringtv.craveonline.com/news/310833-luis-collazo-says-victor-ortiz-better-not-quit-on-jan-30",
"md5": "d25945f5df41cdca2d2587165ac28720",
"info_dict": {
2015-02-01 15:21:02 +01:00
'id': '857645',
'ext': 'mp4',
2014-01-22 02:16:40 +01:00
"title": 'Video: Luis Collazo says Victor Ortiz "better not quit on Jan. 30" - Ring TV',
"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.',
2013-06-28 17:44:06 +02:00
}
}
def _real_extract(self, url):
mobj = re.match(self._VALID_URL, url)
2014-01-22 02:16:40 +01:00
video_id = mobj.group('id').split('-')[0]
2013-06-28 17:44:06 +02:00
webpage = self._download_webpage(url, video_id)
2014-01-22 02:16:40 +01:00
if mobj.group('type') == 'news':
video_id = self._search_regex(
r'''(?x)<iframe[^>]+src="http://cms\.springboardplatform\.com/
embed_iframe/[0-9]+/video/([0-9]+)/''',
webpage, 'real video ID')
title = self._og_search_title(webpage)
description = self._html_search_regex(
r'addthis:description="([^"]+)"',
webpage, 'description', fatal=False)
final_url = "http://ringtv.craveonline.springboardplatform.com/storage/ringtv.craveonline.com/conversion/%s.mp4" % video_id
thumbnail_url = "http://ringtv.craveonline.springboardplatform.com/storage/ringtv.craveonline.com/snapshots/%s.jpg" % video_id
return {
'id': video_id,
'url': final_url,
'title': title,
'thumbnail': thumbnail_url,
'description': description,
}