Compare commits

..

No commits in common. "4957d590987921d0334a2d92ee295a7b08edb18d" and "906370bec7e1777a63ca0a4c78e4f402a784b59b" have entirely different histories.

View File

@ -59,23 +59,23 @@ class AsobiChannelIE(AsobiChannelBaseIE):
}, },
}] }]
_survapi_header = None def _get_survapi_header(self, video_id):
request_token = self._download_json(
def _real_initialize(self): 'https://asobichannel-api.asobistore.jp/api/v1/vspf/token', video_id,
token = self._download_json(
'https://asobichannel-api.asobistore.jp/api/v1/vspf/token', None,
note='Retrieving API token') note='Retrieving API token')
self._survapi_header = {'Authorization': f'Bearer {token}'} return {'Authorization': f'Bearer {request_token}'}
def _process_vod(self, video_id, metadata): def _process_vod(self, video_id, metadata):
content_id = metadata['contents']['video_id'] content_id = metadata['contents']['video_id']
vod_data = self._download_json( vod_data = self._download_json(
f'https://survapi.channel.or.jp/proxy/v1/contents/{content_id}/get_by_cuid', video_id, f'https://survapi.channel.or.jp/proxy/v1/contents/{content_id}/get_by_cuid', video_id,
headers=self._survapi_header, note='Downloading vod data') headers=self._get_survapi_header(video_id), note='Downloading vod data')
m3u8_url = vod_data['ex_content']['streaming_url']
return { return {
'formats': self._extract_m3u8_formats(vod_data['ex_content']['streaming_url'], video_id), 'formats': self._extract_m3u8_formats(m3u8_url, video_id),
} }
def _process_live(self, video_id, metadata): def _process_live(self, video_id, metadata):
@ -87,20 +87,19 @@ class AsobiChannelIE(AsobiChannelBaseIE):
if live_start is None: if live_start is None:
live_status = None live_status = None
elif now_ts < live_start: elif now_ts < live_start:
# live_status should be 'is_upcoming', but stream is not available at this point live_status = 'is_upcoming'
self.raise_no_formats(f'Live stream will be available at {live_start}', expected=True)
else: else:
live_status = 'is_live' live_status = 'is_live'
event_data = self._download_json( event_data = self._download_json(
f'https://survapi.channel.or.jp/ex/events/{content_id}?embed=channel', video_id, f'https://survapi.channel.or.jp/ex/events/{content_id}?embed=channel', video_id,
headers=self._survapi_header, note='Downloading event data') headers=self._get_survapi_header(video_id), note='Downloading event data')
live_url = event_data['data']['Channel']['Custom_live_url'] live_url = event_data['data']['Channel']['Custom_live_url']
return { return {
'live_status': live_status, 'live_status': live_status,
'formats': self._extract_m3u8_formats(live_url, video_id, live=True), 'formats': self._extract_m3u8_formats(live_url, video_id),
} }
def _real_extract(self, url): def _real_extract(self, url):
@ -146,7 +145,7 @@ class AsobiChannelTagURLIE(AsobiChannelBaseIE):
tag_id = self._match_id(url) tag_id = self._match_id(url)
webpage = self._download_webpage(url, tag_id) webpage = self._download_webpage(url, tag_id)
title = traverse_obj(self._search_nextjs_data(webpage, tag_id, fatal=False), ('props', 'pageProps', 'data', 'name')) webpage_data = self._search_nextjs_data(webpage, tag_id)['props']['pageProps']
media_list = self._download_json( media_list = self._download_json(
f'https://channel.microcms.io/api/v1/media?limit=999&filters=(tag[contains]{tag_id})', tag_id, f'https://channel.microcms.io/api/v1/media?limit=999&filters=(tag[contains]{tag_id})', tag_id,
@ -154,8 +153,8 @@ class AsobiChannelTagURLIE(AsobiChannelBaseIE):
entries = [{ entries = [{
'_type': 'url', '_type': 'url',
'url': f'https://asobichannel.asobistore.jp/watch/{metadata["id"]}', 'url': f'https://asobichannel.asobistore.jp/watch/{metadata['id']}',
**self._extract_info(metadata), **self._extract_info(metadata),
} for metadata in media_list.get('contents', [])] } for metadata in media_list.get('contents', [])]
return self.playlist_result(entries, tag_id, title) return self.playlist_result(entries, tag_id, traverse_obj(webpage_data, ('data', 'name')))