Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[twitch.tv][includes workaround + fix] KeyError('redirect',) when downloading with username/password #14090

Closed
Gorrrg opened this issue Sep 1, 2017 · 15 comments

Comments

@Gorrrg
Copy link

@Gorrrg Gorrrg commented Sep 1, 2017

  • I've verified and I assure that I'm running youtube-dl 2017.08.27.1
  • At least skimmed through the README, most notably the FAQ and BUGS sections
  • Searched the bugtracker for similar issues including closed ones
  • Bug report (encountered problems with youtube-dl)
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['--add-metadata', '--write-description', '--write-thumbnail', '--ignore-errors', '--username', 'PRIVATE', '--password', 'PRIVATE', '--cookies', 'cookies.txt', '--verbose', 'https://www.twitch.tv/PRIVATE/videos/all']
[debug] Encodings: locale cp1252, fs mbcs, out cp850, pref cp1252
[debug] youtube-dl version 2017.08.27.1
[debug] Python version 3.4.4 - Windows-7-6.1.7601-SP1
[debug] exe versions: ffmpeg 3.2, ffprobe 3.2
[debug] Proxy map: {}
[twitch:vod] Downloading login page
[twitch:vod] Logging in as PRIVATE
ERROR: An extractor error has occurred. (caused by KeyError('redirect',)); please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
Traceback (most recent call last):
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmp_2hklmx2\build\youtube_dl\extractor\common.py", line 433, in extract
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmp_2hklmx2\build\youtube_dl\extractor\common.py", line 391, in initialize
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmp_2hklmx2\build\youtube_dl\extractor\twitch.py", line 56, in _real_initialize
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmp_2hklmx2\build\youtube_dl\extractor\twitch.py", line 106, in _login
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmp_2hklmx2\build\youtube_dl\extractor\twitch.py", line 91, in login_step
KeyError: 'redirect'
Traceback (most recent call last):
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmp_2hklmx2\build\youtube_dl\extractor\common.py", line 433, in extract
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmp_2hklmx2\build\youtube_dl\extractor\common.py", line 391, in initialize
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmp_2hklmx2\build\youtube_dl\extractor\twitch.py", line 56, in _real_initialize
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmp_2hklmx2\build\youtube_dl\extractor\twitch.py", line 106, in _login
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmp_2hklmx2\build\youtube_dl\extractor\twitch.py", line 91, in login_step
KeyError: 'redirect'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmp_2hklmx2\build\youtube_dl\YoutubeDL.py", line 776, in extract_info
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmp_2hklmx2\build\youtube_dl\extractor\common.py", line 447, in extract
youtube_dl.utils.ExtractorError: An extractor error has occurred. (caused by KeyError('redirect',)); please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.

When you try to use login credentials using --username and --password on Twitch.tv now, youtube-dl gets redirected and aborts downloading the video(s).

A workaround is to create a cookies.txt file using --cookies together with --username and --password once (it gets created despite the redirect error) and then invoke youtube-dl a second time without the --username and --password command options but only using --cookies cookies.txt.

Being able to use login credentials or cookies with youtube-dl is important because some streamers make their VODs only available to subscribers.

Also note that this bug is reproducable with any Twitch.tv VOD not just sub-only VODs, all it takes is trying to use --username and --password for the redirect error to occur.

@dstftw
Copy link
Collaborator

@dstftw dstftw commented Sep 1, 2017

Post the output of --dump-pages.

@Gorrrg
Copy link
Author

@Gorrrg Gorrrg commented Sep 1, 2017

Not a big surprise it gets redirected to a login page:

<!DOCTYPE html>
<html lang="en" data-passport-version="5">
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://passport-cdn.ttvnw.net/styles/passport_7d75a70bb2509541dcc0b94c1212304a.css" />
	<link rel="shortcut icon" href="../assets/img/favicon.png" type="image/x-icon"/>
  <title>Login</title>

	
	
	

  
    <base target="_self" />
  
</head>

<body class="kraken-page" >
  <div class="container" role="main">
    <div class="authorize">
      <div class="wrap">
        
          

