scdl-org / scdl

Soundcloud Music Downloader
GNU General Public License v2.0
3.29k stars 331 forks source link

Log to stderr, download to stdout #493

Closed es3n1n closed 2 months ago

es3n1n commented 2 months ago

This was heavily inspired by the youtube-dl/yt-dlp features that allow you to download stuff to the stdout instead of files. This is also how ffmpeg logs their stuff(everything goes to the stderr).

I propose redirecting all of the logs to stderr and add an option to download files to stdout. This feature essentially allows users of the scdl that embed scdl into their projects to redirect the stdout to a buffer using the contextlib.redirect_stdout function and then directly use the buffer without any overhead from the I/O operations. So basically via this trick instead of downloading to a file you're downloading to a buffer, very neat if you ask me.

I would be happy to implement that but before implementing I wanted to ask what you guys, the maintainers think about such changes. From the user perspective of the CLI tool I don't think anything would change for them, but this might change stuff for people who are embedding scdl in their projects not directly but via calling the cli tool.

7x11x13 commented 2 months ago

Sounds like a good idea to me! I'm pretty sure logging already goes to stderr by default, so I don't think this will break anything.

es3n1n commented 2 months ago

Added in 8974a997fcef6de13693306a01d35f5dfe6ec33d