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

"local variable 'err' referenced before assignment" in /downloader/http.py#L133 #15305

Closed
glenn-slayden opened this issue Jan 18, 2018 · 5 comments
Closed
Labels

Comments

@glenn-slayden
Copy link
Contributor

@glenn-slayden glenn-slayden commented Jan 18, 2018

In the output below, nevermind the HTTP 503 errors, but note the crash right afterwards.

This is with the pre-built Windows exe of youtube-dl version 2018.01.14, using the command as shown:

C:\>youtube-dl.exe -v -f "bestvideo[ext=mp4]+bestaudio[ext=m4a]" https://www.youtube.com/watch?v=hwpChyWCUaw

[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['-v', '-f', 'bestvideo[ext=mp4]+bestaudio[ext=m4a]', 'https://www.youtube.com/watch?v=hwpChyWCUaw']
[debug] Encodings: locale cp1252, fs mbcs, out cp437, pref cp1252
[debug] youtube-dl version 2018.01.14
[debug] Python version 3.4.4 (CPython) - Windows-10-10.0.16299
[debug] exe versions: none
[debug] Proxy map: {}

[youtube] hwpChyWCUaw: Downloading webpage
[youtube] hwpChyWCUaw: Downloading video info webpage
[youtube] hwpChyWCUaw: Extracting video information
WARNING: You have requested multiple formats but ffmpeg or avconv are not installed. The formats won't be merged.
[debug] Invoking downloader on 'https://r3---sn-nx5e6ne6.googlevideo.com/videoplayback?
    keepalive=yes
    requiressl=yes
    ipbits=0
    sparams=aitags,clen,dur,ei,gir,id,initcwndbps,ip,ipbits,itag,keepalive,lmt,mime,mm,mn,ms,mv,pl,requiressl,source,expire
    ms=au
    mv=m
    source=youtube
    lmt=1444727072053666
    ip=■.■.■.■
    key=yt6
    expire=1516288332
    id=o-ACmhCn5_22MehSMROOpe5aNt0MqGbxzzCw532bVMgW-C
    dur=163.133
    mn=sn-nx5e6ne6
    mm=31
    gir=yes
    itag=137
    clen=76469870
    ei=7GRgWvHrMZeY-QPSobTYDA
    pl=16
    mt=1516266635
    beids=[9466591]
    initcwndbps=1463750
    aitags=133,134,135,136,137,160,242,243,244,247,248,278
    mime=video/mp4
    signature=DF872E89C2925B72C83DAC6253EF55FB630C6C70.211ACDCFC7F24F3ACF6FB5A5DF6B908711C6F137
    ratebypass=yes'
[download] Got server HTTP error: HTTP Error 503: Service Unavailable. Retrying (attempt 1 of 10)...
[download] Got server HTTP error: HTTP Error 503: Service Unavailable. Retrying (attempt 2 of 10)...
[download] Got server HTTP error: HTTP Error 503: Service Unavailable. Retrying (attempt 3 of 10)...
[download] Got server HTTP error: HTTP Error 503: Service Unavailable. Retrying (attempt 4 of 10)...
[download] Got server HTTP error: HTTP Error 503: Service Unavailable. Retrying (attempt 5 of 10)...
[download] Got server HTTP error: HTTP Error 503: Service Unavailable. Retrying (attempt 6 of 10)...
[download] Got server HTTP error: HTTP Error 503: Service Unavailable. Retrying (attempt 7 of 10)...
[download] Got server HTTP error: HTTP Error 503: Service Unavailable. Retrying (attempt 8 of 10)...
[download] Got server HTTP error: HTTP Error 503: Service Unavailable. Retrying (attempt 9 of 10)...
[download] Got server HTTP error: HTTP Error 503: Service Unavailable. Retrying (attempt 10 of 10)...
ERROR: giving up after 10 retries
  File "__main__.py", line 19, in 
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmpo17hktrm\build\youtube_dl\__init__.py", line 465, in main
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmpo17hktrm\build\youtube_dl\__init__.py", line 455, in _real_main
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmpo17hktrm\build\youtube_dl\YoutubeDL.py", line 1988, in download
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmpo17hktrm\build\youtube_dl\YoutubeDL.py", line 795, in extract_info
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmpo17hktrm\build\youtube_dl\YoutubeDL.py", line 849, in process_ie_result
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmpo17hktrm\build\youtube_dl\YoutubeDL.py", line 1622, in process_video_result
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmpo17hktrm\build\youtube_dl\YoutubeDL.py", line 1889, in process_info
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmpo17hktrm\build\youtube_dl\YoutubeDL.py", line 1834, in dl
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmpo17hktrm\build\youtube_dl\downloader\common.py", line 361, in download
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmpo17hktrm\build\youtube_dl\downloader\http.py", line 296, in real_download
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmpo17hktrm\build\youtube_dl\downloader\common.py", line 163, in report_error
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmpo17hktrm\build\youtube_dl\YoutubeDL.py", line 612, in report_error
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmpo17hktrm\build\youtube_dl\YoutubeDL.py", line 574, in trouble

C:\>

As I mentioned above (and as you can see), the above output is using your latest official Windows release, but based on a separate private branch I have, I tracked the problem a little more, and I believe the actual error might be:

UnboundLocalError: local variable 'err' referenced before assignment

and it might be happening at...

https://github.com/rg3/youtube-dl/blob/master/youtube_dl/downloader/http.py#L133

I apologize in advance if that additional information is not correct and leads you astray. If that is the case, please feel free to change the title of the issue accordingly.

@dstftw
Copy link
Collaborator

@dstftw dstftw commented Jan 18, 2018

Nothing is wrong in your log. The video is unavailable due to server side 503 error that is clearly stated in the log.

UnboundLocalError: local variable 'err' referenced before assignment

This is not possible in the original code since err is well defined at line 94.

@dstftw dstftw closed this Jan 18, 2018
@dstftw dstftw added the invalid label Jan 18, 2018
@glenn-slayden
Copy link
Contributor Author

@glenn-slayden glenn-slayden commented Jan 18, 2018

Did you try it? It crashes out of Python...

The error was reported against your .EXE build, nothing to do with my private build.

@glenn-slayden
Copy link
Contributor Author

@glenn-slayden glenn-slayden commented Jan 18, 2018

I'd assume that an exception and crash should never happen, regardless of the 503 error.

File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmpo17hktrm\build\youtube_dl\YoutubeDL.py", line 574, in trouble

As you can see from the filename, it's an exception in the embedded Python from your released build.

@glenn-slayden
Copy link
Contributor Author

@glenn-slayden glenn-slayden commented Jan 18, 2018

@dstftw For example, if I were using --ignore-errors (which I do--but I was courteous enough to go to the trouble of reducing this to a minimal example), then youtube-dl wouldn't (and doesn't) continue downloading other videos from a playlist... because it has crashed.

@dstftw
Copy link
Collaborator

@dstftw dstftw commented Jan 18, 2018

Again: nothing crashed. You are using verbose output that prints out a traceback.

@ytdl-org ytdl-org locked and limited conversation to collaborators Jan 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

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