mirror of
https://github.com/ytdl-org/youtube-dl
synced 2025-02-03 09:10:11 +09:00
Attempt to conform to coding conventions
This commit is contained in:
parent
9fbf1376cf
commit
deb1525c05
@ -11,7 +11,7 @@ class CamsodaIE(InfoExtractor):
|
|||||||
_TEST = {
|
_TEST = {
|
||||||
'url': 'https://camsoda.com/valeryromero',
|
'url': 'https://camsoda.com/valeryromero',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '42',
|
'id': 'valeryromero',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': 're:^valeryromero [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$',
|
'title': 're:^valeryromero [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$',
|
||||||
'age_limit': 18,
|
'age_limit': 18,
|
||||||
@ -25,38 +25,37 @@ class CamsodaIE(InfoExtractor):
|
|||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
user_data = self._download_json('https://www.camsoda.com/api/v1/user/%s' %
|
user_data = self._download_json(
|
||||||
video_id, 'Downloading user data', video_id)
|
'https://www.camsoda.com/api/v1/user/%s' % video_id,
|
||||||
|
'Downloading user data', video_id)
|
||||||
|
|
||||||
if not user_data.get('status'):
|
if (not user_data.get('status')) or user_data.get('status') == 0:
|
||||||
raise ExtractorError('Not a valid user', expected=True)
|
raise ExtractorError('No broadcaster found', expected=True)
|
||||||
|
|
||||||
video_data = self._download_json(
|
|
||||||
'https://www.camsoda.com/api/v1/video/vtoken/%s?username=guest_%s' %
|
|
||||||
(video_id, str(random.randint(1000, 99999))),
|
|
||||||
'Downloading second json', video_id
|
|
||||||
)
|
|
||||||
|
|
||||||
if not video_data.get('edge_servers'):
|
|
||||||
raise ExtractorError('Stream is not available', expected=True)
|
|
||||||
|
|
||||||
user = user_data.get('user')
|
user = user_data.get('user')
|
||||||
if user:
|
if user:
|
||||||
thumb = user.get('thumb') or user.get('profile_picture')
|
thumb = user.get('thumb') or user.get('profile_picture')
|
||||||
|
else:
|
||||||
|
thumb = None
|
||||||
|
|
||||||
|
video_data = self._download_json(
|
||||||
|
'https://www.camsoda.com/api/v1/video/vtoken/%s?username=guest_%s' %
|
||||||
|
(video_id, str(random.randint(1000, 99999))),
|
||||||
|
'Downloading stream token', video_id)
|
||||||
|
|
||||||
|
if not video_data.get('edge_servers'):
|
||||||
|
raise ExtractorError('Stream is not available', expected=True)
|
||||||
|
|
||||||
VIDEO_URL = 'https://{server}/{app}/mp4:{stream_name}_aac/playlist.m3u8?token={token}'
|
VIDEO_URL = 'https://{server}/{app}/mp4:{stream_name}_aac/playlist.m3u8?token={token}'
|
||||||
m3u8_url = VIDEO_URL.format(
|
m3u8_url = VIDEO_URL.format(
|
||||||
server=video_data['edge_servers'][0],
|
server=video_data['edge_servers'][0],
|
||||||
app=video_data['app'],
|
app=video_data['app'],
|
||||||
stream_name=video_data['stream_name'],
|
stream_name=video_data['stream_name'],
|
||||||
token=video_data['token']
|
token=video_data['token'])
|
||||||
)
|
|
||||||
|
|
||||||
formats = []
|
formats = []
|
||||||
formats.extend(self._extract_m3u8_formats(
|
formats.extend(self._extract_m3u8_formats(
|
||||||
m3u8_url, video_id, ext='mp4',
|
m3u8_url, video_id, ext='mp4', live=True))
|
||||||
fatal=False, live=True)
|
|
||||||
)
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
@ -64,4 +63,5 @@ class CamsodaIE(InfoExtractor):
|
|||||||
'is_live': True,
|
'is_live': True,
|
||||||
'thumbnail': thumb,
|
'thumbnail': thumb,
|
||||||
'formats': formats,
|
'formats': formats,
|
||||||
|
'age_limit': 18,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user