aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/extractor/viki.py
diff options
context:
space:
mode:
authorfnord <fnord@fnord.mobi>2015-06-25 00:34:46 -0500
committerfnord <fnord@fnord.mobi>2015-06-25 00:34:46 -0500
commitaa5740fb61d388754e9278a3e38de12203c1b89d (patch)
tree8195c113270d167f57225bdaa6f89df807341968 /youtube_dl/extractor/viki.py
parentda92eeae42f556926cb676b3c14e270603b7e38e (diff)
parent18b5e1e5348ba3a6d1b6a98e97217eebb3d32a1e (diff)
Merge remote-tracking branch 'origin/master' into pr-bbcnews
Diffstat (limited to 'youtube_dl/extractor/viki.py')
-rw-r--r--youtube_dl/extractor/viki.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/youtube_dl/extractor/viki.py b/youtube_dl/extractor/viki.py
index 52d10d242..51cdc6b65 100644
--- a/youtube_dl/extractor/viki.py
+++ b/youtube_dl/extractor/viki.py
@@ -28,11 +28,15 @@ class VikiBaseIE(InfoExtractor):
_NETRC_MACHINE = 'viki'
+ _token = None
+
def _prepare_call(self, path, timestamp=None, post_data=None):
path += '?' if '?' not in path else '&'
if not timestamp:
timestamp = int(time.time())
query = self._API_QUERY_TEMPLATE % (path, self._APP, timestamp)
+ if self._token:
+ query += '&token=%s' % self._token
sig = hmac.new(
self._APP_SECRET.encode('ascii'),
query.encode('ascii'),
@@ -76,10 +80,14 @@ class VikiBaseIE(InfoExtractor):
'password': password,
}
- self._call_api(
+ login = self._call_api(
'sessions.json', None,
'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):
IE_NAME = 'viki'