mirror of
https://github.com/l1ving/youtube-dl
synced 2025-02-03 09:52:51 +08:00
[zattoo] Improve extraction of channel id
This commit is contained in:
parent
dac1f63e3e
commit
3f66fa4f99
@ -87,22 +87,22 @@ class ZattooBaseIE(InfoExtractor):
|
|||||||
return 'uuid=%s; beaker.session.id=%s' % (uuid, session_id)
|
return 'uuid=%s; beaker.session.id=%s' % (uuid, session_id)
|
||||||
return 'uuid=%s; beaker.session.id=%s; pzuid=%s' % (uuid, session_id, pzuid)
|
return 'uuid=%s; beaker.session.id=%s; pzuid=%s' % (uuid, session_id, pzuid)
|
||||||
|
|
||||||
def _get_channels_display_cid(self, login_info, video_id):
|
def _extract_cid(self, video_id, channel_name):
|
||||||
data = self._download_json(
|
channel_groups = self._download_json(
|
||||||
'%s/zapi/v2/cached/channels/%s' % (self._HOST_URL,
|
'%s/zapi/v2/cached/channels/%s' % (self._HOST_URL,
|
||||||
login_info['powerhash']),
|
self._login_info['powerhash']),
|
||||||
video_id,
|
video_id,
|
||||||
'Downloading available channel list',
|
'Downloading available channel list',
|
||||||
query={'details': False})
|
query={'details': False})['channel_groups']
|
||||||
display_cid = {}
|
channel_list = []
|
||||||
for elem in data['channel_groups']:
|
for chgrp in channel_groups:
|
||||||
for channel in elem['channels']:
|
channel_list.extend(chgrp['channels'])
|
||||||
display_cid[channel['display_alias']] = channel['cid']
|
try:
|
||||||
return display_cid
|
return next(chan['cid'] for chan in channel_list if
|
||||||
|
chan['display_alias'] == channel_name or
|
||||||
def _extract_cid(self, login_info, video_id, channel_name):
|
chan['cid'] == channel_name)
|
||||||
display_cid = self._get_channels_display_cid(login_info, video_id)
|
except StopIteration:
|
||||||
return display_cid[channel_name]
|
raise ExtractorError('Could not extract channel id')
|
||||||
|
|
||||||
def _extract_cid_and_video_info(self, video_id):
|
def _extract_cid_and_video_info(self, video_id):
|
||||||
data = self._download_json(
|
data = self._download_json(
|
||||||
@ -190,7 +190,7 @@ class ZattooBaseIE(InfoExtractor):
|
|||||||
|
|
||||||
def _extract_video(self, channel_name, video_id, is_live=False):
|
def _extract_video(self, channel_name, video_id, is_live=False):
|
||||||
if is_live:
|
if is_live:
|
||||||
cid = self._extract_cid(self._login_info, video_id, channel_name)
|
cid = self._extract_cid(video_id, channel_name)
|
||||||
info_dict = {
|
info_dict = {
|
||||||
'id': channel_name,
|
'id': channel_name,
|
||||||
'title': self._live_title(channel_name),
|
'title': self._live_title(channel_name),
|
||||||
|
Loading…
Reference in New Issue
Block a user