mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-21 20:46:36 -05:00
parent
ea07412ebf
commit
e9b95167af
1 changed files with 22 additions and 33 deletions
|
@ -1,8 +1,6 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import re
|
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..compat import (
|
from ..compat import (
|
||||||
compat_HTTPError,
|
compat_HTTPError,
|
||||||
|
@ -18,7 +16,6 @@
|
||||||
|
|
||||||
class RoosterTeethIE(InfoExtractor):
|
class RoosterTeethIE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://(?:.+?\.)?roosterteeth\.com/(?:episode|watch)/(?P<id>[^/?#&]+)'
|
_VALID_URL = r'https?://(?:.+?\.)?roosterteeth\.com/(?:episode|watch)/(?P<id>[^/?#&]+)'
|
||||||
_LOGIN_URL = 'https://roosterteeth.com/login'
|
|
||||||
_NETRC_MACHINE = 'roosterteeth'
|
_NETRC_MACHINE = 'roosterteeth'
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'http://roosterteeth.com/episode/million-dollars-but-season-2-million-dollars-but-the-game-announcement',
|
'url': 'http://roosterteeth.com/episode/million-dollars-but-season-2-million-dollars-but-the-game-announcement',
|
||||||
|
@ -53,48 +50,40 @@ class RoosterTeethIE(InfoExtractor):
|
||||||
'url': 'https://roosterteeth.com/watch/million-dollars-but-season-2-million-dollars-but-the-game-announcement',
|
'url': 'https://roosterteeth.com/watch/million-dollars-but-season-2-million-dollars-but-the-game-announcement',
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
}]
|
}]
|
||||||
|
_EPISODE_BASE_URL = 'https://svod-be.roosterteeth.com/api/v1/episodes/'
|
||||||
|
|
||||||
def _login(self):
|
def _login(self):
|
||||||
username, password = self._get_login_info()
|
username, password = self._get_login_info()
|
||||||
if username is None:
|
if username is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
login_page = self._download_webpage(
|
try:
|
||||||
self._LOGIN_URL, None,
|
self._download_json(
|
||||||
note='Downloading login page',
|
'https://auth.roosterteeth.com/oauth/token',
|
||||||
errnote='Unable to download login page')
|
None, 'Logging in', data=urlencode_postdata({
|
||||||
|
'client_id': '4338d2b4bdc8db1239360f28e72f0d9ddb1fd01e7a38fbb07b4b1f4ba4564cc5',
|
||||||
login_form = self._hidden_inputs(login_page)
|
'grant_type': 'password',
|
||||||
|
|
||||||
login_form.update({
|
|
||||||
'username': username,
|
'username': username,
|
||||||
'password': password,
|
'password': password,
|
||||||
})
|
}))
|
||||||
|
except ExtractorError as e:
|
||||||
login_request = self._download_webpage(
|
msg = 'Unable to login'
|
||||||
self._LOGIN_URL, None,
|
if isinstance(e.cause, compat_HTTPError) and e.cause.code == 401:
|
||||||
note='Logging in',
|
resp = self._parse_json(e.cause.read().decode(), None, fatal=False)
|
||||||
data=urlencode_postdata(login_form),
|
if resp:
|
||||||
headers={
|
error = resp.get('extra_info') or resp.get('error_description') or resp.get('error')
|
||||||
'Referer': self._LOGIN_URL,
|
|
||||||
})
|
|
||||||
|
|
||||||
if not any(re.search(p, login_request) for p in (
|
|
||||||
r'href=["\']https?://(?:www\.)?roosterteeth\.com/logout"',
|
|
||||||
r'>Sign Out<')):
|
|
||||||
error = self._html_search_regex(
|
|
||||||
r'(?s)<div[^>]+class=(["\']).*?\balert-danger\b.*?\1[^>]*>(?:\s*<button[^>]*>.*?</button>)?(?P<error>.+?)</div>',
|
|
||||||
login_request, 'alert', default=None, group='error')
|
|
||||||
if error:
|
if error:
|
||||||
raise ExtractorError('Unable to login: %s' % error, expected=True)
|
msg += ': ' + error
|
||||||
raise ExtractorError('Unable to log in')
|
self.report_warning(msg)
|
||||||
|
|
||||||
def _real_initialize(self):
|
def _real_initialize(self):
|
||||||
|
if self._get_cookies(self._EPISODE_BASE_URL).get('rt_access_token'):
|
||||||
|
return
|
||||||
self._login()
|
self._login()
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
display_id = self._match_id(url)
|
display_id = self._match_id(url)
|
||||||
api_episode_url = 'https://svod-be.roosterteeth.com/api/v1/episodes/%s' % display_id
|
api_episode_url = self._EPISODE_BASE_URL + display_id
|
||||||
|
|
||||||
try:
|
try:
|
||||||
m3u8_url = self._download_json(
|
m3u8_url = self._download_json(
|
||||||
|
|
Loading…
Reference in a new issue