3 from .common
import InfoExtractor
5 compat_urllib_parse_urlparse
,
16 class BanByeBaseIE(InfoExtractor
):
17 _API_BASE
= 'https://api.banbye.com'
18 _CDN_BASE
= 'https://cdn.banbye.com'
19 _VIDEO_BASE
= 'https://banbye.com/watch'
22 def _extract_playlist_id(url
, param
='playlist'):
23 return compat_parse_qs(
24 compat_urllib_parse_urlparse(url
).query
).get(param
, [None])[0]
26 def _extract_playlist(self
, playlist_id
):
27 data
= self
._download
_json
(f
'{self._API_BASE}/playlists/{playlist_id}', playlist_id
)
28 return self
.playlist_result([
29 self
.url_result(f
'{self._VIDEO_BASE}/{video_id}', BanByeIE
)
30 for video_id
in data
['videoIds']], playlist_id
, data
.get('name'))
33 class BanByeIE(BanByeBaseIE
):
34 _VALID_URL
= r
'https?://(?:www\.)?banbye.com/(?:en/)?watch/(?P<id>\w+)'
36 'url': 'https://banbye.com/watch/v_ytfmvkVYLE8T',
37 'md5': '2f4ea15c5ca259a73d909b2cfd558eb5',
39 'id': 'v_ytfmvkVYLE8T',
41 'title': 'md5:5ec098f88a0d796f987648de6322ba0f',
42 'description': 'md5:4d94836e73396bc18ef1fa0f43e5a63a',
43 'uploader': 'wRealu24',
44 'channel_id': 'ch_wrealu24',
45 'channel_url': 'https://banbye.com/channel/ch_wrealu24',
46 'timestamp': 1647604800,
47 'upload_date': '20220318',
49 'thumbnail': r
're:https?://.*\.webp',
57 'url': 'https://banbye.com/watch/v_2JjQtqjKUE_F?playlistId=p_Ld82N6gBw_OJ',
59 'title': 'Krzysztof Karoń',
60 'id': 'p_Ld82N6gBw_OJ',
65 def _real_extract(self
, url
):
66 video_id
= self
._match
_id
(url
)
67 playlist_id
= self
._extract
_playlist
_id
(url
, 'playlistId')
69 if self
._yes
_playlist
(playlist_id
, video_id
):
70 return self
._extract
_playlist
(playlist_id
)
72 data
= self
._download
_json
(f
'{self._API_BASE}/videos/{video_id}', video_id
)
75 'url': f
'{self._CDN_BASE}/video/{video_id}/{quality}.webp',
76 } for quality
in [48, 96, 144, 240, 512, 1080]]
78 'format_id': f
'http-{quality}p',
80 'url': f
'{self._CDN_BASE}/video/{video_id}/{quality}.mp4',
81 } for quality
in data
['quality']]
83 self
._sort
_formats
(formats
)
87 'title': data
.get('title'),
88 'description': data
.get('desc'),
89 'uploader': traverse_obj(data
, ('channel', 'name')),
90 'channel_id': data
.get('channelId'),
91 'channel_url': format_field(data
, 'channelId', 'https://banbye.com/channel/%s'),
92 'timestamp': unified_timestamp(data
.get('publishedAt')),
93 'duration': data
.get('duration'),
94 'tags': data
.get('tags'),
96 'thumbnails': thumbnails
,
97 'like_count': data
.get('likes'),
98 'dislike_count': data
.get('dislikes'),
99 'view_count': data
.get('views'),
100 'comment_count': data
.get('commentCount'),
104 class BanByeChannelIE(BanByeBaseIE
):
105 _VALID_URL
= r
'https?://(?:www\.)?banbye.com/(?:en/)?channel/(?P<id>\w+)'
107 'url': 'https://banbye.com/channel/ch_wrealu24',
111 'description': 'md5:da54e48416b74dfdde20a04867c0c2f6',
113 'playlist_mincount': 791,
115 'url': 'https://banbye.com/channel/ch_wrealu24?playlist=p_Ld82N6gBw_OJ',
117 'title': 'Krzysztof Karoń',
118 'id': 'p_Ld82N6gBw_OJ',
124 def _real_extract(self
, url
):
125 channel_id
= self
._match
_id
(url
)
126 playlist_id
= self
._extract
_playlist
_id
(url
)
129 return self
._extract
_playlist
(playlist_id
)
131 def page_func(page_num
):
132 data
= self
._download
_json
(f
'{self._API_BASE}/videos', channel_id
, query
={
133 'channelId': channel_id
,
135 'limit': self
._PAGE
_SIZE
,
136 'offset': page_num
* self
._PAGE
_SIZE
,
137 }, note
=f
'Downloading page {page_num+1}')
139 self
.url_result(f
"{self._VIDEO_BASE}/{video['_id']}", BanByeIE
)
140 for video
in data
['items']
143 channel_data
= self
._download
_json
(f
'{self._API_BASE}/channels/{channel_id}', channel_id
)
144 entries
= InAdvancePagedList(
146 math
.ceil(channel_data
['videoCount'] / self
._PAGE
_SIZE
),
149 return self
.playlist_result(
150 entries
, channel_id
, channel_data
.get('name'), channel_data
.get('description'))