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 status
= traverse_obj(player_meta
, ('initial_event_info', 'status', {str}
))
70 live_status
, msg
, expected
= {
71 'vod': ('was_live', 'No VOD stream URL was found', False),
72 'archiving': ('post_live', 'Event VOD is still being processed', True),
73 'deleting': ('post_live', 'This event has ended', True),
74 'deleted': ('post_live', 'This event has ended', True),
75 'error': ('post_live', 'This event has ended', True),
76 'disconnected': ('post_live', 'Stream has been disconnected', True),
77 'live_to_disconnected': ('post_live', 'Stream has been disconnected', True),
78 'live': ('is_live', 'No livestream URL found was found', False),
79 'waiting': ('is_upcoming', 'Live event has not yet started', True),
80 'cancelled': ('not_live', 'Event has been cancelled', True),
81 }.get(status
) or ('not_live', f
'Unknown event status "{status}"', False)
83 stream_url
= traverse_obj(player_meta
, ('initial_event_info', 'endpoint', {url_or_none}
))
84 formats
= self
._extract
_m
3u8_formats
(
85 stream_url
, video_id
, live
=True, fatal
=False) if stream_url
else []
87 self
.raise_no_formats(msg
, expected
=expected
)
90 traverse_obj(player_meta
, ('initial_event_info', 'poster_url')),
91 self
._og
_search
_thumbnail
(self
._download
_webpage
(
92 f
'https://zaiko.io/event/{video_id}', video_id
, 'Downloading event page', fatal
=False) or ''),
98 'live_status': live_status
,
99 **traverse_obj(stream_meta
, {
100 'title': ('event', 'name', {str}
),
101 'uploader': ('profile', 'name', {str}
),
102 'uploader_id': ('profile', 'id', {str_or_none}
),
103 'release_timestamp': ('stream', 'start', 'timestamp', {int_or_none}
),
104 'categories': ('event', 'genres', ..., {lambda x: x or None}
),
106 **traverse_obj(player_meta
, ('initial_event_info', {
107 'alt_title': ('title', {str}
),
109 'thumbnails': [{'url': url, 'id': url_basename(url)}
for url
in thumbnail_urls
if url_or_none(url
)]
113 class ZaikoETicketIE(ZaikoBaseIE
):
114 _VALID_URL
= r
'https?://(?:www.)?zaiko\.io/account/eticket/(?P<id>[\w=-]{49})'
116 'url': 'https://zaiko.io/account/eticket/TZjMwMzQ2Y2EzMXwyMDIzMDYwNzEyMTMyNXw1MDViOWU2Mw==',
119 'id': 'f30346ca31-20230607121325-505b9e63',
120 'title': 'ZAIKO STREAMING TEST',
121 'thumbnail': 'https://media.zkocdn.net/pf_1/1_3wdyjcjyupseatkwid34u',
123 'skip': 'Only available with the ticketholding account',
126 def _real_extract(self
, url
):
127 ticket_id
= self
._match
_id
(url
)
128 ticket_id
= try_call(
129 lambda: base64
.urlsafe_b64decode(ticket_id
[1:]).decode().replace('|', '-')) or ticket_id
131 webpage
= self
._download
_real
_webpage
(url
, ticket_id
)
132 eticket
= self
._parse
_vue
_element
_attr
('eticket', webpage
, ticket_id
)
134 return self
.playlist_result(
135 [self
.url_result(stream
, ZaikoIE
) for stream
in traverse_obj(eticket
, ('streams', ..., 'url'))],
136 ticket_id
, **traverse_obj(eticket
, ('ticket-details', {
137 'title': 'event_name',
138 'thumbnail': 'event_img_url',