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',
62 'playlist_mincount': 9,
64 'url': 'https://banbye.com/watch/v_kb6_o1Kyq-CD',
66 'id': 'v_kb6_o1Kyq-CD',
68 'title': 'Co tak naprawdę dzieje się we Francji?! Czy Warszawa a potem cała Polska będzie drugim Paryżem?!🤔🇵🇱',
69 'description': 'md5:82be4c0e13eae8ea1ca8b9f2e07226a8',
70 'uploader': 'Marcin Rola - MOIM ZDANIEM!🇵🇱',
71 'channel_id': 'ch_QgWnHvDG2fo5',
72 'channel_url': 'https://banbye.com/channel/ch_QgWnHvDG2fo5',
74 'timestamp': 1688642656,
75 'upload_date': '20230706',
76 'thumbnail': 'https://cdn.banbye.com/video/v_kb6_o1Kyq-CD/96.webp',
77 'tags': ['Paryż', 'Francja', 'Polska', 'Imigranci', 'Morawiecki', 'Tusk'],
85 def _real_extract(self
, url
):
86 video_id
= self
._match
_id
(url
)
87 playlist_id
= self
._extract
_playlist
_id
(url
, 'playlistId')
89 if self
._yes
_playlist
(playlist_id
, video_id
):
90 return self
._extract
_playlist
(playlist_id
)
92 data
= self
._download
_json
(f
'{self._API_BASE}/videos/{video_id}', video_id
)
95 'url': f
'{self._CDN_BASE}/video/{video_id}/{quality}.webp',
96 } for quality
in [48, 96, 144, 240, 512, 1080]]
98 'format_id': f
'http-{quality}p',
100 'url': f
'{self._CDN_BASE}/video/{video_id}/{quality}.mp4',
101 } for quality
in data
['quality']]
105 'title': data
.get('title'),
106 'description': data
.get('desc'),
107 'uploader': traverse_obj(data
, ('channel', 'name')),
108 'channel_id': data
.get('channelId'),
109 'channel_url': format_field(data
, 'channelId', 'https://banbye.com/channel/%s'),
110 'timestamp': unified_timestamp(data
.get('publishedAt')),
111 'duration': data
.get('duration'),
112 'tags': data
.get('tags'),
114 'thumbnails': thumbnails
,
115 'like_count': data
.get('likes'),
116 'dislike_count': data
.get('dislikes'),
117 'view_count': data
.get('views'),
118 'comment_count': data
.get('commentCount'),
122 class BanByeChannelIE(BanByeBaseIE
):
123 _VALID_URL
= r
'https?://(?:www\.)?banbye\.com/(?:en/)?channel/(?P<id>\w+)'
125 'url': 'https://banbye.com/channel/ch_wrealu24',
129 'description': 'md5:da54e48416b74dfdde20a04867c0c2f6',
131 'playlist_mincount': 791,
133 'url': 'https://banbye.com/channel/ch_wrealu24?playlist=p_Ld82N6gBw_OJ',
135 'title': 'Krzysztof Karoń',
136 'id': 'p_Ld82N6gBw_OJ',
142 def _real_extract(self
, url
):
143 channel_id
= self
._match
_id
(url
)
144 playlist_id
= self
._extract
_playlist
_id
(url
)
147 return self
._extract
_playlist
(playlist_id
)
149 def page_func(page_num
):
150 data
= self
._download
_json
(f
'{self._API_BASE}/videos', channel_id
, query
={
151 'channelId': channel_id
,
153 'limit': self
._PAGE
_SIZE
,
154 'offset': page_num
* self
._PAGE
_SIZE
,
155 }, note
=f
'Downloading page {page_num+1}')
157 self
.url_result(f
"{self._VIDEO_BASE}/{video['_id']}", BanByeIE
)
158 for video
in data
['items']
161 channel_data
= self
._download
_json
(f
'{self._API_BASE}/channels/{channel_id}', channel_id
)
162 entries
= InAdvancePagedList(
164 math
.ceil(channel_data
['videoCount'] / self
._PAGE
_SIZE
),
167 return self
.playlist_result(
168 entries
, channel_id
, channel_data
.get('name'), channel_data
.get('description'))