mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2026-01-01 04:21:25 +00:00
[RadioFrance] Include exception case for missing metadata
This commit is contained in:
@@ -6,13 +6,13 @@ from ..utils import (
|
|||||||
join_nonempty,
|
join_nonempty,
|
||||||
js_to_json,
|
js_to_json,
|
||||||
parse_duration,
|
parse_duration,
|
||||||
|
RegexNotFoundError,
|
||||||
strftime_or_none,
|
strftime_or_none,
|
||||||
traverse_obj,
|
traverse_obj,
|
||||||
unified_strdate,
|
unified_strdate,
|
||||||
urljoin,
|
urljoin,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class RadioFranceIE(InfoExtractor):
|
class RadioFranceIE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://maison\.radiofrance\.fr/radiovisions/(?P<id>[^?#]+)'
|
_VALID_URL = r'https?://maison\.radiofrance\.fr/radiovisions/(?P<id>[^?#]+)'
|
||||||
IE_NAME = 'radiofrance'
|
IE_NAME = 'radiofrance'
|
||||||
@@ -286,7 +286,12 @@ class RadioFrancePlaylistBaseIE(RadioFranceBaseIE):
|
|||||||
for linkkey in links:
|
for linkkey in links:
|
||||||
url = self._search_regex(linkkey + r'\.url="([^"]+)";', webpage, content_id)
|
url = self._search_regex(linkkey + r'\.url="([^"]+)";', webpage, content_id)
|
||||||
dur = int(self._search_regex(linkkey + r'\.duration=(\d+);', webpage, content_id))
|
dur = int(self._search_regex(linkkey + r'\.duration=(\d+);', webpage, content_id))
|
||||||
preset = self._search_json(linkkey + r'\.preset=', webpage, content_id, content_id, contains_pattern=r'\{.+\}', transform_source=js_to_json)
|
# Preset describes the audio encoding. Some episodes will be missing a 'preset', simply stating 'null'
|
||||||
|
# In this case, give a generic response
|
||||||
|
try:
|
||||||
|
preset = self._search_json(linkkey + r'\.preset=', webpage, content_id, content_id, contains_pattern=r'\{.+\}', transform_source=js_to_json)
|
||||||
|
except RegexNotFoundError:
|
||||||
|
preset = {"id": "999", "name": "unknown format", "encoding": "unknown", "bitrate": "unknown"}
|
||||||
item['formats'].append({
|
item['formats'].append({
|
||||||
'format_id': preset['id'],
|
'format_id': preset['id'],
|
||||||
'url': url,
|
'url': url,
|
||||||
|
|||||||
Reference in New Issue
Block a user