Compare commits

..

No commits in common. "cb875582a7c228c6bde3537ab7cb3859f2a684f3" and "e9117f0bab990ad43c1a94b3c388bc7d10437b6b" have entirely different histories.

View File

@ -1,5 +1,5 @@
import base64 import base64
import random import secrets
import urllib.parse import urllib.parse
from .common import InfoExtractor from .common import InfoExtractor
@ -70,8 +70,8 @@ class RadikoBaseIE(InfoExtractor):
def _auth_client(self): def _auth_client(self):
cachedata = self.cache.load('radiko', 'auth_data') cachedata = self.cache.load('radiko', 'auth_data')
if cachedata is not None: if cachedata is not None:
response = self._download_webpage( response = self._download_webpage('https://radiko.jp/v2/api/auth_check', None,
'https://radiko.jp/v2/api/auth_check', None, 'Checking cached token', expected_status=401, 'Checking cached token', expected_status=401,
headers={'X-Radiko-AuthToken': cachedata[0], 'X-Radiko-AreaId': cachedata[1]}) headers={'X-Radiko-AuthToken': cachedata[0], 'X-Radiko-AreaId': cachedata[1]})
if response == 'OK': if response == 'OK':
return cachedata return cachedata
@ -116,7 +116,7 @@ class RadikoBaseIE(InfoExtractor):
def _extract_formats(self, video_id, station, is_onair, ft, cursor, auth_token, area_id, query): def _extract_formats(self, video_id, station, is_onair, ft, cursor, auth_token, area_id, query):
m3u8_playlist_data = self._download_xml( m3u8_playlist_data = self._download_xml(
f'https://radiko.jp/v3/station/stream/pc_html5/{station}.xml', video_id, f'https://radiko.jp/v3/station/stream/aSmartPhone7a/{station}.xml', video_id,
note='Downloading stream information') note='Downloading stream information')
formats = [] formats = []
@ -128,12 +128,13 @@ class RadikoBaseIE(InfoExtractor):
pcu = element.text pcu = element.text
if pcu in found: if pcu in found:
continue continue
else:
found.add(pcu) found.add(pcu)
playlist_url = update_url_query(pcu, { playlist_url = update_url_query(pcu, {
'station_id': station, 'station_id': station,
**query, **query,
'l': '15', 'l': '15',
'lsid': ''.join(random.choices('0123456789abcdef', k=32)), 'lsid': secrets.token_hex(16),
'type': 'b', 'type': 'b',
}) })
@ -142,7 +143,7 @@ class RadikoBaseIE(InfoExtractor):
domain = urllib.parse.urlparse(playlist_url).netloc domain = urllib.parse.urlparse(playlist_url).netloc
subformats = self._extract_m3u8_formats( subformats = self._extract_m3u8_formats(
playlist_url, video_id, ext='m4a', playlist_url, video_id, ext='m4a',
live=True, fatal=False, m3u8_id=domain, fatal=False, m3u8_id=domain,
note=f'Downloading m3u8 information from {domain}', note=f'Downloading m3u8 information from {domain}',
headers={ headers={
'X-Radiko-AreaId': area_id, 'X-Radiko-AreaId': area_id,
@ -182,7 +183,6 @@ class RadikoIE(RadikoBaseIE):
prog, station_program, ft, radio_begin, radio_end = self._find_program(video_id, station, vid_int) prog, station_program, ft, radio_begin, radio_end = self._find_program(video_id, station, vid_int)
auth_token, area_id = self._auth_client() auth_token, area_id = self._auth_client()
return { return {
'id': video_id, 'id': video_id,
'title': try_call(lambda: prog.find('title').text), 'title': try_call(lambda: prog.find('title').text),
@ -190,7 +190,7 @@ class RadikoIE(RadikoBaseIE):
'uploader': try_call(lambda: station_program.find('.//name').text), 'uploader': try_call(lambda: station_program.find('.//name').text),
'uploader_id': station, 'uploader_id': station,
'timestamp': vid_int, 'timestamp': vid_int,
'is_live': True, 'live_status': 'was_live',
'formats': self._extract_formats( 'formats': self._extract_formats(
video_id=video_id, station=station, is_onair=False, video_id=video_id, station=station, is_onair=False,
ft=ft, cursor=vid_int, auth_token=auth_token, area_id=area_id, ft=ft, cursor=vid_int, auth_token=auth_token, area_id=area_id,