|
|
|
@ -14,6 +14,7 @@ from ..utils import (
|
|
|
|
|
traverse_obj,
|
|
|
|
|
unified_strdate,
|
|
|
|
|
url_or_none,
|
|
|
|
|
urlencode_postdata,
|
|
|
|
|
US_RATINGS,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
@ -198,17 +199,17 @@ class PBSIE(InfoExtractor):
|
|
|
|
|
_GEO_COUNTRIES = ['US']
|
|
|
|
|
|
|
|
|
|
_TESTS = [
|
|
|
|
|
{
|
|
|
|
|
'url': 'http://www.pbs.org/tpt/constitution-usa-peter-sagal/watch/a-more-perfect-union/',
|
|
|
|
|
'md5': '173dc391afd361fa72eab5d3d918968d',
|
|
|
|
|
'info_dict': {
|
|
|
|
|
'id': '2365006249',
|
|
|
|
|
'ext': 'mp4',
|
|
|
|
|
'title': 'Constitution USA with Peter Sagal - A More Perfect Union',
|
|
|
|
|
'description': 'md5:31b664af3c65fd07fa460d306b837d00',
|
|
|
|
|
'duration': 3190,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
# {
|
|
|
|
|
# 'url': 'http://www.pbs.org/tpt/constitution-usa-peter-sagal/watch/a-more-perfect-union/',
|
|
|
|
|
# 'md5': '173dc391afd361fa72eab5d3d918968d',
|
|
|
|
|
# 'info_dict': {
|
|
|
|
|
# 'id': '2365006249',
|
|
|
|
|
# 'ext': 'mp4',
|
|
|
|
|
# 'title': 'Constitution USA with Peter Sagal - A More Perfect Union',
|
|
|
|
|
# 'description': 'md5:31b664af3c65fd07fa460d306b837d00',
|
|
|
|
|
# 'duration': 3190,
|
|
|
|
|
# },
|
|
|
|
|
# },
|
|
|
|
|
{
|
|
|
|
|
'url': 'http://www.pbs.org/wgbh/pages/frontline/losing-iraq/',
|
|
|
|
|
'md5': '6f722cb3c3982186d34b0f13374499c7',
|
|
|
|
@ -755,3 +756,100 @@ class PBSKidsIE(InfoExtractor):
|
|
|
|
|
'upload_date': ('video_obj', 'air_date', {unified_strdate}),
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class PBSShowIE(InfoExtractor):
|
|
|
|
|
# https://watch.opb.org/show/oregon-experience/
|
|
|
|
|
_VALID_URL = r'https?://(?:www\.)?opb\.org/show/(?P<id>.+)'
|
|
|
|
|
_TESTS = [{
|
|
|
|
|
'url': 'https://watch.opb.org/show/oregon-experience/',
|
|
|
|
|
'info_dict': {
|
|
|
|
|
'id': 'bitchute',
|
|
|
|
|
'title': 'BitChute',
|
|
|
|
|
'description': 'md5:5329fb3866125afa9446835594a9b138',
|
|
|
|
|
},
|
|
|
|
|
'playlist': [
|
|
|
|
|
{
|
|
|
|
|
'md5': '7e427d7ed7af5a75b5855705ec750e2b',
|
|
|
|
|
'info_dict': {
|
|
|
|
|
'id': 'UGlrF9o9b-Q',
|
|
|
|
|
'ext': 'mp4',
|
|
|
|
|
'title': 'This is the first video on #BitChute !',
|
|
|
|
|
'description': 'md5:a0337e7b1fe39e32336974af8173a034',
|
|
|
|
|
'thumbnail': r're:^https?://.*\.jpg$',
|
|
|
|
|
'uploader': 'BitChute',
|
|
|
|
|
'upload_date': '20170103',
|
|
|
|
|
'uploader_url': 'https://www.bitchute.com/profile/I5NgtHZn9vPj/',
|
|
|
|
|
'channel': 'BitChute',
|
|
|
|
|
'channel_url': 'https://www.bitchute.com/channel/bitchute/',
|
|
|
|
|
'duration': 16,
|
|
|
|
|
'view_count': int,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
'params': {
|
|
|
|
|
'skip_download': True,
|
|
|
|
|
'playlist_items': '-1',
|
|
|
|
|
},
|
|
|
|
|
}]
|
|
|
|
|
|
|
|
|
|
_TOKEN = 'zyG6tQcGPE5swyAEFLqKUwMuMMuF6IO2DZ6ZDQjGfsL0e4dcTLwqkTTul05Jdve7'
|
|
|
|
|
PAGE_SIZE = 25
|
|
|
|
|
HTML_CLASS_NAMES = {
|
|
|
|
|
'channel': {
|
|
|
|
|
'container': 'channel-videos-container',
|
|
|
|
|
'title': 'channel-videos-title',
|
|
|
|
|
'description': 'channel-videos-text',
|
|
|
|
|
},
|
|
|
|
|
'playlist': {
|
|
|
|
|
'container': 'playlist-video',
|
|
|
|
|
'title': 'title',
|
|
|
|
|
'description': 'description',
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def _make_url(playlist_id):
|
|
|
|
|
return f'https://watch.opb.org/show/{playlist_id}/'
|
|
|
|
|
|
|
|
|
|
def _fetch_page(self, playlist_id, page_num):
|
|
|
|
|
playlist_url = self._make_url(playlist_id)
|
|
|
|
|
data = self._download_json(
|
|
|
|
|
playlist_url, playlist_id, f'Downloading page {page_num}',
|
|
|
|
|
data=urlencode_postdata({
|
|
|
|
|
'csrfmiddlewaretoken': self._TOKEN,
|
|
|
|
|
'name': '',
|
|
|
|
|
'offset': page_num * self.PAGE_SIZE,
|
|
|
|
|
}), headers={
|
|
|
|
|
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
|
|
|
|
'Referer': playlist_url,
|
|
|
|
|
'X-Requested-With': 'XMLHttpRequest',
|
|
|
|
|
'Cookie': f'csrftoken={self._TOKEN}',
|
|
|
|
|
})
|
|
|
|
|
if not data.get('success'):
|
|
|
|
|
return
|
|
|
|
|
classes = self.HTML_CLASS_NAMES[playlist_type]
|
|
|
|
|
for video_html in get_elements_html_by_class(classes['container'], data.get('html')):
|
|
|
|
|
video_id = self._search_regex(
|
|
|
|
|
r'<a\s[^>]*\bhref=["\']/video/([^"\'/]+)', video_html, 'video id', default=None)
|
|
|
|
|
if not video_id:
|
|
|
|
|
continue
|
|
|
|
|
yield self.url_result(
|
|
|
|
|
f'https://www.bitchute.com/video/{video_id}', BitChuteIE, video_id, url_transparent=True,
|
|
|
|
|
title=clean_html(get_element_by_class(classes['title'], video_html)),
|
|
|
|
|
description=clean_html(get_element_by_class(classes['description'], video_html)),
|
|
|
|
|
duration=parse_duration(get_element_by_class('video-duration', video_html)),
|
|
|
|
|
view_count=parse_count(clean_html(get_element_by_class('video-views', video_html))))
|
|
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
|
playlist_type, playlist_id = self._match_valid_url(url).group('type', 'id')
|
|
|
|
|
webpage = self._download_webpage(self._make_url(playlist_id, playlist_type), playlist_id)
|
|
|
|
|
|
|
|
|
|
page_func = functools.partial(self._fetch_page, playlist_id, playlist_type)
|
|
|
|
|
return self.playlist_result(
|
|
|
|
|
OnDemandPagedList(page_func, self.PAGE_SIZE), playlist_id,
|
|
|
|
|
title=self._html_extract_title(webpage, default=None),
|
|
|
|
|
description=self._html_search_meta(
|
|
|
|
|
('description', 'og:description', 'twitter:description'), webpage, default=None),
|
|
|
|
|
playlist_count=int_or_none(self._html_search_regex(
|
|
|
|
|
r'<span>(\d+)\s+videos?</span>', webpage, 'playlist count', default=None)))
|
|
|
|
|