summaryrefslogtreecommitdiffstats
path: root/yt_dlp/extractor/bigo.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 16:49:24 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 16:49:24 +0000
commit2415e66f889f38503b73e8ebc5f43ca342390e5c (patch)
treeac48ab69d1d96bae3d83756134921e0d90593aa5 /yt_dlp/extractor/bigo.py
parentInitial commit. (diff)
downloadyt-dlp-2415e66f889f38503b73e8ebc5f43ca342390e5c.tar.xz
yt-dlp-2415e66f889f38503b73e8ebc5f43ca342390e5c.zip
Adding upstream version 2024.03.10.upstream/2024.03.10
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'yt_dlp/extractor/bigo.py')
-rw-r--r--yt_dlp/extractor/bigo.py57
1 files changed, 57 insertions, 0 deletions
diff --git a/yt_dlp/extractor/bigo.py b/yt_dlp/extractor/bigo.py
new file mode 100644
index 0000000..acf78e4
--- /dev/null
+++ b/yt_dlp/extractor/bigo.py
@@ -0,0 +1,57 @@
+from .common import InfoExtractor
+from ..utils import ExtractorError, urlencode_postdata
+
+
+class BigoIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?bigo\.tv/(?:[a-z]{2,}/)?(?P<id>[^/]+)'
+
+ _TESTS = [{
+ 'url': 'https://www.bigo.tv/ja/221338632',
+ 'info_dict': {
+ 'id': '6576287577575737440',
+ 'title': '土よ〜💁‍♂️ 休憩室/REST room',
+ 'thumbnail': r're:https?://.+',
+ 'uploader': '✨Shin💫',
+ 'uploader_id': '221338632',
+ 'is_live': True,
+ },
+ 'skip': 'livestream',
+ }, {
+ 'url': 'https://www.bigo.tv/th/Tarlerm1304',
+ 'only_matching': True,
+ }, {
+ 'url': 'https://bigo.tv/115976881',
+ 'only_matching': True,
+ }]
+
+ def _real_extract(self, url):
+ user_id = self._match_id(url)
+
+ info_raw = self._download_json(
+ 'https://ta.bigo.tv/official_website/studio/getInternalStudioInfo',
+ user_id, data=urlencode_postdata({'siteId': user_id}),
+ headers={'Accept': 'application/json'})
+
+ if not isinstance(info_raw, dict):
+ raise ExtractorError('Received invalid JSON data')
+ if info_raw.get('code'):
+ raise ExtractorError(
+ 'Bigo says: %s (code %s)' % (info_raw.get('msg'), info_raw.get('code')), expected=True)
+ info = info_raw.get('data') or {}
+
+ if not info.get('alive'):
+ raise ExtractorError('This user is offline.', expected=True)
+
+ formats, subs = self._extract_m3u8_formats_and_subtitles(
+ info.get('hls_src'), user_id, 'mp4', 'm3u8')
+
+ return {
+ 'id': info.get('roomId') or user_id,
+ 'title': info.get('roomTopic') or info.get('nick_name') or user_id,
+ 'formats': formats,
+ 'subtitles': subs,
+ 'thumbnail': info.get('snapshot'),
+ 'uploader': info.get('nick_name'),
+ 'uploader_id': user_id,
+ 'is_live': True,
+ }