From f65e62f00effec474ccefe14d6d86634ce1b87eb Mon Sep 17 00:00:00 2001 From: Andy Bottom Date: Thu, 18 Oct 2018 22:23:23 -0500 Subject: [PATCH 1/3] Initial commit for rightnowmedia. --- youtube_dl/extractor/extractors.py | 1 + youtube_dl/extractor/rightnowmedia.py | 55 +++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 youtube_dl/extractor/rightnowmedia.py diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py index 464c8d690..4f0cdc5ea 100644 --- a/youtube_dl/extractor/extractors.py +++ b/youtube_dl/extractor/extractors.py @@ -929,6 +929,7 @@ from .revision3 import ( Revision3IE, ) from .rice import RICEIE +from .rightnowmedia import RightNowMediaIE from .rmcdecouverte import RMCDecouverteIE from .ro220 import Ro220IE from .rockstargames import RockstarGamesIE diff --git a/youtube_dl/extractor/rightnowmedia.py b/youtube_dl/extractor/rightnowmedia.py new file mode 100644 index 000000000..d43e38f8d --- /dev/null +++ b/youtube_dl/extractor/rightnowmedia.py @@ -0,0 +1,55 @@ +from __future__ import unicode_literals + +from .common import InfoExtractor +from ..utils import ( + determine_ext +) + +class RightNowMediaIE(InfoExtractor): + _VALID_URL = r'https?://(?:www\.)?rightnowmedia\.org/Content/(?:VideoElement|Series|KidsShow)/(?P[0-9]+)' + _TEST = { + 'url': 'https://www.rightnowmedia.org/Content/VideoElement/231113', + 'info_dict': { + 'id': '231113', + 'ext': 'mp4', + 'title': 'Augustana (S.D.) Baseball vs University of Mary', + 'description': 'md5:7578478614aae3bdd4a90f578f787438', + 'timestamp': 1490468400, + 'upload_date': '20170325', + } + } + + def _real_extract(self, url): + + # Video Id + video_id = self._match_id(url) + # Download + video_info_dicts = self._download_json( + 'https://www.rightnowmedia.org/Content/%s/downloadAndEmbed' + % video_id, video_id) + + video_url = 'https://%s' % video_info_dicts['downloadLinks'] + formats = [] + + + + for video_info in video_info_dicts['downloadLinks']: + video_url = video_info.get('src') + quality = 'high' if 'HD 1080p' in video_info["QualityName"] else 'low' + formats.append({ + 'url': video_info["Link"], + 'preference': 10 if quality == 'high' else 0, + 'format_note': quality, + 'format_id': '%s-%s' % (quality, determine_ext(video_info["Link"])), + }) + self._sort_formats(formats) + + title = "Test 01" + description = "aaaa" + + return { + 'id': video_id, + 'title': title, + 'description': description, + 'formats': formats, + } From 2d68da7781ba553661b5585ce083a6836825ee46 Mon Sep 17 00:00:00 2001 From: Andy Bottom Date: Sun, 21 Oct 2018 13:59:42 -0500 Subject: [PATCH 2/3] Finalized and tested rightnowmedia for the trailers. --- youtube_dl/extractor/extractors.py | 5 +- youtube_dl/extractor/rightnowmedia.py | 87 +++++++++++++++++++++------ 2 files changed, 71 insertions(+), 21 deletions(-) diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py index 4f0cdc5ea..40a8472a1 100644 --- a/youtube_dl/extractor/extractors.py +++ b/youtube_dl/extractor/extractors.py @@ -929,7 +929,10 @@ from .revision3 import ( Revision3IE, ) from .rice import RICEIE -from .rightnowmedia import RightNowMediaIE +from .rightnowmedia import ( + RightNowMediaIE, + RightNowMediaPlaylistIE +) from .rmcdecouverte import RMCDecouverteIE from .ro220 import Ro220IE from .rockstargames import RockstarGamesIE diff --git a/youtube_dl/extractor/rightnowmedia.py b/youtube_dl/extractor/rightnowmedia.py index d43e38f8d..e7bc2fbb7 100644 --- a/youtube_dl/extractor/rightnowmedia.py +++ b/youtube_dl/extractor/rightnowmedia.py @@ -1,38 +1,34 @@ from __future__ import unicode_literals - +import re +from ..compat import compat_urllib_parse_unquote from .common import InfoExtractor from ..utils import ( - determine_ext + determine_ext, ) class RightNowMediaIE(InfoExtractor): - _VALID_URL = r'https?://(?:www\.)?rightnowmedia\.org/Content/(?:VideoElement|Series|KidsShow)/(?P[0-9]+)' + IE_NAME = 'rightnowmedia' + _VALID_URL = r'https?://(?:www\.)?rightnowmedia\.org/Content/(?P[0-9]+)/(?:downloadAndEmbed)' _TEST = { - 'url': 'https://www.rightnowmedia.org/Content/VideoElement/231113', + 'url': 'https://www.rightnowmedia.org/Content/293653/downloadAndEmbed', 'info_dict': { - 'id': '231113', + 'id': '293653', 'ext': 'mp4', - 'title': 'Augustana (S.D.) Baseball vs University of Mary', - 'description': 'md5:7578478614aae3bdd4a90f578f787438', - 'timestamp': 1490468400, - 'upload_date': '20170325', + 'title': ' Philippians 1_12-18 - HD 1080p', } } def _real_extract(self, url): - # Video Id video_id = self._match_id(url) + # Download video_info_dicts = self._download_json( 'https://www.rightnowmedia.org/Content/%s/downloadAndEmbed' % video_id, video_id) - - video_url = 'https://%s' % video_info_dicts['downloadLinks'] + + # Get All The Formats formats = [] - - - for video_info in video_info_dicts['downloadLinks']: video_url = video_info.get('src') quality = 'high' if 'HD 1080p' in video_info["QualityName"] else 'low' @@ -42,14 +38,65 @@ class RightNowMediaIE(InfoExtractor): 'format_note': quality, 'format_id': '%s-%s' % (quality, determine_ext(video_info["Link"])), }) + + # Get the Title + title = compat_urllib_parse_unquote(re.findall( + r'.*?filename=(.*).*(?:.mp4)', + formats[0]['url'])[0]) + + # Sort Formats self._sort_formats(formats) - - title = "Test 01" - description = "aaaa" - + + # Return return { 'id': video_id, 'title': title, - 'description': description, 'formats': formats, } + + +class RightNowMediaPlaylistIE(InfoExtractor): + IE_NAME = 'rightnowmedia:playlist' + _VALID_URL = r'https?://(?:www\.)?rightnowmedia\.org/Content/(?:Series|KidsShow)/(?P[0-9]+)' + _TESTS = [{ + 'url': 'https://www.rightnowmedia.org/Content/Series/265320', + 'info_dict': { + 'id': '265320' + }, + 'playlist_count': 9, + },{ + 'url': 'https://www.rightnowmedia.org/Content/KidsShow/298875', + 'info_dict': { + 'id': '298875' + }, + 'playlist_count': 15, + }] + + def _real_extract(self, url): + # Series Id + playlist_id = self._match_id(url) + + # Download Webpage + webpage = self._download_webpage(url, playlist_id) + + # Find The Correct Table + all_buckets = re.findall( + r'(?s)', + webpage) + + # Find All The Video Elements + all_video_elements = re.findall( + r'.*?data-detail-content-id="(.*)">.*', + all_buckets[0]) + + # Finalize All The URLs + entries = [] + for video_element in all_video_elements: + entries.append(self.url_result('https://www.rightnowmedia.org/Content/%s/downloadAndEmbed' % video_element)) + + # Return + return { + '_type': 'playlist', + 'id': playlist_id, + 'entries': entries, + } From d76916f79ec2d340dfe0c293bb7d223ad673dc43 Mon Sep 17 00:00:00 2001 From: Andy Bottom Date: Sun, 21 Oct 2018 14:09:30 -0500 Subject: [PATCH 3/3] Fixed formatting according to flake8 --- youtube_dl/extractor/rightnowmedia.py | 28 +++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/youtube_dl/extractor/rightnowmedia.py b/youtube_dl/extractor/rightnowmedia.py index e7bc2fbb7..ea8f18686 100644 --- a/youtube_dl/extractor/rightnowmedia.py +++ b/youtube_dl/extractor/rightnowmedia.py @@ -6,6 +6,7 @@ from ..utils import ( determine_ext, ) + class RightNowMediaIE(InfoExtractor): IE_NAME = 'rightnowmedia' _VALID_URL = r'https?://(?:www\.)?rightnowmedia\.org/Content/(?P[0-9]+)/(?:downloadAndEmbed)' @@ -21,16 +22,15 @@ class RightNowMediaIE(InfoExtractor): def _real_extract(self, url): # Video Id video_id = self._match_id(url) - + # Download video_info_dicts = self._download_json( 'https://www.rightnowmedia.org/Content/%s/downloadAndEmbed' % video_id, video_id) - + # Get All The Formats formats = [] for video_info in video_info_dicts['downloadLinks']: - video_url = video_info.get('src') quality = 'high' if 'HD 1080p' in video_info["QualityName"] else 'low' formats.append({ 'url': video_info["Link"], @@ -38,15 +38,15 @@ class RightNowMediaIE(InfoExtractor): 'format_note': quality, 'format_id': '%s-%s' % (quality, determine_ext(video_info["Link"])), }) - + # Get the Title title = compat_urllib_parse_unquote(re.findall( - r'.*?filename=(.*).*(?:.mp4)', - formats[0]['url'])[0]) - + r'.*?filename=(.*).*(?:.mp4)', + formats[0]['url'])[0]) + # Sort Formats self._sort_formats(formats) - + # Return return { 'id': video_id, @@ -54,7 +54,7 @@ class RightNowMediaIE(InfoExtractor): 'formats': formats, } - + class RightNowMediaPlaylistIE(InfoExtractor): IE_NAME = 'rightnowmedia:playlist' _VALID_URL = r'https?://(?:www\.)?rightnowmedia\.org/Content/(?:Series|KidsShow)/(?P[0-9]+)' @@ -64,7 +64,7 @@ class RightNowMediaPlaylistIE(InfoExtractor): 'id': '265320' }, 'playlist_count': 9, - },{ + }, { 'url': 'https://www.rightnowmedia.org/Content/KidsShow/298875', 'info_dict': { 'id': '298875' @@ -77,18 +77,18 @@ class RightNowMediaPlaylistIE(InfoExtractor): playlist_id = self._match_id(url) # Download Webpage - webpage = self._download_webpage(url, playlist_id) - + webpage = self._download_webpage(url, playlist_id) + # Find The Correct Table all_buckets = re.findall( r'(?s)
', webpage) - + # Find All The Video Elements all_video_elements = re.findall( r'.*?data-detail-content-id="(.*)">.*', all_buckets[0]) - + # Finalize All The URLs entries = [] for video_element in all_video_elements: