[unauthorizedtv] Add new extractor
This commit is contained in:
parent
2dbc0967f2
commit
429c564ae9
@ -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
|
||||
|
82
youtube_dl/extractor/unauthorizedtv.py
Normal file
82
youtube_dl/extractor/unauthorizedtv.py
Normal file
@ -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<id>.+)'
|
||||
_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',
|
||||
}],
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user