artyshko / smd

Spotify Music Downloader
MIT License
1.36k stars 236 forks source link

sys.stdout set to None prevents ffmpeg download #71

Open dioraman opened 4 years ago

dioraman commented 4 years ago

Hi all!

TL;DR sys.stdout set to None prevents ffmpeg download and causes a lot of troubles, e.g. here #3 #8 #13 #17 #23 #40 #49 #62 #66 .

Longform This line (later referred as THE line): https://github.com/artyshko/smd/blob/dba1b59af0a58c14954b11ed262a9b3b4205617c/youtube.py#L15 sets sys.stdout to None, raising conflicts with moviepy/imageio. imageio indeed uses stdout for the downloading progress. Indeed, an AttributeError is raised here: https://github.com/imageio/imageio/blob/23cdcf5e62aceb1a32ee37e529eb731612b98298/imageio/core/fetching.py#L168 as follows (imageio/core/util.py, line 407, in _start): AttributeError: 'NoneType' object has no attribute 'write'

User cannot read the error since this: https://github.com/imageio/imageio/blob/23cdcf5e62aceb1a32ee37e529eb731612b98298/imageio/core/fetching.py#L176 always assumes an IOError as suggested here: https://github.com/imageio/imageio/blob/23cdcf5e62aceb1a32ee37e529eb731612b98298/imageio/core/fetching.py#L184 . In the end, user is misled as shown in .

How to fix it As far as I understand, the only purpose of THE line is to prevent intro pygame information to be printed in the stdout. If so, changing the environment variable 'PYGAME_HIDE_SUPPORT_PROMPT' to "hide" might be enough.

voidoak commented 3 years ago

I was about to post this very issue, after debugging and crawling backwards through the codebase for about an hour or two. It'll have been a year in two weeks from now since this issue was posted, yet no fix. Seems to be a well built project, yet they've ignored this. I'm on debian 10, buster, and I wonder if this has just not been a common issue for others. I've corrected it in my local version. I doubt we'll see any updates to the original repo as it's been a good two years since the last commit (disregarding the README commit). Hope they fix this, seems like a lot of people have tried and failed to use this due to the error.