<div class="header clearfix">
  <a id="header_logo">
    <svg class="svg-logo_twitch" version="1.1" viewBox="-2.5 0 100 50" x="0px" y="0px">
      <path clip-rule="evenodd" d="M88,5h-6V0h-9l-6,5h-5.5L59,7.5V5h-5V0H36v5H16l-5-5H0v22l5,5.25L14,32h6v-1.5l3,1.5h12l2-3l1,3h7v-3l3,3h8l0.5-3l2.5,3h10l3-3v3h4l3-3v3h7l7-6V10L88,5z M13,13H8v6h5v6H6l-4-4V2h6v5h5V13z M36,21.5L32.5,25H15V7h6v12h2V7h6v12h2V7h5V21.5z M44,25h-6V7h6V25z M44,5h-6V2h6V5z M57,13h-5v6h5v6h-7l-4-4V2h6v5h5V13z M72,13h-7v6h7v6h-9l-4-4V11l4-4h9V13z M91,25h-6V13h-5v12h-6V2h6v5h7l4,4V25z" fill-rule="evenodd"></path>
    </svg>
  </a>
</div>


        
        <div class="card">
          <div class="text-content">
            
              
                <div class="item">
                  <button class="fb_button button" disabled>
                    <svg width="18" height="18" viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg"><path d="M16.936 0H.99C.442 0 0 .443 0 .99v15.946c0 .547.443.99.99.99h8.585v-6.942H7.24V8.28h2.335V6.282c0-2.315 1.414-3.576 3.48-3.576.99 0 1.84.074 2.087.107v2.42H13.71c-1.124 0-1.342.534-1.342 1.317v1.73h2.68l-.35 2.704h-2.33v6.942h4.568c.547 0 .99-.443.99-.99V.99c0-.547-.443-.99-.99-.99" fill="#FFF" fill-rule="evenodd"/></svg>
                      <span>Connect with Facebook</span>
                  </button>
									<input type="hidden" name="facebook" />
                  <input type="hidden" name="facebook_submit_url" value="/facebook_login/new" />
                </div>
              
              
                
    <div class="item">
      <ul class="tabs">
        <li id="login_tab" class="tab selected"><a target="_self" href="#">Log In</a></li>
        <li id="signup_tab" class="tab "><a target="_self" href="/signup/new?client_id=PRIVATE&amp;embed=0&amp;error_code=&amp;redirect_path=https%3A%2F%2Fwww.twitch.tv%2F&amp;style=&amp;sudo_reason=&amp;username=">Sign Up</a></li>
      </ul>
    </div>

              
            
            <div class="item">
              
              
              <input type="hidden" name="request_id" value="PRIVATE" />
              <input type="hidden" name="origin_uri" value="" />
              <input type="hidden" name="redirect_path" value="https://www.twitch.tv/" />
              <input id="authenticity_token" type="hidden" value="PRIVATE" />
              


  <form method="post" action="/sessions/new" id="loginForm" class="col-md-6">

  

  

<input type="hidden" name="scope" value="" />
<input type="hidden" name="client_id" value="PRIVATE" />
<input type="hidden" name="redirect_uri" value="" />
<input type="hidden" name="response_type" value="" />
<input type="hidden" name="state" value="" />
<input type="hidden" name="nonce" value="" />
<input type="hidden" name="kraken_oidc_nonce" value="" />



  <input type="hidden" name="embed" value="false" />
  <input type="hidden" name="time_to_submit" value="" />
  
    <div class="field item">
        <label for="username">Username</label>
        <input autocapitalize="none" type="text" name="username" id="username" class="text" value="" />
    </div>
  

    <div class="field item" id="password">
        <label for="password">Password</label>
        <input autocapitalize="none" type="password" name="password" class="text" />
        <div class="help sub">
          <a id="reset" href="/password_resets/new?client_id=PRIVATE" target="_blank" class="small" >Trouble logging in?</a>
        </div>
    </div>
  <div class="buttons">
    <button class="primary button js-login-button" type="submit">
      <span class="js-login-text">
        Log In
      </span>
    </button>
  </div>
</form>

            </div>
          </div>
        </div>
      </div>

      
      <div id="fb-root"></div>
    </div>
  </div>

  
