mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-11-16 18:46:24 +00:00
Adapt yt-dlp#187 to improve NBC metadata
This commit is contained in:
parent
23bd0b20d2
commit
7d07e6bf6b
1 changed files with 25 additions and 9 deletions
|
@ -12,7 +12,9 @@ from ..compat import (
|
||||||
compat_urllib_parse_unquote
|
compat_urllib_parse_unquote
|
||||||
)
|
)
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
|
ExtractorError,
|
||||||
int_or_none,
|
int_or_none,
|
||||||
|
parse_age_limit,
|
||||||
parse_duration,
|
parse_duration,
|
||||||
smuggle_url,
|
smuggle_url,
|
||||||
try_get,
|
try_get,
|
||||||
|
@ -21,7 +23,7 @@ from ..utils import (
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class NBCIE(AdobePassIE):
|
class NBCIE(ThePlatformIE):
|
||||||
_VALID_URL = r'https?(?P<permalink>://(?:www\.)?nbc\.com/(?:classic-tv/)?[^/]+/video/[^/]+/(?P<id>n?\d+))'
|
_VALID_URL = r'https?(?P<permalink>://(?:www\.)?nbc\.com/(?:classic-tv/)?[^/]+/video/[^/]+/(?P<id>n?\d+))'
|
||||||
|
|
||||||
_TESTS = [
|
_TESTS = [
|
||||||
|
@ -134,8 +136,13 @@ class NBCIE(AdobePassIE):
|
||||||
'mbr': 'true',
|
'mbr': 'true',
|
||||||
'manifest': 'm3u',
|
'manifest': 'm3u',
|
||||||
}
|
}
|
||||||
video_id = video_data['mpxGuid']
|
video_id = try_get(video_data, lambda x: x['mpxGuid'])
|
||||||
title = video_data['secondaryTitle']
|
if not video_id:
|
||||||
|
raise ExtractorError('Empty or no metadata from NBC GraphQL API', expected=True)
|
||||||
|
tp_path = ('NnzsPC/media/guid/%s/%s' %
|
||||||
|
(video_data.get('mpxAccountId', '2410887629'), video_id))
|
||||||
|
tpm = self._download_theplatform_metadata(tp_path, video_id)
|
||||||
|
title = tpm.get('title') or video_data['secondaryTitle']
|
||||||
if video_data.get('locked'):
|
if video_data.get('locked'):
|
||||||
resource = self._get_mvpd_resource(
|
resource = self._get_mvpd_resource(
|
||||||
video_data.get('resourceId') or 'nbcentertainment',
|
video_data.get('resourceId') or 'nbcentertainment',
|
||||||
|
@ -145,17 +152,27 @@ class NBCIE(AdobePassIE):
|
||||||
theplatform_url = smuggle_url(update_url_query(
|
theplatform_url = smuggle_url(update_url_query(
|
||||||
'http://link.theplatform.com/s/NnzsPC/media/guid/%s/%s' % (video_data.get('mpxAccountId') or '2410887629', video_id),
|
'http://link.theplatform.com/s/NnzsPC/media/guid/%s/%s' % (video_data.get('mpxAccountId') or '2410887629', video_id),
|
||||||
query), {'force_smil_url': True})
|
query), {'force_smil_url': True})
|
||||||
|
episode_number = int_or_none(
|
||||||
|
video_data.get('episodeNumber'),
|
||||||
|
default=int_or_none(tpm.get('nbcu$airOrder')))
|
||||||
|
rating = video_data.get('rating',
|
||||||
|
try_get(tpm, lambda x: x['ratings'][0]['rating']))
|
||||||
|
season_number = int_or_none(
|
||||||
|
video_data.get('seasonNumber'),
|
||||||
|
default=int_or_none(tpm.get('nbcu$seasonNumber')))
|
||||||
|
series = video_data.get('seriesShortTitle', tpm.get('nbcu$seriesShortTitle'))
|
||||||
return {
|
return {
|
||||||
'_type': 'url_transparent',
|
'_type': 'url_transparent',
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'title': title,
|
'title': title,
|
||||||
'url': theplatform_url,
|
'url': theplatform_url,
|
||||||
'description': video_data.get('description'),
|
'description': video_data.get('description') or tpm.get('description'),
|
||||||
'tags': video_data.get('keywords'),
|
'tags': video_data.get('keywords') or tpm.get('keywords'),
|
||||||
'season_number': int_or_none(video_data.get('seasonNumber')),
|
'season_number': season_number,
|
||||||
'episode_number': int_or_none(video_data.get('episodeNumber')),
|
'episode_number': episode_number,
|
||||||
'episode': title,
|
'episode': title,
|
||||||
'series': video_data.get('seriesShortTitle'),
|
'series': series,
|
||||||
|
'age_limit': parse_age_limit(rating),
|
||||||
'ie_key': 'ThePlatform',
|
'ie_key': 'ThePlatform',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -389,7 +406,6 @@ class NBCNewsIE(ThePlatformIE):
|
||||||
]
|
]
|
||||||
|
|
||||||
def _old_real_extract(self, url, video_id, webpage=None):
|
def _old_real_extract(self, url, video_id, webpage=None):
|
||||||
print url
|
|
||||||
if not webpage:
|
if not webpage:
|
||||||
webpage = self._download_webpage(url, video_id)
|
webpage = self._download_webpage(url, video_id)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue