Compare commits

...

3 Commits

Author SHA1 Message Date
Lesmiscore
2944835080
[bigo] Fix extractor to not to use form_params 2022-02-13 00:01:04 +09:00
Tom
a3eb987e0e
[zoom] Add support for screen cast (#2699)
Authored by: Mipsters
2022-02-12 06:22:51 -08:00
Lesmiscore (Naoya Ozaki)
7bc33ad0e9
[bigo] Add extractor (#2749)
Fixes https://github.com/ytdl-org/youtube-dl/issues/18357

Authored by: Lesmiscore
2022-02-12 06:07:10 -08:00
3 changed files with 91 additions and 7 deletions

57
yt_dlp/extractor/bigo.py Normal file
View File

@ -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,
}

View File

@ -142,6 +142,7 @@ from .bfmtv import (
) )
from .bibeltv import BibelTVIE from .bibeltv import BibelTVIE
from .bigflix import BigflixIE from .bigflix import BigflixIE
from .bigo import BigoIE
from .bild import BildIE from .bild import BildIE
from .bilibili import ( from .bilibili import (
BiliBiliIE, BiliBiliIE,

View File

@ -6,6 +6,7 @@ from .common import InfoExtractor
from ..utils import ( from ..utils import (
ExtractorError, ExtractorError,
int_or_none, int_or_none,
str_or_none,
js_to_json, js_to_json,
parse_filesize, parse_filesize,
urlencode_postdata, urlencode_postdata,
@ -23,7 +24,8 @@ class ZoomIE(InfoExtractor):
'id': 'dUk_CNBETmZ5VA2BwEl-jjakPpJ3M1pcfVYAPRsoIbEByGsLjUZtaa4yCATQuOL3der8BlTwxQePl_j0.EImBkXzTIaPvdZO5', 'id': 'dUk_CNBETmZ5VA2BwEl-jjakPpJ3M1pcfVYAPRsoIbEByGsLjUZtaa4yCATQuOL3der8BlTwxQePl_j0.EImBkXzTIaPvdZO5',
'ext': 'mp4', 'ext': 'mp4',
'title': 'China\'s "two sessions" and the new five-year plan', 'title': 'China\'s "two sessions" and the new five-year plan',
} },
'skip': 'Recording requires email authentication to access',
} }
def _real_extract(self, url): def _real_extract(self, url):
@ -56,22 +58,46 @@ class ZoomIE(InfoExtractor):
webpage, 'data'), play_id, js_to_json) webpage, 'data'), play_id, js_to_json)
subtitles = {} subtitles = {}
for _type in ('transcript', 'cc'): for _type in ('transcript', 'cc', 'chapter'):
if data.get('%sUrl' % _type): if data.get('%sUrl' % _type):
subtitles[_type] = [{ subtitles[_type] = [{
'url': urljoin(base_url, data['%sUrl' % _type]), 'url': urljoin(base_url, data['%sUrl' % _type]),
'ext': 'vtt', 'ext': 'vtt',
}] }]
return { formats = []
'id': play_id,
'title': data['topic'], if data.get('viewMp4Url'):
'url': data['viewMp4Url'], formats.append({
'subtitles': subtitles, 'format_note': 'Camera stream',
'url': str_or_none(data.get('viewMp4Url')),
'width': int_or_none(data.get('viewResolvtionsWidth')), 'width': int_or_none(data.get('viewResolvtionsWidth')),
'height': int_or_none(data.get('viewResolvtionsHeight')), 'height': int_or_none(data.get('viewResolvtionsHeight')),
'format_id': str_or_none(data.get('recordingId')),
'ext': 'mp4',
'filesize_approx': parse_filesize(data.get('fileSize')),
'preference': 0
})
if data.get('shareMp4Url'):
formats.append({
'format_note': 'Screen share stream',
'url': str_or_none(data.get('shareMp4Url')),
'width': int_or_none(data.get('shareResolvtionsWidth')),
'height': int_or_none(data.get('shareResolvtionsHeight')),
'format_id': str_or_none(data.get('shareVideoId')),
'ext': 'mp4',
'preference': -1
})
self._sort_formats(formats)
return {
'id': play_id,
'title': data.get('topic'),
'subtitles': subtitles,
'formats': formats,
'http_headers': { 'http_headers': {
'Referer': base_url, 'Referer': base_url,
}, },
'filesize_approx': parse_filesize(data.get('fileSize')),
} }