scdl-org / scdl

Soundcloud Music Downloader
GNU General Public License v2.0
3.37k stars 338 forks source link

Issue downloading Soundcloud songs (Windows OS) #291

Closed hentaiwithsenpai closed 4 years ago

hentaiwithsenpai commented 4 years ago

Just reposting my issue here since OP closed his issue that I posted this in that was relevant to his.

When attempting to download a song i'm presented with this error.

">scdl -l https://soundcloud.com/user-650501549/spookyli-cloud-strife-prod-snook Soundcloud Downloader Found a track Retrieving more info on the track Downloading SPOOKYLI - CLOUD STRIFE (Prod. SNOOK) ffmpeg version git-2019-11-26-59d264b Copyright (c) 2000-2019 the FFmpeg developers built with gcc 9.2.1 (GCC) 20191125 configuration: --disable-static --enable-shared --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf libavutil 56. 36.100 / 56. 36.100 libavcodec 58. 62.100 / 58. 62.100 libavformat 58. 35.100 / 58. 35.100 libavdevice 58. 9.101 / 58. 9.101 libavfilter 7. 67.100 / 7. 67.100 libswscale 5. 6.100 / 5. 6.100 libswresample 3. 6.100 / 3. 6.100 libpostproc 55. 6.100 / 55. 6.100 'https://cf-hls-media.sndcdn.com/playlist/QdzeqpoPobWx.128.mp3/playlist.m3u8?Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiKjovL2NmLWhscy1tZWRpYS5zbmRjZG4uY29tL3BsYXlsaXN0L1FkemVxcG9Qb2JXeC4xMjgubXAzL3BsYXlsaXN0Lm0zdTgiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjE1NzUwNDM4ODF9fX1dfQ__: No such file or directory 'Signature' is not recognized as an internal or external command, operable program or batch file. 'Key-Pair-Id' is not recognized as an internal or external command, operable program or batch file. Setting tags... Error trying to set the tags... Cannot update utime of file SPOOKYLI - CLOUD STRIFE (Prod. SNOOK).mp3 Downloaded."

Says the song was downloaded but it wasn't

OS: Windows 10 was working untill a few days ago and your recent update didn't fix it.

silverbacknet commented 4 years ago

Yup, pretty sure Soundcloud requires cookies/params passed, which ffmpeg can't do. So scdl either has to download the file itself, pass it to ffmpeg, and then process the output, or just rip the HLS code out of ffmpeg and bypass that enormous new extra dependency entirely.

silverbacknet commented 4 years ago

Worth noting that this highlights that there isn't really any error checking, and the script claims that it was downloaded when it actually wasn't at all.

hentaiwithsenpai commented 4 years ago

Worth noting that this highlights that there isn't really any error checking, and the script claims that it was downloaded when it actually wasn't at all.

Yeah I know it wasn't downloaded actually i wrote that at the end. In the meantime though, I'm just using youtube-dl

flyingrub commented 4 years ago

Yup, pretty sure Soundcloud requires cookies/params passed, which ffmpeg can't do.

Nope, it works well on unix system, I think it's an issue with the windows terminal that does not like the special character in the URL.

Flygsand commented 4 years ago

This is an escaping issue. The Windows shell treats & as a command separator and tries to execute part of the URL as a command. Solution: replace os.system with subprocess.run (or subprocess.call if you want pre-3.5 compatibility) and you won't have this problem (as you're no longer invoking the shell, no need for shlex). It's more efficient, less prone to breakage, and more secure (what if the URL contained & rmdir C:\Windows?)

mafia808 commented 4 years ago

Solution: replace os.system with subprocess.run (or subprocess.call if you want pre-3.5 compatibility) and you won't have this problem (as you're no longer invoking the shell, no need for shlex).

Could you please expand on how to do this with an example? Thank you!

pyxelr commented 4 years ago

Worth noting that this highlights that there isn't really any error checking, and the script claims that it was downloaded when it actually wasn't at all.

Yeah I know it wasn't downloaded actually i wrote that at the end. In the meantime though, I'm just using youtube-dl

I decided to switch to youtube-dl as well. The command that will download all the metadata with a thumbnail is much longer in comparison to scdl: youtube-dl --add-metadata --embed-thumbnail -o "%(uploader)s - %(title)s.%(ext)s" + <link> but you can easily improve it with the AutoHotkey script, where you can type sc in a console window, press [SPACE] and follow it with the right hyperlink.

flyingrub commented 4 years ago

This is an escaping issue. The Windows shell treats & as a command separator and tries to execute part of the URL as a command. Solution: replace os.system with subprocess.run (or subprocess.call if you want pre-3.5 compatibility) and you won't have this problem (as you're no longer invoking the shell, no need for shlex). It's more efficient, less prone to breakage, and more secure (what if the URL contained & rmdir C:\Windows?)

I tried this, but still get an error OSError: [Errno 36] File name too long:. We might have to use a python ffmpeg library in the end.

angelfor3v3r commented 4 years ago

gonna post my changes to make it work on windows.

at least, i think this applies mostly to windows. might need more testing for the request headers issue i had... anyway:

(before)

