0
0
Fork 0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2024-11-26 02:55:17 +00:00
yt-dlp/youtube_dl/extractor/rds.py

71 lines
2.7 KiB
Python
Raw Normal View History

2015-07-12 17:35:56 +00:00
# coding: utf-8
from __future__ import unicode_literals
from .common import InfoExtractor
from ..utils import (
parse_duration,
parse_iso8601,
2016-06-30 17:14:23 +00:00
js_to_json,
2015-07-12 17:35:56 +00:00
)
2016-06-30 17:14:23 +00:00
from ..compat import compat_str
2015-07-12 17:35:56 +00:00
class RDSIE(InfoExtractor):
IE_DESC = 'RDS.ca'
2016-06-30 17:14:23 +00:00
_VALID_URL = r'https?://(?:www\.)?rds\.ca/vid(?:[eé]|%C3%A9)os/(?:[^/]+/)*(?P<id>[^/]+)-\d+\.\d+'
2015-07-12 17:35:56 +00:00
2015-07-12 17:45:47 +00:00
_TESTS = [{
2015-07-12 17:35:56 +00:00
'url': 'http://www.rds.ca/videos/football/nfl/fowler-jr-prend-la-direction-de-jacksonville-3.1132799',
'info_dict': {
2016-06-30 17:14:23 +00:00
'id': '604333',
2015-07-12 17:35:56 +00:00
'display_id': 'fowler-jr-prend-la-direction-de-jacksonville',
'ext': 'flv',
2015-07-12 17:35:56 +00:00
'title': 'Fowler Jr. prend la direction de Jacksonville',
'description': 'Dante Fowler Jr. est le troisième choix du repêchage 2015 de la NFL. ',
'timestamp': 1430397346,
'upload_date': '20150430',
'duration': 154.354,
'age_limit': 0,
}
2015-07-12 17:45:47 +00:00
}, {
'url': 'http://www.rds.ca/vid%C3%A9os/un-voyage-positif-3.877934',
'only_matching': True,
}]
2015-07-12 17:35:56 +00:00
def _real_extract(self, url):
2016-06-30 17:14:23 +00:00
display_id = self._match_id(url)
2015-07-12 17:35:56 +00:00
webpage = self._download_webpage(url, display_id)
2016-06-30 17:14:23 +00:00
item = self._parse_json(self._search_regex(r'(?s)itemToPush\s*=\s*({.+?});', webpage, 'item'), display_id, js_to_json)
video_id = compat_str(item['id'])
title = item.get('title') or self._og_search_title(webpage) or self._html_search_meta(
2015-07-12 17:35:56 +00:00
'title', webpage, 'title', fatal=True)
description = self._og_search_description(webpage) or self._html_search_meta(
'description', webpage, 'description')
2016-06-30 17:14:23 +00:00
thumbnail = item.get('urlImageBig') or self._og_search_thumbnail(webpage) or self._search_regex(
2015-07-12 17:35:56 +00:00
[r'<link[^>]+itemprop="thumbnailUrl"[^>]+href="([^"]+)"',
r'<span[^>]+itemprop="thumbnailUrl"[^>]+content="([^"]+)"'],
webpage, 'thumbnail', fatal=False)
timestamp = parse_iso8601(self._search_regex(
r'<span[^>]+itemprop="uploadDate"[^>]+content="([^"]+)"',
webpage, 'upload date', fatal=False))
duration = parse_duration(self._search_regex(
r'<span[^>]+itemprop="duration"[^>]+content="([^"]+)"',
webpage, 'duration', fatal=False))
age_limit = self._family_friendly_search(webpage)
return {
2016-06-30 17:14:23 +00:00
'_type': 'url_transparent',
2015-07-12 17:35:56 +00:00
'id': video_id,
'display_id': display_id,
2016-06-30 17:14:23 +00:00
'url': '9c9media:rds_web:%s' % video_id,
2015-07-12 17:35:56 +00:00
'title': title,
'description': description,
'thumbnail': thumbnail,
'timestamp': timestamp,
'duration': duration,
'age_limit': age_limit,
2016-06-30 17:14:23 +00:00
'ie_key': 'NineCNineMedia',
2015-07-12 17:35:56 +00:00
}