[unauthorizedtv] Require cid in URL
This commit is contained in:
parent
8a05ffa9c0
commit
efc73896df
@ -9,7 +9,7 @@ from ..compat import (
|
|||||||
|
|
||||||
|
|
||||||
class UnauthorizedTvIE(InfoExtractor):
|
class UnauthorizedTvIE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://(?:www\.)?unauthorized\.tv/programs/(?P<id>.+)'
|
_VALID_URL = r'https?://(?:www\.)?unauthorized\.tv/programs/.*?cid=(?P<id>\d+)'
|
||||||
_TEST = {
|
_TEST = {
|
||||||
'url': 'https://www.unauthorized.tv/programs/owens-shorts?cid=231148',
|
'url': 'https://www.unauthorized.tv/programs/owens-shorts?cid=231148',
|
||||||
'md5': 'dd9a5b81b9704c68942c2584086dd73f',
|
'md5': 'dd9a5b81b9704c68942c2584086dd73f',
|
||||||
@ -22,10 +22,8 @@ class UnauthorizedTvIE(InfoExtractor):
|
|||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
cid = None
|
|
||||||
|
|
||||||
if "?cid=" in video_id:
|
program = url[url.rfind("/")+1:url.find("?cid=")]
|
||||||
cid = int(video_id[video_id.find('=') + 1:])
|
|
||||||
|
|
||||||
html = self._download_webpage(url, video_id)
|
html = self._download_webpage(url, video_id)
|
||||||
|
|
||||||
@ -37,28 +35,14 @@ class UnauthorizedTvIE(InfoExtractor):
|
|||||||
'X-CSRF-Token': csrf_token,
|
'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(
|
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,
|
video_id,
|
||||||
headers=headers
|
headers=headers
|
||||||
)
|
)
|
||||||
|
|
||||||
if cid is None:
|
video_title = metadata[0]['title']
|
||||||
video_title = metadata[0]['title']
|
video_url = metadata[0]['subject']['versions']['hls']
|
||||||
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']
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user