From efc73896df0c7738b1b402809bb10f5290509ca6 Mon Sep 17 00:00:00 2001 From: Kevin G Date: Sun, 9 Jun 2019 03:17:44 -0700 Subject: [PATCH] [unauthorizedtv] Require cid in URL --- youtube_dl/extractor/unauthorizedtv.py | 28 ++++++-------------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/youtube_dl/extractor/unauthorizedtv.py b/youtube_dl/extractor/unauthorizedtv.py index 67e1013d3..225a1775a 100644 --- a/youtube_dl/extractor/unauthorizedtv.py +++ b/youtube_dl/extractor/unauthorizedtv.py @@ -9,7 +9,7 @@ from ..compat import ( class UnauthorizedTvIE(InfoExtractor): - _VALID_URL = r'https?://(?:www\.)?unauthorized\.tv/programs/(?P.+)' + _VALID_URL = r'https?://(?:www\.)?unauthorized\.tv/programs/.*?cid=(?P\d+)' _TEST = { 'url': 'https://www.unauthorized.tv/programs/owens-shorts?cid=231148', 'md5': 'dd9a5b81b9704c68942c2584086dd73f', @@ -22,10 +22,8 @@ class UnauthorizedTvIE(InfoExtractor): def _real_extract(self, url): video_id = self._match_id(url) - cid = None - - if "?cid=" in video_id: - cid = int(video_id[video_id.find('=') + 1:]) + + program = url[url.rfind("/")+1:url.find("?cid=")] html = self._download_webpage(url, video_id) @@ -37,28 +35,14 @@ class UnauthorizedTvIE(InfoExtractor): 'X-CSRF-Token': csrf_token, } - chaptersJson = self._download_json( - 'https://www.unauthorized.tv/api/contents/%s' % video_id, - video_id, - headers=headers - ) - - chapters = '&ids[]='.join([compat_str(x) for x in chaptersJson['chapters']]) - metadata = self._download_json( - 'https://www.unauthorized.tv/api/chapters?ids[]=%s' % chapters, + 'https://www.unauthorized.tv/api/chapters?ids[]=%s' % video_id, video_id, headers=headers ) - if cid is None: - video_title = metadata[0]['title'] - video_url = metadata[0]['subject']['versions']['hls'] - else: - for item in metadata: - if item["id"] == cid: - video_title = item['title'] - video_url = item['subject']['versions']['hls'] + video_title = metadata[0]['title'] + video_url = metadata[0]['subject']['versions']['hls'] return { 'id': video_id,