mirror of
https://codeberg.org/polarisfm/youtube-dl
synced 2024-11-26 02:14:32 +01: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 __future__ import unicode_literals
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
|
from ..compat import compat_str
|
||||||
import random
|
import random
|
||||||
from ..utils import ExtractorError
|
from ..utils import ExtractorError
|
||||||
|
|
||||||
@ -27,31 +28,29 @@ class CamsodaIE(InfoExtractor):
|
|||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
user_data = self._download_json(
|
user_data = self._download_json(
|
||||||
'https://www.camsoda.com/api/v1/user/%s' % video_id,
|
'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'):
|
if not user_data.get('status'):
|
||||||
raise ExtractorError('No broadcaster found', expected=True)
|
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:
|
if user:
|
||||||
thumb = user.get('thumb') or user.get('profile_picture')
|
thumb = user.get('thumb') or user.get('profile_picture')
|
||||||
else:
|
else:
|
||||||
thumb = None
|
thumb = None
|
||||||
|
|
||||||
video_data = self._download_json(
|
video_data = self._download_json(
|
||||||
'https://www.camsoda.com/api/v1/video/vtoken/%s?username=guest_%s' %
|
'https://www.camsoda.com/api/v1/video/vtoken/%s' % video_id, video_id,
|
||||||
(video_id, str(random.randint(1000, 99999))),
|
'Downloading stream token', query={
|
||||||
'Downloading stream token', video_id)
|
'username': 'guest_%s' % compat_str(random.randint(1000, 99999)),
|
||||||
|
})
|
||||||
|
|
||||||
if not video_data.get('edge_servers'):
|
if not video_data.get('edge_servers'):
|
||||||
raise ExtractorError('Stream is not available', expected=True)
|
raise ExtractorError('Stream is not available', expected=True)
|
||||||
|
|
||||||
VIDEO_URL = 'https://{server}/{app}/mp4:{stream_name}_aac/playlist.m3u8?token={token}'
|
m3u8_url = 'https://%s/%s/mp4:%s_aac/playlist.m3u8?token=%s' % (
|
||||||
m3u8_url = VIDEO_URL.format(
|
video_data['edge_servers'][0], video_data['app'],
|
||||||
server=video_data['edge_servers'][0],
|
video_data['stream_name'], video_data['token'])
|
||||||
app=video_data['app'],
|
|
||||||
stream_name=video_data['stream_name'],
|
|
||||||
token=video_data['token'])
|
|
||||||
|
|
||||||
formats = []
|
formats = []
|
||||||
formats.extend(self._extract_m3u8_formats(
|
formats.extend(self._extract_m3u8_formats(
|
||||||
|
Loading…
Reference in New Issue
Block a user