3 from .common
import InfoExtractor
17 class ZaikoBaseIE(InfoExtractor
):
18 def _download_real_webpage(self
, url
, video_id
):
19 webpage
, urlh
= self
._download
_webpage
_handle
(url
, video_id
)
21 if 'zaiko.io/login' in final_url
:
22 self
.raise_login_required()
23 elif '/_buy/' in final_url
:
24 raise ExtractorError('Your account does not have tickets to this event', expected
=True)
27 def _parse_vue_element_attr(self
, name
, string
, video_id
):
28 page_elem
= self
._search
_regex
(rf
'(<{name}[^>]+>)', string
, name
)
30 for key
, value
in extract_attributes(page_elem
).items():
31 if key
.startswith(':'):
32 attrs
[key
[1:]] = self
._parse
_json
(
33 value
, video_id
, transform_source
=unescapeHTML
, fatal
=False)
37 class ZaikoIE(ZaikoBaseIE
):
38 _VALID_URL
= r
'https?://(?:[\w-]+\.)?zaiko\.io/event/(?P<id>\d+)/stream(?:/\d+)+'
40 'url': 'https://zaiko.io/event/324868/stream/20571/20571',
44 'title': 'ZAIKO STREAMING TEST',
45 'alt_title': '[VOD] ZAIKO STREAMING TEST_20210603(Do Not Delete)',
47 'uploader': 'ZAIKO ZERO',
48 'release_timestamp': 1583809200,
49 'thumbnail': r
're:^https://[\w.-]+/\w+/\w+',
50 'thumbnails': 'maxcount:2',
51 'release_date': '20200310',
52 'categories': ['Tech House'],
53 'live_status': 'was_live',
55 'params': {'skip_download': 'm3u8'},
56 'skip': 'Your account does not have tickets to this event',
59 def _real_extract(self
, url
):
60 video_id
= self
._match
_id
(url
)
62 webpage
= self
._download
_real
_webpage
(url
, video_id
)
63 stream_meta
= self
._parse
_vue
_element
_attr
('stream-page', webpage
, video_id
)
65 player_page
= self
._download
_webpage
(
66 stream_meta
['stream-access']['video_source'], video_id
,
67 'Downloading player page', headers
={'referer': 'https://zaiko.io/'})
68 player_meta
= self
._parse
_vue
_element
_attr
('player', player_page
, video_id
)
69 initial_event_info
= traverse_obj(player_meta
, ('initial_event_info', {dict}
)) or {}
71 status
= traverse_obj(initial_event_info
, ('status', {str}
))
72 live_status
, msg
, expected
= {
73 'vod': ('was_live', 'No VOD stream URL was found', False),
74 'archiving': ('post_live', 'Event VOD is still being processed', True),
75 'deleting': ('post_live', 'This event has ended', True),
76 'deleted': ('post_live', 'This event has ended', True),
77 'error': ('post_live', 'This event has ended', True),
78 'disconnected': ('post_live', 'Stream has been disconnected', True),
79 'live_to_disconnected': ('post_live', 'Stream has been disconnected', True),
80 'live': ('is_live', 'No livestream URL found was found', False),
81 'waiting': ('is_upcoming', 'Live event has not yet started', True),
82 'cancelled': ('not_live', 'Event has been cancelled', True),
83 }.get(status
) or ('not_live', f
'Unknown event status "{status}"', False)
85 if traverse_obj(initial_event_info
, ('is_jwt_protected', {bool}
)):
86 stream_url
= self
._download
_json
(
87 initial_event_info
['jwt_token_url'], video_id
, 'Downloading JWT-protected stream URL',
88 'Failed to download JWT-protected stream URL')['playback_url']
90 stream_url
= traverse_obj(initial_event_info
, ('endpoint', {url_or_none}
))
92 formats
= self
._extract
_m
3u8_formats
(
93 stream_url
, video_id
, live
=True, fatal
=False) if stream_url
else []
95 self
.raise_no_formats(msg
, expected
=expected
)
98 traverse_obj(initial_event_info
, ('poster_url', {url_or_none}
)),
99 self
._og
_search
_thumbnail
(self
._download
_webpage
(
100 f
'https://zaiko.io/event/{video_id}', video_id
, 'Downloading event page', fatal
=False) or ''),
106 'live_status': live_status
,
107 **traverse_obj(stream_meta
, {
108 'title': ('event', 'name', {str}
),
109 'uploader': ('profile', 'name', {str}
),
110 'uploader_id': ('profile', 'id', {str_or_none}
),
111 'release_timestamp': ('stream', 'start', 'timestamp', {int_or_none}
),
112 'categories': ('event', 'genres', ..., filter),
114 'alt_title': traverse_obj(initial_event_info
, ('title', {str}
)),
115 'thumbnails': [{'url': url
, 'id': url_basename(url
)} for url
in thumbnail_urls
if url_or_none(url
)],
119 class ZaikoETicketIE(ZaikoBaseIE
):
120 _VALID_URL
= r
'https?://(?:www.)?zaiko\.io/account/eticket/(?P<id>[\w=-]{49})'
122 'url': 'https://zaiko.io/account/eticket/TZjMwMzQ2Y2EzMXwyMDIzMDYwNzEyMTMyNXw1MDViOWU2Mw==',
125 'id': 'f30346ca31-20230607121325-505b9e63',
126 'title': 'ZAIKO STREAMING TEST',
127 'thumbnail': 'https://media.zkocdn.net/pf_1/1_3wdyjcjyupseatkwid34u',
129 'skip': 'Only available with the ticketholding account',
132 def _real_extract(self
, url
):
133 ticket_id
= self
._match
_id
(url
)
134 ticket_id
= try_call(
135 lambda: base64
.urlsafe_b64decode(ticket_id
[1:]).decode().replace('|', '-')) or ticket_id
137 webpage
= self
._download
_real
_webpage
(url
, ticket_id
)
138 eticket
= self
._parse
_vue
_element
_attr
('eticket', webpage
, ticket_id
)
140 return self
.playlist_result(
141 [self
.url_result(stream
, ZaikoIE
) for stream
in traverse_obj(eticket
, ('streams', ..., 'url'))],
142 ticket_id
, **traverse_obj(eticket
, ('ticket-details', {
143 'title': 'event_name',
144 'thumbnail': 'event_img_url',