From ac8f97f2b37115bf81a653360819b5d30eebda18 Mon Sep 17 00:00:00 2001 From: felix Date: Sat, 11 Jul 2015 18:56:07 +0200 Subject: [PATCH 1/2] [rdsca] New extractor --- youtube_dl/extractor/__init__.py | 1 + youtube_dl/extractor/rdsca.py | 50 ++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 youtube_dl/extractor/rdsca.py diff --git a/youtube_dl/extractor/__init__.py b/youtube_dl/extractor/__init__.py index cbaa07391..73fa0e4ed 100644 --- a/youtube_dl/extractor/__init__.py +++ b/youtube_dl/extractor/__init__.py @@ -460,6 +460,7 @@ from .radiobremen import RadioBremenIE from .radiofrance import RadioFranceIE from .rai import RaiIE from .rbmaradio import RBMARadioIE +from .rdsca import RDScaIE from .redtube import RedTubeIE from .restudy import RestudyIE from .reverbnation import ReverbNationIE diff --git a/youtube_dl/extractor/rdsca.py b/youtube_dl/extractor/rdsca.py new file mode 100644 index 000000000..a8df927e4 --- /dev/null +++ b/youtube_dl/extractor/rdsca.py @@ -0,0 +1,50 @@ +# coding: utf-8 +from __future__ import unicode_literals + +from .common import InfoExtractor +from ..utils import ( + parse_iso8601, + url_basename, +) + + +class RDScaIE(InfoExtractor): + IE_NAME = 'RDS.ca' + _VALID_URL = r'http://(?:www\.)?rds\.ca/videos/(?P.*)' + + _TESTS = [{ + 'url': 'http://www.rds.ca/videos/football/nfl/fowler-jr-prend-la-direction-de-jacksonville-3.1132799', + 'info_dict': { + "ext": "mp4", + "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, + } + }] + + def _real_extract(self, url): + video_id = url_basename(url) + + webpage = self._download_webpage(url, video_id) + + title = self._search_regex( + r']*>([^\n]*)', webpage, 'video title', default=None) + video_url = self._search_regex( + r']*>([^\n]*)', webpage, 'description', default=None) + thumbnail = self._search_regex( + r' Date: Sun, 12 Jul 2015 23:35:56 +0600 Subject: [PATCH 2/2] [rds] Improve --- youtube_dl/extractor/__init__.py | 2 +- youtube_dl/extractor/rds.py | 70 ++++++++++++++++++++++++++++++++ youtube_dl/extractor/rdsca.py | 50 ----------------------- 3 files changed, 71 insertions(+), 51 deletions(-) create mode 100644 youtube_dl/extractor/rds.py delete mode 100644 youtube_dl/extractor/rdsca.py diff --git a/youtube_dl/extractor/__init__.py b/youtube_dl/extractor/__init__.py index 73fa0e4ed..3f4f23521 100644 --- a/youtube_dl/extractor/__init__.py +++ b/youtube_dl/extractor/__init__.py @@ -460,7 +460,7 @@ from .radiobremen import RadioBremenIE from .radiofrance import RadioFranceIE from .rai import RaiIE from .rbmaradio import RBMARadioIE -from .rdsca import RDScaIE +from .rds import RDSIE from .redtube import RedTubeIE from .restudy import RestudyIE from .reverbnation import ReverbNationIE diff --git a/youtube_dl/extractor/rds.py b/youtube_dl/extractor/rds.py new file mode 100644 index 000000000..fdd3f36a6 --- /dev/null +++ b/youtube_dl/extractor/rds.py @@ -0,0 +1,70 @@ +# coding: utf-8 +from __future__ import unicode_literals + +import re + +from .common import InfoExtractor +from ..utils import ( + parse_duration, + parse_iso8601, +) + + +class RDSIE(InfoExtractor): + IE_DESC = 'RDS.ca' + _VALID_URL = r'https?://(?:www\.)?rds\.ca/videos/(?:[^/]+/)+(?P[^/]+)-(?P\d+\.\d+)' + + _TEST = { + 'url': 'http://www.rds.ca/videos/football/nfl/fowler-jr-prend-la-direction-de-jacksonville-3.1132799', + 'info_dict': { + 'id': '3.1132799', + 'display_id': 'fowler-jr-prend-la-direction-de-jacksonville', + 'ext': 'mp4', + '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, + } + } + + def _real_extract(self, url): + mobj = re.match(self._VALID_URL, url) + video_id = mobj.group('id') + display_id = mobj.group('display_id') + + webpage = self._download_webpage(url, display_id) + + # TODO: extract f4m from 9c9media.com + video_url = self._search_regex( + r']+itemprop="contentURL"[^>]+content="([^"]+)"', + webpage, 'video url') + + title = self._og_search_title(webpage) or self._html_search_meta( + 'title', webpage, 'title', fatal=True) + description = self._og_search_description(webpage) or self._html_search_meta( + 'description', webpage, 'description') + thumbnail = self._og_search_thumbnail(webpage) or self._search_regex( + [r']+itemprop="thumbnailUrl"[^>]+href="([^"]+)"', + r']+itemprop="thumbnailUrl"[^>]+content="([^"]+)"'], + webpage, 'thumbnail', fatal=False) + timestamp = parse_iso8601(self._search_regex( + r']+itemprop="uploadDate"[^>]+content="([^"]+)"', + webpage, 'upload date', fatal=False)) + duration = parse_duration(self._search_regex( + r']+itemprop="duration"[^>]+content="([^"]+)"', + webpage, 'duration', fatal=False)) + age_limit = self._family_friendly_search(webpage) + + return { + 'id': video_id, + 'display_id': display_id, + 'url': video_url, + 'title': title, + 'description': description, + 'thumbnail': thumbnail, + 'timestamp': timestamp, + 'duration': duration, + 'age_limit': age_limit, + } diff --git a/youtube_dl/extractor/rdsca.py b/youtube_dl/extractor/rdsca.py deleted file mode 100644 index a8df927e4..000000000 --- a/youtube_dl/extractor/rdsca.py +++ /dev/null @@ -1,50 +0,0 @@ -# coding: utf-8 -from __future__ import unicode_literals - -from .common import InfoExtractor -from ..utils import ( - parse_iso8601, - url_basename, -) - - -class RDScaIE(InfoExtractor): - IE_NAME = 'RDS.ca' - _VALID_URL = r'http://(?:www\.)?rds\.ca/videos/(?P.*)' - - _TESTS = [{ - 'url': 'http://www.rds.ca/videos/football/nfl/fowler-jr-prend-la-direction-de-jacksonville-3.1132799', - 'info_dict': { - "ext": "mp4", - "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, - } - }] - - def _real_extract(self, url): - video_id = url_basename(url) - - webpage = self._download_webpage(url, video_id) - - title = self._search_regex( - r']*>([^\n]*)', webpage, 'video title', default=None) - video_url = self._search_regex( - r']*>([^\n]*)', webpage, 'description', default=None) - thumbnail = self._search_regex( - r'