sdaqo / anipy-cli

Little tool in python to watch and download anime from the terminal (the better way to watch anime). Also applicable as an API
https://sdaqo.github.io/anipy-cli
GNU General Public License v3.0
270 stars 40 forks source link

"UnboundLocalError: local variable 'progress_bar' referenced before assignment" #130

Closed S0litaire closed 8 months ago

S0litaire commented 1 year ago

Describe the bug Error while downloading a anime locally. I get the error with or without the "-f" flag. The file does seem to download, so not sure what it's trying to with the progress bar.

Using it without the -D flag I can stream file with on issues.

To Reproduce

s0l@asus:~/build/anipy-cli$ ./anipy_cli.py -D
***Download Mode***
Downloads are stored in: /mnt/Plex/anime
Search MyAnimeList for anime in Season? (y|n): 
>> n
Search: the witch from mercury
Add another search: (y|n)
n

Current:  the witch from mercury
[1] Kidou Senshi Gundam: Suisei no Majo (Dub)
[2] Mobile Suit Gundam: The Witch from Mercury
[3] Kidou Senshi Gundam: Suisei no Majo Season 2 (Dub)
[4] Mobile Suit Gundam: The Witch from Mercury Season 2
[5] Mobile Suit Gundam: The Witch from Mercury - Prologue
[6] Mobile Suit Gundam: The Witch from Mercury - Prologue (Dub)
Enter Number: 4
Episode (Range with '-') [1-6]
>> 5
--------------------
Downloading: Mobile Suit Gundam: The Witch from Mercury Season 2 EP: 5 - auto
Type: m3u8
Downloader: ffmpeg
Running: ffmpeg -y -headers referer:https://playtaku.online/streaming.php?id=MjA0MDc2&title=Mobile+Suit+Gundam%3A+The+Witch+from+Mercury+Season+2+Episode+5&typesub=SUB -i https://ta-052.agucdn.com/1ab5d45273a9183bebb58eb74d5722d8ea6384f350caf008f08cf018f1f0566d0cb82a2a799830d1af97cd3f4b6a9a81ef3aed2fb783292b1abcf1b8560a1d1aa308008b88420298522a9f761e5aa1024fbe74e5aa853cfc933cd1219327d1232e91847a185021b184c027f97ae732b3708ee6beb80ba5db6628ced43f1196fe/7c1af56052828e468e2a5e9100898e11/ep.5.1683453457.m3u8 -vcodec copy -acodec copy -scodec mov_text -c copy /mnt/Plex/anime/Mobile Suit Gundam: The Witch from Mercury Season 2/Mobile Suit Gundam: The Witch from Mercury Season 2 - 5 - auto.mp4 -hide_banner -loglevel verbose
Traceback (most recent call last):
  File "/home/s0l/.local/lib/python3.10/site-packages/better_ffmpeg_progress/better_ffmpeg_progress.py", line 111, in run
    progress_bar.close()
UnboundLocalError: local variable 'progress_bar' referenced before assignment

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/s0l/build/anipy-cli/./anipy_cli.py", line 14, in <module>
    main()
  File "/home/s0l/build/anipy-cli/./anipy_cli.py", line 8, in main
    cli.run_cli()
  File "/home/s0l/build/anipy-cli/anipy_cli/cli/cli.py", line 37, in run_cli
    cli_class(options=args, rpc_client=rpc_client).run()
  File "/home/s0l/build/anipy-cli/anipy_cli/cli/clis/base_cli.py", line 36, in run
    self.process()
  File "/home/s0l/build/anipy-cli/anipy_cli/cli/clis/download_cli.py", line 86, in process
    download(entry, self.options.quality, self.options.ffmpeg).download()
  File "/home/s0l/build/anipy-cli/anipy_cli/download.py", line 90, in download
    self.ffmpeg_dl()
  File "/home/s0l/build/anipy-cli/anipy_cli/download.py", line 128, in ffmpeg_dl
    ffmpeg_process.run(
  File "/home/s0l/.local/lib/python3.10/site-packages/better_ffmpeg_progress/better_ffmpeg_progress.py", line 123, in run
    progress_bar.close()
UnboundLocalError: local variable 'progress_bar' referenced before assignment

Expected behavior File to be downloaded.

Info

Name: anipy-cli
Version: 2.7.20
Summary: Little tool in python to watch anime from the terminal (the better way to watch anime)
Home-page: https://github.com/sdaqo/anipy-cli
Author: sdaqo
Author-email: sdaqo.dev@protonmail.com
License: GPL-3.0
Location: /home/s0l/.local/lib/python3.10/site-packages
Requires: beautifulsoup4, better-ffmpeg-progress, m3u8, moviepy, pycryptodomex, pypresence, python-dateutil, python-mpv, pyyaml, requests, setuptools, tqdm
Required-by: 

Platform

Additional context

pip show better-ffmpeg-progress

Name: better-ffmpeg-progress
Version: 2.1.0
Summary: Run FFmpeg & see percentage progress + ETA.
Home-page: https://github.com/CrypticSignal/better-ffmpeg-progress
Author: GitHub.com/CrypticSignal
Author-email: theaudiophile@outlook.com
License: 
Location: /home/s0l/.local/lib/python3.10/site-packages
Requires: ffmpeg-python, tqdm
Required-by: anipy-cli

ffmpeg -version

ffmpeg version 5.1.1-1ubuntu2.1 Copyright (c) 2000-2022 the FFmpeg developers
built with gcc 12 (Ubuntu 12.2.0-3ubuntu1)
configuration: --prefix=/usr --extra-version=1ubuntu2.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libglslang --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librist --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --disable-sndio --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-libplacebo --enable-shared
libavutil      57. 28.100 / 57. 28.100
libavcodec     59. 37.100 / 59. 37.100
libavformat    59. 27.100 / 59. 27.100
libavdevice    59.  7.100 / 59.  7.100
libavfilter     8. 44.100 /  8. 44.100
libswscale      6.  7.100 /  6.  7.100
libswresample   4.  7.100 /  4.  7.100
libpostproc    56.  6.100 / 56.  6.100
sdaqo commented 1 year ago

Hmm, weird. I have the same version off better-ffmpeg-progress and I can not reproduce this error. Does this still happen ? If yes, only to this specific anime or to others too?

S0litaire commented 1 year ago

It's happening with all downloads, If you can't recreate it then it looks like an issue with my install.

sdaqo commented 1 year ago

So I can not help you with your ffmpeg issues unfortunately, but it seems like your anipy-cli is using the ffmpeg downloader all the time, even without the -f flag. Do you perhaps have the ffmpeg_hls config option set to True?

S0litaire commented 1 year ago

Sorry for the delay.

ffmpeg_hls is set to False.

DragonOfShuu commented 1 year ago

Any updates or findings on this @S0litaire?

S0litaire commented 1 year ago

Any updates or findings on this @S0litaire?

Sorry for the delay!

I totally forgot about this!

Not a good solution unfortunately!

It looks like it was my system's python packages which were broken (no way to cleanly recover and get all python packages working), so only a wipe and reinstall could fix it! So i just wiped and installed Ubuntu 23.10.

So in the meantime I moved it over to a raspberry pi and left it running on that. That grabs things perfectly and I just copy over new episodes when I want to watch them.