mirror of
https://github.com/l1ving/youtube-dl
synced 2025-02-11 16:52:51 +08:00
[Roosterteeth] Implement saving access token as cookie.
This commit is contained in:
parent
8cc5ae3b37
commit
990f14755a
@ -54,6 +54,11 @@ class RoosterTeethIE(InfoExtractor):
|
|||||||
if username is None:
|
if username is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
cookie = self._get_cookie('rt_access_token')
|
||||||
|
if cookie and not cookie.is_expired():
|
||||||
|
self._ACCESS_TOKEN = cookie.value
|
||||||
|
return
|
||||||
|
|
||||||
response = self._download_json(
|
response = self._download_json(
|
||||||
self._LOGIN_URL, None,
|
self._LOGIN_URL, None,
|
||||||
note='Logging in',
|
note='Logging in',
|
||||||
@ -70,6 +75,16 @@ class RoosterTeethIE(InfoExtractor):
|
|||||||
if not self._ACCESS_TOKEN:
|
if not self._ACCESS_TOKEN:
|
||||||
raise ExtractorError('Unable to log in')
|
raise ExtractorError('Unable to log in')
|
||||||
|
|
||||||
|
created_at = response.get('created_at', 0)
|
||||||
|
expires_in = response.get('expires_in', 0)
|
||||||
|
|
||||||
|
self._set_cookie(
|
||||||
|
'.roosterteeth.com',
|
||||||
|
'rt_access_token',
|
||||||
|
self._ACCESS_TOKEN,
|
||||||
|
created_at + expires_in
|
||||||
|
)
|
||||||
|
|
||||||
def _real_initialize(self):
|
def _real_initialize(self):
|
||||||
self._login()
|
self._login()
|
||||||
|
|
||||||
@ -168,3 +183,9 @@ class RoosterTeethIE(InfoExtractor):
|
|||||||
video_id,
|
video_id,
|
||||||
**kwargs
|
**kwargs
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def _get_cookie(self, name):
|
||||||
|
for cookie in self._downloader.cookiejar:
|
||||||
|
if cookie.name == name:
|
||||||
|
return cookie
|
||||||
|
return None
|
||||||
|
Loading…
Reference in New Issue
Block a user