X-Git-Url: https://git.rapsys.eu/youtubedl/blobdiff_plain/848723ea972c09f28787db91d8c06e98a274ab89..1931fa5f23ac75ea766517aa1b5ebf267ad3f97d:/youtube_dl/extractor/pbs.py diff --git a/youtube_dl/extractor/pbs.py b/youtube_dl/extractor/pbs.py index e7e0042..ec95d07 100644 --- a/youtube_dl/extractor/pbs.py +++ b/youtube_dl/extractor/pbs.py @@ -3,6 +3,9 @@ from __future__ import unicode_literals import re from .common import InfoExtractor +from ..utils import ( + US_RATINGS, +) class PBSIE(InfoExtractor): @@ -13,7 +16,7 @@ class PBSIE(InfoExtractor): # Article with embedded player (?:www\.)?pbs\.org/(?:[^/]+/){2,5}(?P[^/]+)/?(?:$|[?\#]) | # Player - video\.pbs\.org/partnerplayer/(?P[^/]+)/ + video\.pbs\.org/(?:widget/)?partnerplayer/(?P[^/]+)/ ) ''' @@ -29,13 +32,21 @@ class PBSIE(InfoExtractor): }, } - def _real_extract(self, url): + def _extract_ids(self, url): mobj = re.match(self._VALID_URL, url) presumptive_id = mobj.group('presumptive_id') display_id = presumptive_id if presumptive_id: webpage = self._download_webpage(url, display_id) + + # frontline video embed + media_id = self._search_regex( + r"div\s*:\s*'videoembed'\s*,\s*mediaid\s*:\s*'(\d+)'", + webpage, 'frontline video ID', fatal=False, default=None) + if media_id: + return media_id, presumptive_id + url = self._search_regex( r'', webpage, 'player URL') @@ -54,9 +65,19 @@ class PBSIE(InfoExtractor): video_id = mobj.group('id') display_id = video_id + return video_id, display_id + + def _real_extract(self, url): + video_id, display_id = self._extract_ids(url) + info_url = 'http://video.pbs.org/videoInfo/%s?format=json' % video_id info = self._download_json(info_url, display_id) + rating_str = info.get('rating') + if rating_str is not None: + rating_str = rating_str.rpartition('-')[2] + age_limit = US_RATINGS.get(rating_str) + return { 'id': video_id, 'title': info['title'], @@ -65,4 +86,5 @@ class PBSIE(InfoExtractor): 'description': info['program'].get('description'), 'thumbnail': info.get('image_url'), 'duration': info.get('duration'), + 'age_limit': age_limit, }