<img class="tracking-pixel" src="/client_event/new?client_id=PRIVATE&title=Login"/>

  
	<input type="hidden" name="show_captcha" value="false" />
	<input type="hidden" name="lang" value="en" />
	<script src="https://passport-cdn.ttvnw.net/javascripts/common_08568d77854b5134d262.js"></script>
  <script src="https://passport-cdn.ttvnw.net/javascripts/login_8d4e602fa2b9960106ff.js"></script>
</body>
@Strandtasche
Copy link

@Strandtasche Strandtasche commented Sep 2, 2017

I have the same problem. The described workaround also works for me. Thanks @Gorrrg!

@Gorrrg Gorrrg closed this Sep 2, 2017
@Gorrrg Gorrrg reopened this Sep 2, 2017
@dglo
Copy link

@dglo dglo commented Sep 8, 2017

Looks like the response includes 'redirect_path' now. Changing the 'redirect_url = urljoin(...)' line to this fixed the problem for me:

        if 'redirect_path' in response:
            redirect_url = urljoin(post_url, response['redirect_path'])
        else:
            redirect_url = urljoin(post_url, response['redirect'])
@Gorrrg Gorrrg changed the title [twitch.tv][includes workaround] KeyError('redirect',) when downloading with username/password [twitch.tv][includes workaround + fix] KeyError('redirect',) when downloading with username/password Sep 8, 2017
@Ajedi32
Copy link

@Ajedi32 Ajedi32 commented Sep 21, 2017

Thanks, I'm having the same issue. The workaround worked for me.

@rien333
Copy link

@rien333 rien333 commented Sep 22, 2017

Can someone help me with the workaround?

I tried:

$ youtube-dl --password 'my-password' --username 'my-username' --cookies cookies.txt 'url'
[fails with the error from OP]
$ youtube-dl --cookies cookies.txt 'url'
[twitch:vod] 176220025: Downloading vod info JSON
[twitch:vod] 176220025: Downloading vod access token
[twitch:vod] 176220025: Downloading m3u8 information
ERROR: Failed to download m3u8 information: HTTP Error 403: ERROR (caused by HTTPError()); please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.

I have the newest version and all. Gist to verbose output can be found here.

@Gorrrg
Copy link
Author

@Gorrrg Gorrrg commented Sep 22, 2017

Error 403 means that you have successfully authenticated but you don't have permission to acess that resource.

@stephenwade
Copy link

@stephenwade stephenwade commented Oct 7, 2017

What can I do to help get this fixed? I'm getting the same error.

@airminer
Copy link

@airminer airminer commented Dec 13, 2017

I'm getting the same error:

