]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/banbye.py
4 from .common
import InfoExtractor
13 class BanByeBaseIE(InfoExtractor
):
14 _API_BASE
= 'https://api.banbye.com'
15 _CDN_BASE
= 'https://cdn.banbye.com'
16 _VIDEO_BASE
= 'https://banbye.com/watch'
19 def _extract_playlist_id(url
, param
='playlist'):
20 return urllib
.parse
.parse_qs(
21 urllib
.parse
.urlparse(url
).query
).get(param
, [None])[0]
23 def _extract_playlist(self
, playlist_id
):
24 data
= self
._download
_json
(f
'{self._API_BASE}/playlists/{playlist_id}', playlist_id
)
25 return self
.playlist_result([
26 self
.url_result(f
'{self._VIDEO_BASE}/{video_id}', BanByeIE
)
27 for video_id
in data
['videoIds']], playlist_id
, data
.get('name'))
30 class BanByeIE(BanByeBaseIE
):
31 _VALID_URL
= r
'https?://(?:www\.)?banbye\.com/(?:en/)?watch/(?P<id>[\w-]+)'
33 'url': 'https://banbye.com/watch/v_ytfmvkVYLE8T',
34 'md5': '2f4ea15c5ca259a73d909b2cfd558eb5',
36 'id': 'v_ytfmvkVYLE8T',
38 'title': 'md5:5ec098f88a0d796f987648de6322ba0f',
39 'description': 'md5:4d94836e73396bc18ef1fa0f43e5a63a',
40 'uploader': 'wRealu24',
41 'channel_id': 'ch_wrealu24',
42 'channel_url': 'https://banbye.com/channel/ch_wrealu24',
43 'timestamp': 1647604800,
44 'upload_date': '20220318',
46 'thumbnail': r
're:https?://.*\.webp',
54 'url': 'https://banbye.com/watch/v_2JjQtqjKUE_F?playlistId=p_Ld82N6gBw_OJ',
56 'title': 'Krzysztof Karoń',
57 'id': 'p_Ld82N6gBw_OJ',
59 'playlist_mincount': 9,
61 'url': 'https://banbye.com/watch/v_kb6_o1Kyq-CD',
63 'id': 'v_kb6_o1Kyq-CD',
65 'title': 'Co tak naprawdę dzieje się we Francji?! Czy Warszawa a potem cała Polska będzie drugim Paryżem?!🤔🇵🇱',
66 'description': 'md5:82be4c0e13eae8ea1ca8b9f2e07226a8',
67 'uploader': 'Marcin Rola - MOIM ZDANIEM!🇵🇱',
68 'channel_id': 'ch_QgWnHvDG2fo5',
69 'channel_url': 'https://banbye.com/channel/ch_QgWnHvDG2fo5',
71 'timestamp': 1688642656,
72 'upload_date': '20230706',
73 'thumbnail': 'https://cdn.banbye.com/video/v_kb6_o1Kyq-CD/96.webp',
74 'tags': ['Paryż', 'Francja', 'Polska', 'Imigranci', 'Morawiecki', 'Tusk'],
82 def _real_extract(self
, url
):
83 video_id
= self
._match
_id
(url
)
84 playlist_id
= self
._extract
_playlist
_id
(url
, 'playlistId')
86 if self
._yes
_playlist
(playlist_id
, video_id
):
87 return self
._extract
_playlist
(playlist_id
)
89 data
= self
._download
_json
(f
'{self._API_BASE}/videos/{video_id}', video_id
)
92 'url': f
'{self._CDN_BASE}/video/{video_id}/{quality}.webp',
93 } for quality
in [48, 96, 144, 240, 512, 1080]]
95 'format_id': f
'http-{quality}p',
97 'url': f
'{self._CDN_BASE}/video/{video_id}/{quality}.mp4',
98 } for quality
in data
['quality']]
102 'title': data
.get('title'),
103 'description': data
.get('desc'),
104 'uploader': traverse_obj(data
, ('channel', 'name')),
105 'channel_id': data
.get('channelId'),
106 'channel_url': format_field(data
, 'channelId', 'https://banbye.com/channel/%s'),
107 'timestamp': unified_timestamp(data
.get('publishedAt')),
108 'duration': data
.get('duration'),
109 'tags': data
.get('tags'),
111 'thumbnails': thumbnails
,
112 'like_count': data
.get('likes'),
113 'dislike_count': data
.get('dislikes'),
114 'view_count': data
.get('views'),
115 'comment_count': data
.get('commentCount'),
119 class BanByeChannelIE(BanByeBaseIE
):
120 _VALID_URL
= r
'https?://(?:www\.)?banbye\.com/(?:en/)?channel/(?P<id>\w+)'
122 'url': 'https://banbye.com/channel/ch_wrealu24',
126 'description': 'md5:da54e48416b74dfdde20a04867c0c2f6',
128 'playlist_mincount': 791,
130 'url': 'https://banbye.com/channel/ch_wrealu24?playlist=p_Ld82N6gBw_OJ',
132 'title': 'Krzysztof Karoń',
133 'id': 'p_Ld82N6gBw_OJ',
139 def _real_extract(self
, url
):
140 channel_id
= self
._match
_id
(url
)
141 playlist_id
= self
._extract
_playlist
_id
(url
)
144 return self
._extract
_playlist
(playlist_id
)
146 def page_func(page_num
):
147 data
= self
._download
_json
(f
'{self._API_BASE}/videos', channel_id
, query
={
148 'channelId': channel_id
,
150 'limit': self
._PAGE
_SIZE
,
151 'offset': page_num
* self
._PAGE
_SIZE
,
152 }, note
=f
'Downloading page {page_num + 1}')
154 self
.url_result(f
"{self._VIDEO_BASE}/{video['_id']}", BanByeIE
)
155 for video
in data
['items']
158 channel_data
= self
._download
_json
(f
'{self._API_BASE}/channels/{channel_id}', channel_id
)
159 entries
= InAdvancePagedList(
161 math
.ceil(channel_data
['videoCount'] / self
._PAGE
_SIZE
),
164 return self
.playlist_result(
165 entries
, channel_id
, channel_data
.get('name'), channel_data
.get('description'))