mirror of
https://github.com/l1ving/youtube-dl
synced 2024-12-21 23:52:51 +08:00
[viki] Pass session token around (#6005)
This commit is contained in:
parent
edcd2d665b
commit
16d6973f8a
@ -28,11 +28,15 @@ class VikiBaseIE(InfoExtractor):
|
|||||||
|
|
||||||
_NETRC_MACHINE = 'viki'
|
_NETRC_MACHINE = 'viki'
|
||||||
|
|
||||||
|
_token = None
|
||||||
|
|
||||||
def _prepare_call(self, path, timestamp=None, post_data=None):
|
def _prepare_call(self, path, timestamp=None, post_data=None):
|
||||||
path += '?' if '?' not in path else '&'
|
path += '?' if '?' not in path else '&'
|
||||||
if not timestamp:
|
if not timestamp:
|
||||||
timestamp = int(time.time())
|
timestamp = int(time.time())
|
||||||
query = self._API_QUERY_TEMPLATE % (path, self._APP, timestamp)
|
query = self._API_QUERY_TEMPLATE % (path, self._APP, timestamp)
|
||||||
|
if self._token:
|
||||||
|
query += '&token=%s' % self._token
|
||||||
sig = hmac.new(
|
sig = hmac.new(
|
||||||
self._APP_SECRET.encode('ascii'),
|
self._APP_SECRET.encode('ascii'),
|
||||||
query.encode('ascii'),
|
query.encode('ascii'),
|
||||||
@ -76,10 +80,14 @@ class VikiBaseIE(InfoExtractor):
|
|||||||
'password': password,
|
'password': password,
|
||||||
}
|
}
|
||||||
|
|
||||||
self._call_api(
|
login = self._call_api(
|
||||||
'sessions.json', None,
|
'sessions.json', None,
|
||||||
'Logging in as %s' % username, post_data=login_form)
|
'Logging in as %s' % username, post_data=login_form)
|
||||||
|
|
||||||
|
self._token = login.get('token')
|
||||||
|
if not self._token:
|
||||||
|
self.report_warning('Unable to get session token, login has probably failed')
|
||||||
|
|
||||||
|
|
||||||
class VikiIE(VikiBaseIE):
|
class VikiIE(VikiBaseIE):
|
||||||
IE_NAME = 'viki'
|
IE_NAME = 'viki'
|
||||||
|
Loading…
Reference in New Issue
Block a user