[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['--verbose', '--username', 'PRIVATE', '-F', 'https://www.twitch.tv/videos/208999541']
Type account password and press [Return]:
[debug] Encodings: locale cp1250, fs mbcs, out cp852, pref cp1250
[debug] youtube-dl version 2017.12.10
[debug] Python version 3.4.4 - Windows-10-10.0.15063
[debug] exe versions: ffmpeg N-79690-g78baa45, ffprobe N-79690-g78baa45
[debug] Proxy map: {}
[twitch:vod] Downloading login page
[twitch:vod] Logging in
ERROR: An extractor error has occurred. (caused by KeyError('redirect',)); please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
Traceback (most recent call last):
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmp9arpqqmf\build\youtube_dl\extractor\common.py", line 436, in extract
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmp9arpqqmf\build\youtube_dl\extractor\common.py", line 394, in initialize
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmp9arpqqmf\build\youtube_dl\extractor\twitch.py", line 56, in _real_initialize
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmp9arpqqmf\build\youtube_dl\extractor\twitch.py", line 106, in _login
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmp9arpqqmf\build\youtube_dl\extractor\twitch.py", line 91, in login_step
KeyError: 'redirect'
Traceback (most recent call last):
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmp9arpqqmf\build\youtube_dl\extractor\common.py", line 436, in extract
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmp9arpqqmf\build\youtube_dl\extractor\common.py", line 394, in initialize
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmp9arpqqmf\build\youtube_dl\extractor\twitch.py", line 56, in _real_initialize
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmp9arpqqmf\build\youtube_dl\extractor\twitch.py", line 106, in _login
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmp9arpqqmf\build\youtube_dl\extractor\twitch.py", line 91, in login_step
KeyError: 'redirect'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmp9arpqqmf\build\youtube_dl\YoutubeDL.py", line 784, in extract_info
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmp9arpqqmf\build\youtube_dl\extractor\common.py", line 450, in extract
youtube_dl.utils.ExtractorError: An extractor error has occurred. (caused by KeyError('redirect',)); please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
@airminer
Copy link

@airminer airminer commented Dec 13, 2017

And here is the output with --dump-pages:

[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['--dump-pages', '--verbose', '--username', 'PRIVATE', '-F', 'https://www.twitch.tv/videos/208999541']
Type account password and press [Return]:
[debug] Encodings: locale cp1250, fs mbcs, out cp852, pref cp1250
[debug] youtube-dl version 2017.12.10
[debug] Python version 3.4.4 - Windows-10-10.0.15063
[debug] exe versions: ffmpeg N-79690-g78baa45, ffprobe N-79690-g78baa45
[debug] Proxy map: {}
[twitch:vod] Downloading login page
[twitch:vod] Dumping request to https://passport.twitch.tv/sessions/new?client_id=36926892495301a63b2e9350a38d3d6dbf72ad81e571a3ebba4687250ec8f352c70b3e91229602f73e1335528f3caa00a5cf513f484d7003784e722f2ce7a216&embed=0&error_code=&redirect_path=https%3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dGxlPUxvZ2luJnJlcXVlc3RfaWQ9MDE1Z3h1dnMzNGJnaGhpbjlqZnJib3g3anQwMXA4NXAiLz4KCiAgCgk8aW5wdXQgdHlwZT0iaGlkZGVuIiBuYW1lPSJzaG93X2NhcHRjaGEiIHZhbHVlPSJ0cnVlIiAvPgoJPGlucHV0IHR5cGU9ImhpZGRlbiIgbmFtZT0ibGFuZyIgdmFsdWU9ImVuIiAvPgoJPHNjcmlwdCBzcmM9Imh0dHBzOi8vcGFzc3BvcnQtY2RuLnR0dm53Lm5ldC9qYXZhc2NyaXB0cy9jb21tb25fZTAyMzY4M2U2ZGI2NjRhNTJlNWMuanMiPjwvc2NyaXB0PgogIDxzY3JpcHQgc3JjPSJodHRwczovL3Bhc3Nwb3J0LWNkbi50dHZudy5uZXQvamF2YXNjcmlwdHMvbG9naW5fMDkxMmNkZmNiZTZkNDU0YjkyZWIuanMiPjwvc2NyaXB0Pgo8L2JvZHk+Cg==
[twitch:vod] Logging in
[twitch:vod] Dumping request to https://passport.twitch.tv/sessions/new
eyJtZXNzYWdlIjoiQXV0aGVudGljYXRlZCBzdWNjZXNzZnVsbHkuIiwicmVkaXJlY3RfcGF0aCI6Imh0dHBzOi8vd3d3LnR3aXRjaC50di8ifQ==
ERROR: An extractor error has occurred. (caused by KeyError('redirect',)); please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
Traceback (most recent call last):
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmp9arpqqmf\build\youtube_dl\extractor\common.py", line 436, in extract
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmp9arpqqmf\build\youtube_dl\extractor\common.py", line 394, in initialize
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmp9arpqqmf\build\youtube_dl\extractor\twitch.py", line 56, in _real_initialize
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmp9arpqqmf\build\youtube_dl\extractor\twitch.py", line 106, in _login
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmp9arpqqmf\build\youtube_dl\extractor\twitch.py", line 91, in login_step
KeyError: 'redirect'
Traceback (most recent call last):
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmp9arpqqmf\build\youtube_dl\extractor\common.py", line 436, in extract
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmp9arpqqmf\build\youtube_dl\extractor\common.py", line 394, in initialize
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmp9arpqqmf\build\youtube_dl\extractor\twitch.py", line 56, in _real_initialize
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmp9arpqqmf\build\youtube_dl\extractor\twitch.py", line 106, in _login
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmp9arpqqmf\build\youtube_dl\extractor\twitch.py", line 91, in login_step
KeyError: 'redirect'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmp9arpqqmf\build\youtube_dl\YoutubeDL.py", line 784, in extract_info
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmp9arpqqmf\build\youtube_dl\extractor\common.py", line 450, in extract
youtube_dl.utils.ExtractorError: An extractor error has occurred. (caused by KeyError('redirect',)); please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
@rmanly
Copy link

@rmanly rmanly commented Jan 12, 2018

Had same issue on this page.

Past episode that requires subscription.

Cloning repo and making @dglo's change to the twitch extractor worked for me as well.

[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: [u'-v', u'-u', u'PRIVATE', u'-p', u'PRIVATE', u'https://www.twitch.tv/videos/217708370']
[debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2018.01.07
[debug] Python version 2.7.10 (CPython) - Darwin-17.3.0-x86_64-i386-64bit
[debug] exe versions: ffmpeg 3.4.1-tessus, ffprobe 3.4.1-tessus, phantomjs 2.1.1
[debug] Proxy map: {}
[twitch:vod] Downloading login page
[twitch:vod] Logging in
ERROR: An extractor error has occurred. (caused by KeyError(u'redirect',)); please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
Traceback (most recent call last):
  File "/usr/local/bin/youtube-dl/youtube_dl/extractor/common.py", line 437, in extract
    self.initialize()
  File "/usr/local/bin/youtube-dl/youtube_dl/extractor/common.py", line 395, in initialize
    self._real_initialize()
  File "/usr/local/bin/youtube-dl/youtube_dl/extractor/twitch.py", line 56, in _real_initialize
    self._login()
  File "/usr/local/bin/youtube-dl/youtube_dl/extractor/twitch.py", line 106, in _login
    'password': password,
  File "/usr/local/bin/youtube-dl/youtube_dl/extractor/twitch.py", line 91, in login_step
    redirect_url = urljoin(post_url, response['redirect'])
KeyError: u'redirect'
Traceback (most recent call last):
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 784, in extract_info
    ie_result = ie.extract(url)
  File "/usr/local/bin/youtube-dl/youtube_dl/extractor/common.py", line 451, in extract
    raise ExtractorError('An extractor error has occurred.', cause=e)
ExtractorError: An extractor error has occurred. (caused by KeyError(u'redirect',)); please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
@rmanly
Copy link

@rmanly rmanly commented Jan 12, 2018

For folks that land here that don't know exactly what to do to fix this if you have even a tiny bit of git and python knowledge you just need to modify the twitch.py extractor file after cloning the repo.

$ git diff 
diff --git a/youtube_dl/extractor/twitch.py b/youtube_dl/extractor/twitch.py
index f9164af09..69489d40d 100644
--- a/youtube_dl/extractor/twitch.py
+++ b/youtube_dl/extractor/twitch.py
@@ -88,7 +88,11 @@ class TwitchBaseIE(InfoExtractor):
                     fail(response['message'])
                 raise
 
-            redirect_url = urljoin(post_url, response['redirect'])
+            if 'redirect_path' in response:
+                redirect_url = urljoin(post_url, response['redirect_path'])
+            else:
+                redirect_url = urljoin(post_url, response['redirect'])
+
             return self._download_webpage_handle(
                 redirect_url, None, 'Downloading login redirect page',
                 headers=headers)

Then you can download the vid you want by running a command like this from the top level of the repo.

$ python -m youtube_dl -u NAME -p PASS https://www.twitch.tv/videos/217708370

@Ajedi32
Copy link

@Ajedi32 Ajedi32 commented Jan 12, 2018

@rmanly @dglo If that change fixes the problem I suggest you submit it as PR to the repo and solve this issue for everyone, permanently.

@mikhailbot
Copy link

@mikhailbot mikhailbot commented Jan 12, 2018

Had the same issue and the initial cookies.txt workaround works for downloading VODs that require a subscription (which I have).

Version: 2018.01.07
Videos: https://www.twitch.tv/geekandsundry/

@tobinjt
Copy link

@tobinjt tobinjt commented Jan 15, 2018

I've sent a pull request to fix this: #15264

@dstftw dstftw closed this in 1370dba Jan 16, 2018
@dstftw dstftw removed the cant-reproduce label Jan 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
You can’t perform that action at this time.