Skip to content

Commit

Permalink
[twitch] Modernize
Browse files Browse the repository at this point in the history
  • Loading branch information
dstftw committed Aug 21, 2016
1 parent 92d4cfa commit b1e676f
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions youtube_dl/extractor/twitch.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
orderedSet,
parse_duration,
parse_iso8601,
sanitized_Request,
urlencode_postdata,
)

Expand Down Expand Up @@ -50,8 +49,8 @@ def _download_json(self, url, video_id, note='Downloading JSON metadata'):
for cookie in self._downloader.cookiejar:
if cookie.name == 'api_token':
headers['Twitch-Api-Token'] = cookie.value
request = sanitized_Request(url, headers=headers)
response = super(TwitchBaseIE, self)._download_json(request, video_id, note)
response = super(TwitchBaseIE, self)._download_json(
url, video_id, note, headers=headers)
self._handle_error(response)
return response

Expand Down Expand Up @@ -82,11 +81,10 @@ def _login(self):
if not post_url.startswith('http'):
post_url = compat_urlparse.urljoin(redirect_url, post_url)

request = sanitized_Request(
post_url, urlencode_postdata(login_form))
request.add_header('Referer', redirect_url)
response = self._download_webpage(
request, None, 'Logging in as %s' % username)
post_url, None, 'Logging in as %s' % username,
data=urlencode_postdata(login_form),
headers={'Referer': redirect_url})

error_message = self._search_regex(
r'<div[^>]+class="subwindow_notice"[^>]*>([^<]+)</div>',
Expand Down

0 comments on commit b1e676f

Please sign in to comment.