- channel_url = self._proto_relative_url('//tvpstream.vod.tvp.pl/?channel_id=%s' % channel_id or 'default')
- webpage = self._download_webpage(channel_url, channel_id, 'Downloading channel webpage')
- if not channel_id:
- channel_id = self._search_regex(self._PLAYER_BOX_RE % 'channel',
- webpage, 'default channel id')
- video_id = self._search_regex(self._PLAYER_BOX_RE % 'video',
- webpage, 'video id')
- audition_title, station_name = self._search_regex(
- self._BUTTON_RE % (re.escape(channel_id)), webpage,
- 'audition title and station name',
- group=(1, 2))
+ channel_url = self._proto_relative_url('//stream.tvp.pl/?channel_id=%s' % channel_id or 'default')
+ webpage = self._download_webpage(channel_url, channel_id or 'default', 'Downloading channel webpage')
+ channels = self._search_json(
+ r'window\.__channels\s*=', webpage, 'channel list', channel_id,
+ contains_pattern=r'\[\s*{(?s:.+)}\s*]')
+ channel = traverse_obj(channels, (lambda _, v: channel_id == str(v['id'])), get_all=False) if channel_id else channels[0]
+ audition = traverse_obj(channel, ('items', lambda _, v: v['is_live'] is True), get_all=False)