mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-14 03:11:24 +01:00
Compare commits
No commits in common. "cb875582a7c228c6bde3537ab7cb3859f2a684f3" and "e9117f0bab990ad43c1a94b3c388bc7d10437b6b" have entirely different histories.
cb875582a7
...
e9117f0bab
|
@ -1,5 +1,5 @@
|
|||
import base64
|
||||
import random
|
||||
import secrets
|
||||
import urllib.parse
|
||||
|
||||
from .common import InfoExtractor
|
||||
|
@ -70,9 +70,9 @@ class RadikoBaseIE(InfoExtractor):
|
|||
def _auth_client(self):
|
||||
cachedata = self.cache.load('radiko', 'auth_data')
|
||||
if cachedata is not None:
|
||||
response = self._download_webpage(
|
||||
'https://radiko.jp/v2/api/auth_check', None, 'Checking cached token', expected_status=401,
|
||||
headers={'X-Radiko-AuthToken': cachedata[0], 'X-Radiko-AreaId': cachedata[1]})
|
||||
response = self._download_webpage('https://radiko.jp/v2/api/auth_check', None,
|
||||
'Checking cached token', expected_status=401,
|
||||
headers={'X-Radiko-AuthToken': cachedata[0], 'X-Radiko-AreaId': cachedata[1]})
|
||||
if response == 'OK':
|
||||
return cachedata
|
||||
return self._negotiate_token()
|
||||
|
@ -116,7 +116,7 @@ class RadikoBaseIE(InfoExtractor):
|
|||
|
||||
def _extract_formats(self, video_id, station, is_onair, ft, cursor, auth_token, area_id, query):
|
||||
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')
|
||||
|
||||
formats = []
|
||||
|
@ -128,12 +128,13 @@ class RadikoBaseIE(InfoExtractor):
|
|||
pcu = element.text
|
||||
if pcu in found:
|
||||
continue
|
||||
found.add(pcu)
|
||||
else:
|
||||
found.add(pcu)
|
||||
playlist_url = update_url_query(pcu, {
|
||||
'station_id': station,
|
||||
**query,
|
||||
'l': '15',
|
||||
'lsid': ''.join(random.choices('0123456789abcdef', k=32)),
|
||||
'lsid': secrets.token_hex(16),
|
||||
'type': 'b',
|
||||
})
|
||||
|
||||
|
@ -142,7 +143,7 @@ class RadikoBaseIE(InfoExtractor):
|
|||
domain = urllib.parse.urlparse(playlist_url).netloc
|
||||
subformats = self._extract_m3u8_formats(
|
||||
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}',
|
||||
headers={
|
||||
'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)
|
||||
|
||||
auth_token, area_id = self._auth_client()
|
||||
|
||||
return {
|
||||
'id': video_id,
|
||||
'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_id': station,
|
||||
'timestamp': vid_int,
|
||||
'is_live': True,
|
||||
'live_status': 'was_live',
|
||||
'formats': self._extract_formats(
|
||||
video_id=video_id, station=station, is_onair=False,
|
||||
ft=ft, cursor=vid_int, auth_token=auth_token, area_id=area_id,
|
||||
|
|
Loading…
Reference in New Issue
Block a user