103 lines
3.1 KiB
Python
Raw Normal View History

2018-10-18 22:23:23 -05:00
from __future__ import unicode_literals
import re
from ..compat import compat_urllib_parse_unquote
2018-10-18 22:23:23 -05:00
from .common import InfoExtractor
from ..utils import (
determine_ext,
2018-10-18 22:23:23 -05:00
)
2018-10-21 14:09:30 -05:00
2018-10-18 22:23:23 -05:00
class RightNowMediaIE(InfoExtractor):
IE_NAME = 'rightnowmedia'
_VALID_URL = r'https?://(?:www\.)?rightnowmedia\.org/Content/(?P<id>[0-9]+)/(?:downloadAndEmbed)'
2018-10-18 22:23:23 -05:00
_TEST = {
'url': 'https://www.rightnowmedia.org/Content/293653/downloadAndEmbed',
2018-10-18 22:23:23 -05:00
'info_dict': {
'id': '293653',
2018-10-18 22:23:23 -05:00
'ext': 'mp4',
'title': ' Philippians 1_12-18 - HD 1080p',
2018-10-18 22:23:23 -05:00
}
}
def _real_extract(self, url):
# Video Id
video_id = self._match_id(url)
2018-10-21 14:09:30 -05:00
2018-10-18 22:23:23 -05:00
# Download
video_info_dicts = self._download_json(
'https://www.rightnowmedia.org/Content/%s/downloadAndEmbed'
% video_id, video_id)
2018-10-21 14:09:30 -05:00
# Get All The Formats
formats = []
2018-10-18 22:23:23 -05:00
for video_info in video_info_dicts['downloadLinks']:
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"])),
})
2018-10-21 14:09:30 -05:00
# Get the Title
title = compat_urllib_parse_unquote(re.findall(
2018-10-21 14:09:30 -05:00
r'.*?filename=(.*).*(?:.mp4)',
formats[0]['url'])[0])
# Sort Formats
2018-10-18 22:23:23 -05:00
self._sort_formats(formats)
2018-10-21 14:09:30 -05:00
# Return
2018-10-18 22:23:23 -05:00
return {
'id': video_id,
'title': title,
'formats': formats,
}
2018-10-21 14:09:30 -05:00
class RightNowMediaPlaylistIE(InfoExtractor):
IE_NAME = 'rightnowmedia:playlist'
_VALID_URL = r'https?://(?:www\.)?rightnowmedia\.org/Content/(?:Series|KidsShow)/(?P<id>[0-9]+)'
_TESTS = [{
'url': 'https://www.rightnowmedia.org/Content/Series/265320',
'info_dict': {
'id': '265320'
},
'playlist_count': 9,
2018-10-21 14:09:30 -05:00
}, {
'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
2018-10-21 14:09:30 -05:00
webpage = self._download_webpage(url, playlist_id)
# Find The Correct Table
all_buckets = re.findall(
r'(?s)<table [^"]*"..*? id="primarySeriesTable" [^"]*"..*? \B.*\B<div class="row rowStripMargin nomobile">',
webpage)
2018-10-21 14:09:30 -05:00
# Find All The Video Elements
all_video_elements = re.findall(
r'.*?data-detail-content-id="(.*)">.*',
all_buckets[0])
2018-10-21 14:09:30 -05:00
# 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,
}