mirror of
https://github.com/l1ving/youtube-dl
synced 2025-02-10 23:12: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:
|
||||
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(
|
||||
self._LOGIN_URL, None,
|
||||
note='Logging in',
|
||||
@ -70,6 +75,16 @@ class RoosterTeethIE(InfoExtractor):
|
||||
if not self._ACCESS_TOKEN:
|
||||
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):
|
||||
self._login()
|
||||
|
||||
@ -168,3 +183,9 @@ class RoosterTeethIE(InfoExtractor):
|
||||
video_id,
|
||||
**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