1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2025-09-03 00:25:08 +00:00

[extractor/npr] Implement e50c3500b4 differently

Closes #4141
This commit is contained in:
pukkandan
2022-06-23 01:42:39 +05:30
parent 28163422a6
commit 0c36dc00d7
2 changed files with 25 additions and 33 deletions

View File

@ -1,9 +1,5 @@
from .common import InfoExtractor
from ..utils import (
int_or_none,
qualities,
url_or_none,
)
from ..utils import int_or_none, qualities, traverse_obj, url_or_none
class NprIE(InfoExtractor):
@ -74,10 +70,6 @@ class NprIE(InfoExtractor):
})['list']['story'][0]
playlist_title = story.get('title', {}).get('$text')
# Fetch the JSON-LD from the npr page.
json_ld = self._search_json_ld(
self._download_webpage(url, playlist_id), playlist_id, 'NewsArticle', fatal=False)
KNOWN_FORMATS = ('threegp', 'm3u8', 'smil', 'mp4', 'mp3')
quality = qualities(KNOWN_FORMATS)
@ -124,8 +116,10 @@ class NprIE(InfoExtractor):
stream_url, stream_id, 'mp4', 'm3u8_native',
m3u8_id='hls', fatal=False))
if not formats and json_ld.get('url'):
formats.extend(self._extract_m3u8_formats(json_ld['url'], media_id, 'mp4', m3u8_id='hls', fatal=False))
if not formats:
raw_json_ld = self._yield_json_ld(self._download_webpage(url, playlist_id), playlist_id, fatal=False)
m3u8_url = traverse_obj(list(raw_json_ld), (..., 'subjectOf', ..., 'embedUrl'), get_all=False)
formats = self._extract_m3u8_formats(m3u8_url, media_id, 'mp4', m3u8_id='hls', fatal=False)
self._sort_formats(formats)