aboutsummaryrefslogtreecommitdiffstats
path: root/yt_dlp/extractor/bigo.py
diff options
context:
space:
mode:
authorJesús <heckyel@hyperbola.info>2022-02-12 21:05:27 -0500
committerJesús <heckyel@hyperbola.info>2022-02-12 21:05:27 -0500
commitaf4847e22e81d05177f92c712983ab3f2f20184b (patch)
tree6b749333494ffe379df3e1a060660e4b1afcdf85 /yt_dlp/extractor/bigo.py
parentc4b763b19f54ed5dfc2fd408adb9ed74126f6740 (diff)
parent29448350808619262d6a9ddd393a2c28df1720fe (diff)
downloadhypervideo-pre-af4847e22e81d05177f92c712983ab3f2f20184b.tar.lz
hypervideo-pre-af4847e22e81d05177f92c712983ab3f2f20184b.tar.xz
hypervideo-pre-af4847e22e81d05177f92c712983ab3f2f20184b.zip
updated from upstream | 12/02/2022 at 21:05
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 000000000..6e38ecc1d
--- /dev/null
+++ b/yt_dlp/extractor/bigo.py
@@ -0,0 +1,57 @@
+# coding: utf-8
+from __future__ import unicode_literals
+
+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://bigo.tv/studio/getInternalStudioInfo',
+ user_id, data=urlencode_postdata({'siteId': user_id}))
+
+ if info_raw.get('code'):
+ raise ExtractorError(
+ f'{info_raw["msg"]} (code {info_raw["code"]})', expected=True)
+ info = info_raw.get('data') or {}
+
+ if not info.get('alive'):
+ raise ExtractorError('This user is offline.', expected=True)
+
+ return {
+ 'id': info.get('roomId') or user_id,
+ 'title': info.get('roomTopic'),
+ 'formats': [{
+ 'url': info.get('hls_src'),
+ 'ext': 'mp4',
+ 'protocol': 'm3u8',
+ }],
+ 'thumbnail': info.get('snapshot'),
+ 'uploader': info.get('nick_name'),
+ 'uploader_id': user_id,
+ 'is_live': True,
+ }