aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaster <roadmasternavi@gmail.com>2023-02-11 19:24:10 +0900
committerGitHub <noreply@github.com>2023-02-11 19:24:10 +0900
commit203a06f8554df6db07d8f20f465ecbfe8a14e591 (patch)
treea6d78355414f210c6fda826663a55ccbda571662
parent6839ae1f6dde4c0442619e351b3f0442312ab4f9 (diff)
downloadhypervideo-pre-203a06f8554df6db07d8f20f465ecbfe8a14e591.tar.lz
hypervideo-pre-203a06f8554df6db07d8f20f465ecbfe8a14e591.tar.xz
hypervideo-pre-203a06f8554df6db07d8f20f465ecbfe8a14e591.zip
[extractor/radiko] Fix format sorting for Time Free (#6159)
Authored by: road-master
-rw-r--r--yt_dlp/extractor/radiko.py29
1 files changed, 23 insertions, 6 deletions
diff --git a/yt_dlp/extractor/radiko.py b/yt_dlp/extractor/radiko.py
index f10292203..43eecba5f 100644
--- a/yt_dlp/extractor/radiko.py
+++ b/yt_dlp/extractor/radiko.py
@@ -1,5 +1,4 @@
import base64
-import re
import urllib.parse
from .common import InfoExtractor
@@ -15,6 +14,23 @@ from ..utils import (
class RadikoBaseIE(InfoExtractor):
_FULL_KEY = None
+ _HOSTS_FOR_TIME_FREE_FFMPEG_UNSUPPORTED = (
+ 'https://c-rpaa.smartstream.ne.jp',
+ 'https://si-c-radiko.smartstream.ne.jp',
+ 'https://tf-f-rpaa-radiko.smartstream.ne.jp',
+ 'https://tf-c-rpaa-radiko.smartstream.ne.jp',
+ 'https://si-f-radiko.smartstream.ne.jp',
+ 'https://rpaa.smartstream.ne.jp',
+ )
+ _HOSTS_FOR_TIME_FREE_FFMPEG_SUPPORTED = (
+ 'https://rd-wowza-radiko.radiko-cf.com',
+ 'https://radiko.jp',
+ 'https://f-radiko.smartstream.ne.jp',
+ )
+ # Following URL forcibly connects not Time Free but Live
+ _HOSTS_FOR_LIVE = (
+ 'https://c-radiko.smartstream.ne.jp',
+ )
def _auth_client(self):
_, auth1_handle = self._download_webpage_handle(
@@ -92,9 +108,9 @@ class RadikoBaseIE(InfoExtractor):
formats = []
found = set()
for url_tag in m3u8_urls:
- pcu = url_tag.find('playlist_create_url')
+ pcu = url_tag.find('playlist_create_url').text
url_attrib = url_tag.attrib
- playlist_url = update_url_query(pcu.text, {
+ playlist_url = update_url_query(pcu, {
'station_id': station,
**query,
'l': '15',
@@ -117,10 +133,11 @@ class RadikoBaseIE(InfoExtractor):
'X-Radiko-AreaId': area_id,
'X-Radiko-AuthToken': auth_token,
})
+ not_preferred = is_onair and not pcu.startswith(self._HOSTS_FOR_LIVE) or (not is_onair and (pcu.startswith(self._HOSTS_FOR_TIME_FREE_FFMPEG_UNSUPPORTED) or pcu.startswith(self._HOSTS_FOR_LIVE)))
for sf in subformats:
- if re.fullmatch(r'[cf]-radiko\.smartstream\.ne\.jp', domain):
- # Prioritize live radio vs playback based on extractor
- sf['preference'] = 100 if is_onair else -100
+ if not_preferred:
+ sf['preference'] = -100
+ sf['format_note'] = 'not preferred'
if not is_onair and url_attrib['timefree'] == '1' and time_to_skip:
sf['downloader_options'] = {'ffmpeg_args': ['-ss', time_to_skip]}
formats.extend(subformats)