From b560f884774fab5208f82a9bcdbf644cc88e181d Mon Sep 17 00:00:00 2001 From: JChris246 Date: Sun, 1 Sep 2019 15:45:06 -0400 Subject: [PATCH] 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 --- youtube_dl/extractor/camsoda.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/youtube_dl/extractor/camsoda.py b/youtube_dl/extractor/camsoda.py index ce4b1ac64..36e43430b 100644 --- a/youtube_dl/extractor/camsoda.py +++ b/youtube_dl/extractor/camsoda.py @@ -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(