Downloading it all ends the same
Downloading the original file.
filename : it all ends the same.wa
[################################] 61312/61312 - 00:00:04
This type of audio doesn't support tagging...
it all ends the same.wa Downloaded.

(after)

Downloading it all ends the same
Downloading the original file.
filename : it all ends the same.wav
[################################] 61312/61312 - 00:00:04
Converting to .flac...
ffmpeg -i 'it all ends the same.wav' 'it all ends the same.flac' -loglevel fatal

and finally... this is the output:

Downloading it all ends the same
Downloading the original file.
filename : it all ends the same.wav
[################################] 61312/61312 - 00:00:04
Converting to .flac...
ffmpeg -i "it all ends the same.wav" "it all ends the same.flac" -loglevel fatal
Setting tags...
Extracting date: 2019-12-06T17:58:41Z 2019-12-06 17:58:41
it all ends the same.flac Downloaded.

some extra info:

Microsoft Windows [Version 10.0.18363.476]

Y:\music\soundcloud_rips>python --version
Python 3.7.5
Ideekay commented 4 years ago

Tried both changes that angelfor3v3r suggested along with changing os.system to subprocess.run with no luck.

Still getting these:

'ffmpeg' is not recognized as an internal or external command, operable program or batch file. 'Signature' is not recognized as an internal or external command, operable program or batch file. 'Key-Pair-Id' is not recognized as an internal or external command, operable program or batch file. Setting tags... Error trying to set the tags... Cannot update utime of file

silverbacknet commented 4 years ago

You do need ffmpeg installed into your system path somewhere first, or added to the path before running. There's no mechanism to point to it.

Ideekay commented 4 years ago

Thanks, I'm pretty inexperienced with all this, but I managed to install ffmpeg.

Errors are now:

'Signature' is not recognized as an internal or external command, operable program or batch file. 'Key-Pair-Id' is not recognized as an internal or external command, operable program or batch file. Setting tags... Error trying to set the tags... Cannot update utime of file

Additionally, I get a unique error per song attempt:

'https://cf-hls-media.sndcdn.com/playlist/H5x3oqQumkYk.128.mp3/playlist.m3u8?Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiKjovL2NmLWhscy1tZWRpYS5zbmRjZG4uY29tL3BsYXlsaXN0L0g1eDNvcVF1bWtZay4xMjgubXAzL3BsYXlsaXN0Lm0zdTgiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjE1NzY0NzUyODJ9fX1dfQ__: No such file or directory

angelfor3v3r commented 4 years ago

Thanks, I'm pretty inexperienced with all this, but I managed to install ffmpeg.

Errors are now:

'Signature' is not recognized as an internal or external command, operable program or batch file. 'Key-Pair-Id' is not recognized as an internal or external command, operable program or batch file. Setting tags... Error trying to set the tags... Cannot update utime of file

Additionally, I get a unique error per song attempt:

'https://cf-hls-media.sndcdn.com/playlist/H5x3oqQumkYk.128.mp3/playlist.m3u8?Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiKjovL2NmLWhscy1tZWRpYS5zbmRjZG4uY29tL3BsYXlsaXN0L0g1eDNvcVF1bWtZay4xMjgubXAzL3BsYXlsaXN0Lm0zdTgiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjE1NzY0NzUyODJ9fX1dfQ__: No such file or directory

I'm not sure about the first few errors, probably an issue with argument passing to FFMPEG, idk.

About the second error, that happens on tracks that do not have original downloads available. It happens to me too and i'm unable to download soundcloud tracks without downloads enabled.

@flyingrub are HLS streams still being implemented to download?

GiovanH commented 4 years ago

Having the same issue with ffmpeg on windows, using python 3.7 and cygwin:

$ scdl -l https://soundcloud.com/aradiasings -t
Soundcloud Downloader
Found a user profile
Retrieving all uploaded tracks of user broadway aradia^2...
Retrieved 5 uploaded tracks
Uploaded tracks n°1 of 5
Retrieving more info on the track
Downloading while my b0dy sleeps
ffmpeg version 3.4 Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 7.2.0 (GCC)
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-cuda --enable-cuvid --enable-d3d11va --enable-nvenc --enable-dxva2 --enable-avisynth --enable-libmfx
  libavutil      55. 78.100 / 55. 78.100
  libavcodec     57.107.100 / 57.107.100
  libavformat    57. 83.100 / 57. 83.100
  libavdevice    57. 10.100 / 57. 10.100
  libavfilter     6.107.100 /  6.107.100
  libswscale      4.  8.100 /  4.  8.100
  libswresample   2.  9.100 /  2.  9.100
  libpostproc    54.  7.100 / 54.  7.100
'https://cf-hls-media.sndcdn.com/playlist/h3Q2BY2JAzu9.128.mp3/playlist.m3u8?Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiKjovL2NmLWhscy1tZWRpYS5zbmRjZG4uY29tL3BsYXlsaXN0L2gzUTJCWTJKQXp1OS4xMjgubXAzL3BsYXlsaXN0Lm0zdTgiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjE1NzY5NjU5MTF9fX1dfQ__: No such file or directory
'Signature' is not recognized as an internal or external command,
operable program or batch file.
'Key-Pair-Id' is not recognized as an internal or external command,
operable program or batch file.
Setting tags...
Error trying to set the tags...
Cannot update utime of file
GiovanH commented 4 years ago

@CROSP's fork at https://github.com/CROSP/scdl seems to be designed to resolve the error, which seems to be caused by a malformed shell command, but it's not working for me either.

flyingrub commented 4 years ago

Note that I did merge @CROSP's fork changes to master

Ideekay commented 4 years ago

Everything seems to be working now! Granted, my entire library is being redownloaded, but the downloads are at least working again.

flyingrub commented 4 years ago

Closing this one also, latest version on master should be working fine https://github.com/flyingrub/scdl/commit/c221e439a4683ede34635b517a7d6a66c77e1f17.