From 2ab554656a5659cb1bb8d940490874d6f613792a Mon Sep 17 00:00:00 2001 From: Kevin G Date: Thu, 6 Jun 2019 14:24:41 -0700 Subject: [PATCH 01/19] [unauthorizedtv] Add new extractor --- youtube_dl/extractor/extractors.py | 1 + youtube_dl/extractor/unauthorizedtv.py | 82 ++++++++++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 youtube_dl/extractor/unauthorizedtv.py diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py index 711d3f402..052d4c8a6 100644 --- a/youtube_dl/extractor/extractors.py +++ b/youtube_dl/extractor/extractors.py @@ -1266,6 +1266,7 @@ from .ufctv import UFCTVIE from .uktvplay import UKTVPlayIE from .digiteka import DigitekaIE from .umg import UMGDeIE +from .unauthorizedtv import UnauthorizedTvIE from .unistra import UnistraIE from .unity import UnityIE from .uol import UOLIE diff --git a/youtube_dl/extractor/unauthorizedtv.py b/youtube_dl/extractor/unauthorizedtv.py new file mode 100644 index 000000000..52f9bae02 --- /dev/null +++ b/youtube_dl/extractor/unauthorizedtv.py @@ -0,0 +1,82 @@ +# coding: utf-8 +from __future__ import unicode_literals + +from .common import InfoExtractor + + +class UnauthorizedTvIE(InfoExtractor): + _VALID_URL = r'https?://(?:www\.)?unauthorized\.tv/programs/(?P.+)' + _TEST = { + 'url': 'https://www.unauthorized.tv/programs/owens-shorts?cid=231148', + 'md5': 'dd9a5b81b9704c68942c2584086dd73f', + 'info_dict': { + 'id': 'owens-shorts?cid=231148', + 'ext': 'mp4', + 'title': 'Millennials', + } + } + + 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:]) + + if self._downloader.params.get('verbose', False): + print(video_id) + + html = self._download_webpage(url, video_id) + + csrf_token = self._html_search_meta( + 'csrf-token', + html, + 'csrf token', + default=None + ) + + headers = { + 'Referer': url, + 'X-Requested-With': 'XMLHttpRequest', + 'X-CSRF-Token': csrf_token, + } + + chaptersJson = self._download_json( + 'https://www.unauthorized.tv/api/contents/%s' % video_id, + video_id, + headers=headers + ) + + if self._downloader.params.get('verbose', False): + print(chaptersJson) + + chapters = '&ids[]='.join([str(x) for x in chaptersJson['chapters']]) + + metadata = self._download_json( + 'https://www.unauthorized.tv/api/chapters?ids[]=%s' % chapters, + 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'] + + if self._downloader.params.get('verbose', False): + print(metadata) + print(video_title) + print(video_url) + + return { + 'id': video_id, + 'title': video_title, + 'formats': [{ + 'url': video_url, + 'ext': 'mp4', + }], + } From bca8b61c66e6f3d5d26d0864cde19536375e1105 Mon Sep 17 00:00:00 2001 From: Kevin G Date: Thu, 6 Jun 2019 14:29:15 -0700 Subject: [PATCH 02/19] [unauthorizedtv] Add new extractor --- youtube_dl/extractor/unauthorizedtv.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/youtube_dl/extractor/unauthorizedtv.py b/youtube_dl/extractor/unauthorizedtv.py index 52f9bae02..e70b8a3e5 100644 --- a/youtube_dl/extractor/unauthorizedtv.py +++ b/youtube_dl/extractor/unauthorizedtv.py @@ -75,8 +75,6 @@ class UnauthorizedTvIE(InfoExtractor): return { 'id': video_id, 'title': video_title, - 'formats': [{ - 'url': video_url, - 'ext': 'mp4', - }], + 'url': video_url, + 'ext': 'mp4', } From 158ebb21823b37f3f388db574cce6f05622db385 Mon Sep 17 00:00:00 2001 From: Kevin G Date: Sun, 9 Jun 2019 02:59:22 -0700 Subject: [PATCH 03/19] [unauthorizedtv] Remove verbose debug --- youtube_dl/extractor/unauthorizedtv.py | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/youtube_dl/extractor/unauthorizedtv.py b/youtube_dl/extractor/unauthorizedtv.py index e70b8a3e5..6766268d7 100644 --- a/youtube_dl/extractor/unauthorizedtv.py +++ b/youtube_dl/extractor/unauthorizedtv.py @@ -23,9 +23,6 @@ class UnauthorizedTvIE(InfoExtractor): if "?cid=" in video_id: cid = int(video_id[video_id.find('=') + 1:]) - if self._downloader.params.get('verbose', False): - print(video_id) - html = self._download_webpage(url, video_id) csrf_token = self._html_search_meta( @@ -47,9 +44,6 @@ class UnauthorizedTvIE(InfoExtractor): headers=headers ) - if self._downloader.params.get('verbose', False): - print(chaptersJson) - chapters = '&ids[]='.join([str(x) for x in chaptersJson['chapters']]) metadata = self._download_json( @@ -67,11 +61,6 @@ class UnauthorizedTvIE(InfoExtractor): video_title = item['title'] video_url = item['subject']['versions']['hls'] - if self._downloader.params.get('verbose', False): - print(metadata) - print(video_title) - print(video_url) - return { 'id': video_id, 'title': video_title, From 167f89fc6fdcd8984f91422c38950fd460b54e5b Mon Sep 17 00:00:00 2001 From: Kevin G Date: Sun, 9 Jun 2019 03:00:54 -0700 Subject: [PATCH 04/19] [unauthorizedtv] Collapse lines to single line --- youtube_dl/extractor/unauthorizedtv.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/youtube_dl/extractor/unauthorizedtv.py b/youtube_dl/extractor/unauthorizedtv.py index 6766268d7..e68bbc775 100644 --- a/youtube_dl/extractor/unauthorizedtv.py +++ b/youtube_dl/extractor/unauthorizedtv.py @@ -25,12 +25,7 @@ class UnauthorizedTvIE(InfoExtractor): html = self._download_webpage(url, video_id) - csrf_token = self._html_search_meta( - 'csrf-token', - html, - 'csrf token', - default=None - ) + csrf_token = self._html_search_meta('csrf-token', html, 'csrf token', default=None) headers = { 'Referer': url, From f11f756e3fc4f1ca21845b90c7f9b09311846649 Mon Sep 17 00:00:00 2001 From: Kevin G Date: Sun, 9 Jun 2019 03:05:00 -0700 Subject: [PATCH 05/19] [unauthorizedtv] Use compat_str --- youtube_dl/extractor/unauthorizedtv.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/youtube_dl/extractor/unauthorizedtv.py b/youtube_dl/extractor/unauthorizedtv.py index e68bbc775..67e1013d3 100644 --- a/youtube_dl/extractor/unauthorizedtv.py +++ b/youtube_dl/extractor/unauthorizedtv.py @@ -3,6 +3,10 @@ from __future__ import unicode_literals from .common import InfoExtractor +from ..compat import ( + compat_str, +) + class UnauthorizedTvIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?unauthorized\.tv/programs/(?P.+)' @@ -39,7 +43,7 @@ class UnauthorizedTvIE(InfoExtractor): headers=headers ) - chapters = '&ids[]='.join([str(x) for x in chaptersJson['chapters']]) + chapters = '&ids[]='.join([compat_str(x) for x in chaptersJson['chapters']]) metadata = self._download_json( 'https://www.unauthorized.tv/api/chapters?ids[]=%s' % chapters, From 38dffd27d98368df5fc64683283a22266dd357ca Mon Sep 17 00:00:00 2001 From: Kevin G Date: Sun, 9 Jun 2019 03:17:44 -0700 Subject: [PATCH 06/19] [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, From 9237f2125ff2d923534709c37dc2e7d1de9535ca Mon Sep 17 00:00:00 2001 From: Kevin G Date: Sun, 9 Jun 2019 03:18:00 -0700 Subject: [PATCH 07/19] [unauthorizedtv] Update id in test --- youtube_dl/extractor/unauthorizedtv.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/youtube_dl/extractor/unauthorizedtv.py b/youtube_dl/extractor/unauthorizedtv.py index 225a1775a..df0ff1331 100644 --- a/youtube_dl/extractor/unauthorizedtv.py +++ b/youtube_dl/extractor/unauthorizedtv.py @@ -14,7 +14,7 @@ class UnauthorizedTvIE(InfoExtractor): 'url': 'https://www.unauthorized.tv/programs/owens-shorts?cid=231148', 'md5': 'dd9a5b81b9704c68942c2584086dd73f', 'info_dict': { - 'id': 'owens-shorts?cid=231148', + 'id': '231148', 'ext': 'mp4', 'title': 'Millennials', } From 48456eea51fffef28a1dc7e3a17600cfaa2a9495 Mon Sep 17 00:00:00 2001 From: Kevin G Date: Sun, 9 Jun 2019 03:19:19 -0700 Subject: [PATCH 08/19] [unauthorizedtv] Fix flake8 warnings --- youtube_dl/extractor/unauthorizedtv.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/youtube_dl/extractor/unauthorizedtv.py b/youtube_dl/extractor/unauthorizedtv.py index df0ff1331..495916071 100644 --- a/youtube_dl/extractor/unauthorizedtv.py +++ b/youtube_dl/extractor/unauthorizedtv.py @@ -3,10 +3,6 @@ from __future__ import unicode_literals from .common import InfoExtractor -from ..compat import ( - compat_str, -) - class UnauthorizedTvIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?unauthorized\.tv/programs/.*?cid=(?P\d+)' @@ -22,8 +18,6 @@ class UnauthorizedTvIE(InfoExtractor): def _real_extract(self, url): video_id = self._match_id(url) - - program = url[url.rfind("/")+1:url.find("?cid=")] html = self._download_webpage(url, video_id) From e8a49bd0b263dce2bf3ae8f55f1aad9381c5a061 Mon Sep 17 00:00:00 2001 From: Kevin G Date: Sun, 9 Jun 2019 03:20:27 -0700 Subject: [PATCH 09/19] [unauthorizedtv] Require csrf-token --- youtube_dl/extractor/unauthorizedtv.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/youtube_dl/extractor/unauthorizedtv.py b/youtube_dl/extractor/unauthorizedtv.py index 495916071..8ed784281 100644 --- a/youtube_dl/extractor/unauthorizedtv.py +++ b/youtube_dl/extractor/unauthorizedtv.py @@ -21,7 +21,7 @@ class UnauthorizedTvIE(InfoExtractor): html = self._download_webpage(url, video_id) - csrf_token = self._html_search_meta('csrf-token', html, 'csrf token', default=None) + csrf_token = self._html_search_meta('csrf-token', html, 'csrf token', fatal=True) headers = { 'Referer': url, From 429c564ae92179a73aec4e7c0a0582854d254a08 Mon Sep 17 00:00:00 2001 From: Kevin G Date: Thu, 6 Jun 2019 14:24:41 -0700 Subject: [PATCH 10/19] [unauthorizedtv] Add new extractor --- youtube_dl/extractor/extractors.py | 1 + youtube_dl/extractor/unauthorizedtv.py | 82 ++++++++++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 youtube_dl/extractor/unauthorizedtv.py diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py index 376d07727..6c7624176 100644 --- a/youtube_dl/extractor/extractors.py +++ b/youtube_dl/extractor/extractors.py @@ -1246,6 +1246,7 @@ from .dlive import ( DLiveStreamIE, ) from .umg import UMGDeIE +from .unauthorizedtv import UnauthorizedTvIE from .unistra import UnistraIE from .unity import UnityIE from .uol import UOLIE diff --git a/youtube_dl/extractor/unauthorizedtv.py b/youtube_dl/extractor/unauthorizedtv.py new file mode 100644 index 000000000..52f9bae02 --- /dev/null +++ b/youtube_dl/extractor/unauthorizedtv.py @@ -0,0 +1,82 @@ +# coding: utf-8 +from __future__ import unicode_literals + +from .common import InfoExtractor + + +class UnauthorizedTvIE(InfoExtractor): + _VALID_URL = r'https?://(?:www\.)?unauthorized\.tv/programs/(?P.+)' + _TEST = { + 'url': 'https://www.unauthorized.tv/programs/owens-shorts?cid=231148', + 'md5': 'dd9a5b81b9704c68942c2584086dd73f', + 'info_dict': { + 'id': 'owens-shorts?cid=231148', + 'ext': 'mp4', + 'title': 'Millennials', + } + } + + 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:]) + + if self._downloader.params.get('verbose', False): + print(video_id) + + html = self._download_webpage(url, video_id) + + csrf_token = self._html_search_meta( + 'csrf-token', + html, + 'csrf token', + default=None + ) + + headers = { + 'Referer': url, + 'X-Requested-With': 'XMLHttpRequest', + 'X-CSRF-Token': csrf_token, + } + + chaptersJson = self._download_json( + 'https://www.unauthorized.tv/api/contents/%s' % video_id, + video_id, + headers=headers + ) + + if self._downloader.params.get('verbose', False): + print(chaptersJson) + + chapters = '&ids[]='.join([str(x) for x in chaptersJson['chapters']]) + + metadata = self._download_json( + 'https://www.unauthorized.tv/api/chapters?ids[]=%s' % chapters, + 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'] + + if self._downloader.params.get('verbose', False): + print(metadata) + print(video_title) + print(video_url) + + return { + 'id': video_id, + 'title': video_title, + 'formats': [{ + 'url': video_url, + 'ext': 'mp4', + }], + } From bb17ebb6fd184d748ef43345cd0aaff52670929a Mon Sep 17 00:00:00 2001 From: Kevin G Date: Thu, 6 Jun 2019 14:29:15 -0700 Subject: [PATCH 11/19] [unauthorizedtv] Add new extractor --- youtube_dl/extractor/unauthorizedtv.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/youtube_dl/extractor/unauthorizedtv.py b/youtube_dl/extractor/unauthorizedtv.py index 52f9bae02..e70b8a3e5 100644 --- a/youtube_dl/extractor/unauthorizedtv.py +++ b/youtube_dl/extractor/unauthorizedtv.py @@ -75,8 +75,6 @@ class UnauthorizedTvIE(InfoExtractor): return { 'id': video_id, 'title': video_title, - 'formats': [{ - 'url': video_url, - 'ext': 'mp4', - }], + 'url': video_url, + 'ext': 'mp4', } From 06603fae4b4110b3b3955783b42b5fe02315bc20 Mon Sep 17 00:00:00 2001 From: Kevin G Date: Sun, 9 Jun 2019 02:59:22 -0700 Subject: [PATCH 12/19] [unauthorizedtv] Remove verbose debug --- youtube_dl/extractor/unauthorizedtv.py | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/youtube_dl/extractor/unauthorizedtv.py b/youtube_dl/extractor/unauthorizedtv.py index e70b8a3e5..6766268d7 100644 --- a/youtube_dl/extractor/unauthorizedtv.py +++ b/youtube_dl/extractor/unauthorizedtv.py @@ -23,9 +23,6 @@ class UnauthorizedTvIE(InfoExtractor): if "?cid=" in video_id: cid = int(video_id[video_id.find('=') + 1:]) - if self._downloader.params.get('verbose', False): - print(video_id) - html = self._download_webpage(url, video_id) csrf_token = self._html_search_meta( @@ -47,9 +44,6 @@ class UnauthorizedTvIE(InfoExtractor): headers=headers ) - if self._downloader.params.get('verbose', False): - print(chaptersJson) - chapters = '&ids[]='.join([str(x) for x in chaptersJson['chapters']]) metadata = self._download_json( @@ -67,11 +61,6 @@ class UnauthorizedTvIE(InfoExtractor): video_title = item['title'] video_url = item['subject']['versions']['hls'] - if self._downloader.params.get('verbose', False): - print(metadata) - print(video_title) - print(video_url) - return { 'id': video_id, 'title': video_title, From b83975fb4887fe896ac523cabe9367737b181a90 Mon Sep 17 00:00:00 2001 From: Kevin G Date: Sun, 9 Jun 2019 03:00:54 -0700 Subject: [PATCH 13/19] [unauthorizedtv] Collapse lines to single line --- youtube_dl/extractor/unauthorizedtv.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/youtube_dl/extractor/unauthorizedtv.py b/youtube_dl/extractor/unauthorizedtv.py index 6766268d7..e68bbc775 100644 --- a/youtube_dl/extractor/unauthorizedtv.py +++ b/youtube_dl/extractor/unauthorizedtv.py @@ -25,12 +25,7 @@ class UnauthorizedTvIE(InfoExtractor): html = self._download_webpage(url, video_id) - csrf_token = self._html_search_meta( - 'csrf-token', - html, - 'csrf token', - default=None - ) + csrf_token = self._html_search_meta('csrf-token', html, 'csrf token', default=None) headers = { 'Referer': url, From 8a05ffa9c0426eee62f82776541c0519e66ccadf Mon Sep 17 00:00:00 2001 From: Kevin G Date: Sun, 9 Jun 2019 03:05:00 -0700 Subject: [PATCH 14/19] [unauthorizedtv] Use compat_str --- youtube_dl/extractor/unauthorizedtv.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/youtube_dl/extractor/unauthorizedtv.py b/youtube_dl/extractor/unauthorizedtv.py index e68bbc775..67e1013d3 100644 --- a/youtube_dl/extractor/unauthorizedtv.py +++ b/youtube_dl/extractor/unauthorizedtv.py @@ -3,6 +3,10 @@ from __future__ import unicode_literals from .common import InfoExtractor +from ..compat import ( + compat_str, +) + class UnauthorizedTvIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?unauthorized\.tv/programs/(?P.+)' @@ -39,7 +43,7 @@ class UnauthorizedTvIE(InfoExtractor): headers=headers ) - chapters = '&ids[]='.join([str(x) for x in chaptersJson['chapters']]) + chapters = '&ids[]='.join([compat_str(x) for x in chaptersJson['chapters']]) metadata = self._download_json( 'https://www.unauthorized.tv/api/chapters?ids[]=%s' % chapters, From efc73896df0c7738b1b402809bb10f5290509ca6 Mon Sep 17 00:00:00 2001 From: Kevin G Date: Sun, 9 Jun 2019 03:17:44 -0700 Subject: [PATCH 15/19] [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, From bf09740f896052ee75e91528bc4caaebe1272ea2 Mon Sep 17 00:00:00 2001 From: Kevin G Date: Sun, 9 Jun 2019 03:18:00 -0700 Subject: [PATCH 16/19] [unauthorizedtv] Update id in test --- youtube_dl/extractor/unauthorizedtv.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/youtube_dl/extractor/unauthorizedtv.py b/youtube_dl/extractor/unauthorizedtv.py index 225a1775a..df0ff1331 100644 --- a/youtube_dl/extractor/unauthorizedtv.py +++ b/youtube_dl/extractor/unauthorizedtv.py @@ -14,7 +14,7 @@ class UnauthorizedTvIE(InfoExtractor): 'url': 'https://www.unauthorized.tv/programs/owens-shorts?cid=231148', 'md5': 'dd9a5b81b9704c68942c2584086dd73f', 'info_dict': { - 'id': 'owens-shorts?cid=231148', + 'id': '231148', 'ext': 'mp4', 'title': 'Millennials', } From 31043fca5c19c7a81f64bb84464d04d681834bc9 Mon Sep 17 00:00:00 2001 From: Kevin G Date: Sun, 9 Jun 2019 03:19:19 -0700 Subject: [PATCH 17/19] [unauthorizedtv] Fix flake8 warnings --- youtube_dl/extractor/unauthorizedtv.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/youtube_dl/extractor/unauthorizedtv.py b/youtube_dl/extractor/unauthorizedtv.py index df0ff1331..495916071 100644 --- a/youtube_dl/extractor/unauthorizedtv.py +++ b/youtube_dl/extractor/unauthorizedtv.py @@ -3,10 +3,6 @@ from __future__ import unicode_literals from .common import InfoExtractor -from ..compat import ( - compat_str, -) - class UnauthorizedTvIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?unauthorized\.tv/programs/.*?cid=(?P\d+)' @@ -22,8 +18,6 @@ class UnauthorizedTvIE(InfoExtractor): def _real_extract(self, url): video_id = self._match_id(url) - - program = url[url.rfind("/")+1:url.find("?cid=")] html = self._download_webpage(url, video_id) From 40505e87ee681c39aa5f8816570423bc854d1acf Mon Sep 17 00:00:00 2001 From: Kevin G Date: Sun, 9 Jun 2019 03:20:27 -0700 Subject: [PATCH 18/19] [unauthorizedtv] Require csrf-token --- youtube_dl/extractor/unauthorizedtv.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/youtube_dl/extractor/unauthorizedtv.py b/youtube_dl/extractor/unauthorizedtv.py index 495916071..8ed784281 100644 --- a/youtube_dl/extractor/unauthorizedtv.py +++ b/youtube_dl/extractor/unauthorizedtv.py @@ -21,7 +21,7 @@ class UnauthorizedTvIE(InfoExtractor): html = self._download_webpage(url, video_id) - csrf_token = self._html_search_meta('csrf-token', html, 'csrf token', default=None) + csrf_token = self._html_search_meta('csrf-token', html, 'csrf token', fatal=True) headers = { 'Referer': url, From f1bcfe63bf75875a5fc8063d97866540b0833661 Mon Sep 17 00:00:00 2001 From: Kevin G Date: Sat, 21 Dec 2019 20:25:39 -0800 Subject: [PATCH 19/19] [unauthorizedtv] Support login --- youtube_dl/extractor/unauthorizedtv.py | 43 +++++++++++++++----------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/youtube_dl/extractor/unauthorizedtv.py b/youtube_dl/extractor/unauthorizedtv.py index 8ed784281..0e3718885 100644 --- a/youtube_dl/extractor/unauthorizedtv.py +++ b/youtube_dl/extractor/unauthorizedtv.py @@ -1,38 +1,45 @@ # coding: utf-8 from __future__ import unicode_literals +import json + from .common import InfoExtractor +from ..utils import ( + ExtractorError, +) class UnauthorizedTvIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?unauthorized\.tv/programs/.*?cid=(?P\d+)' - _TEST = { - 'url': 'https://www.unauthorized.tv/programs/owens-shorts?cid=231148', - 'md5': 'dd9a5b81b9704c68942c2584086dd73f', - 'info_dict': { - 'id': '231148', - 'ext': 'mp4', - 'title': 'Millennials', - } - } + _LOGIN_URL = 'https://www.unauthorized.tv/api/sessions' + _NETRC_MACHINE = 'unauthorizedtv' def _real_extract(self, url): - video_id = self._match_id(url) - html = self._download_webpage(url, video_id) + username, password = self._get_login_info() + if username is None: + self.raise_login_required() - csrf_token = self._html_search_meta('csrf-token', html, 'csrf token', fatal=True) - - headers = { - 'Referer': url, - 'X-Requested-With': 'XMLHttpRequest', - 'X-CSRF-Token': csrf_token, + data = { + 'email': username, + 'password': password, } + login_page = self._download_json( + self._LOGIN_URL, None, 'Logging in', + data=json.dumps(data).encode(), headers={ + 'Content-Type': 'application/json', + 'Referer': self._LOGIN_URL, + }) + + if login_page.get('id') is None: + raise ExtractorError('Invalid username or password', expected=True) + + video_id = self._match_id(url) + metadata = self._download_json( 'https://www.unauthorized.tv/api/chapters?ids[]=%s' % video_id, video_id, - headers=headers ) video_title = metadata[0]['title']