mirror of
https://github.com/ytdl-org/youtube-dl
synced 2024-09-01 10:55:08 +02:00
making requested changes
corrected order of video id and note changed str to compat_str removed query from string and passed as var changed str.format to old style %operator check to make sure user is a dict
This commit is contained in:
parent
ad3a52a278
commit
b560f88477
@ -2,6 +2,7 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from .common import InfoExtractor
|
||||
from ..compat import compat_str
|
||||
import random
|
||||
from ..utils import ExtractorError
|
||||
|
||||
@ -27,31 +28,29 @@ class CamsodaIE(InfoExtractor):
|
||||
video_id = self._match_id(url)
|
||||
user_data = self._download_json(
|
||||
'https://www.camsoda.com/api/v1/user/%s' % video_id,
|
||||
'Downloading user data', video_id)
|
||||
video_id, 'Downloading user data')
|
||||
|
||||
if not user_data.get('status'):
|
||||
raise ExtractorError('No broadcaster found', expected=True)
|
||||
|
||||
user = user_data.get('user')
|
||||
user = user_data.get('user') if isinstance(user_data.get('user'), dict) else None
|
||||
if user:
|
||||
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)
|
||||
'https://www.camsoda.com/api/v1/video/vtoken/%s' % video_id, video_id,
|
||||
'Downloading stream token', query={
|
||||
'username': 'guest_%s' % compat_str(random.randint(1000, 99999)),
|
||||
})
|
||||
|
||||
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}'
|
||||
m3u8_url = VIDEO_URL.format(
|
||||
server=video_data['edge_servers'][0],
|
||||
app=video_data['app'],
|
||||
stream_name=video_data['stream_name'],
|
||||
token=video_data['token'])
|
||||
m3u8_url = 'https://%s/%s/mp4:%s_aac/playlist.m3u8?token=%s' % (
|
||||
video_data['edge_servers'][0], video_data['app'],
|
||||
video_data['stream_name'], video_data['token'])
|
||||
|
||||
formats = []
|
||||
formats.extend(self._extract_m3u8_formats(
|
||||
|
Loading…
Reference in New Issue
Block a user