X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=youtube_dl%2Fextractor%2Ftwitch.py;h=ab557a1a57f4936b7f93d46269607127324740bf;hb=1793d71db61acc9f6cceefbc63d7de2b558b7582;hp=b56ee2959cd92c3bb26ca57c471c049236ea63ca;hpb=ac0474f89d3e6f8c8c1fb3223a16a18a2fd02bcb;p=youtube-dl diff --git a/youtube_dl/extractor/twitch.py b/youtube_dl/extractor/twitch.py index b56ee2959..ab557a1a5 100644 --- a/youtube_dl/extractor/twitch.py +++ b/youtube_dl/extractor/twitch.py @@ -22,8 +22,8 @@ class TwitchBaseIE(InfoExtractor): _API_BASE = 'https://api.twitch.tv' _USHER_BASE = 'http://usher.twitch.tv' - _LOGIN_URL = 'https://secure.twitch.tv/user/login' - _LOGIN_POST_URL = 'https://secure-login.twitch.tv/login' + _LOGIN_URL = 'https://secure.twitch.tv/login' + _LOGIN_POST_URL = 'https://passport.twitch.tv/authorize' _NETRC_MACHINE = 'twitch' def _handle_error(self, response): @@ -59,20 +59,12 @@ class TwitchBaseIE(InfoExtractor): login_page = self._download_webpage( self._LOGIN_URL, None, 'Downloading login page') - authenticity_token = self._search_regex( - r']*>(?P[^<]+)", response) - if m: + error_message = self._search_regex( + r']+class="subwindow_notice"[^>]*>([^<]+)', + response, 'error message', default=None) + if error_message: raise ExtractorError( - 'Unable to login: %s' % m.group('msg').strip(), expected=True) + 'Unable to login. Twitch said: %s' % error_message, expected=True) + + if '>Reset your password<' in response: + self.report_warning('Twitch asks you to reset your password, go to https://secure.twitch.tv/reset/submit') def _prefer_source(self, formats): try: @@ -350,6 +346,8 @@ class TwitchStreamIE(TwitchBaseIE): 'http://www.twitch.tv/%s/profile' % channel_id, 'TwitchProfile', channel_id) + channel_id = stream.get('channel', {}).get('name') or channel_id.lower() + access_token = self._download_json( '%s/api/channels/%s/access_token' % (self._API_BASE, channel_id), channel_id, 'Downloading channel access token')