Silverfeelin / spotdl-handler

Some scripts that allow you to call spotdl from a button on the Spotify website.
MIT License
24 stars 3 forks source link

Excuse me, spotdl-handler cant find the PATH of FFmpeg in Win10? #4

Closed DimRacker closed 4 years ago

DimRacker commented 4 years ago

Hi!

Thanks for the nice tool!

When I using it, There is a small issue, it can not covert .m4a to .mp3 automatically.

I tried pip install ffmpeg, and put three exes to System32, added the path to System Variables. In CMD, spotdl -s https://xxx -o .mp3, it works well.

Thank you very much!

Sincerely,

Dim

Silverfeelin commented 4 years ago

Hello,

Can you call ffmpeg directly from the command line (without being in the System32 folder)?

If not, I suggest you place the executables elsewhere and add that path to your environmental variables as well.

If that does work, please configure the spotdl-handler tool to keep the window open. This will allow you to see what's wrong and you could copy the information here if you don't know how to solve it. Here's information on how to do that: https://github.com/Silverfeelin/spotdl-handler/issues/2#issuecomment-558363526

DimRacker commented 4 years ago

Hi, Silverfeelin:

Yes, I can exec ffmpeg.exe,dotnet.exe,spotdl.exe from the CMD in any folder.

`D:>dotnet

Usage: dotnet [options] Usage: dotnet [path-to-application]

Options: -h|--help Display help. --info Display .NET Core information. --list-sdks Display the installed SDKs. --list-runtimes Display the installed runtimes.

path-to-application: The path to an application .dll file to execute.

D:>ffmpeg ffmpeg version git-2019-12-03-12bbfc4 Copyright (c) 2000-2019 the FFmpeg developers built with gcc 9.2.1 (GCC) 20191125 configuration: --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.101 / 56. 36.101 libavcodec 58. 64.101 / 58. 64.101 libavformat 58. 35.101 / 58. 35.101 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 Hyper fast Audio and Video encoder usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

Use -h to get full help or, even better, run 'man ffmpeg'

D:>spotdl -s https://open.spotify.com/track/0O3TAouZE4vL9dM5SyxgvH -o .mp3 -f C:\Users\Dim\Downloads INFO: A$AP ROCKY - Fashion Killa LYRICS ON SCREEN (http://www.youtube.com/watch?v=nPhe9Ah8rKA) 3,750,143.0 Bytes [100.00%] received. Rate: [ 252 KB/s]. ETA: [0 secs]

INFO: Converting AAP Rocky - Fashion Killa.m4a to mp3 INFO: Applying metadata`

Today, I encountered another issue, no matter what the "keepOpen" is, After I click the Download button, The download box is fleeting.

I tried uninstall/re-install spotdl/spotdl-handler, deleted the HKEY_CLASSES_ROOT\spotdl and re-config it, but it's no effect.

Thanks for your times!

Sincerely,

Dim

Silverfeelin commented 4 years ago

If the window still closes with this configuration I guess it's not the processes (spotdl/youtube-dl/ffmpeg) failing but some of my code is throwing an exception.

I have attached a debug build that will remain open regardless of what happens. Please overwrite the files with these ones and see what happens. You'll likely see some red text after running the tool. Please copy that information.

spotdl-handler-issue-4.zip

I will also make sure some code ends up in version 1.2 so that future exceptions won't require these steps to find them. Sorry for the inconvenience.

DimRacker commented 4 years ago

I overwrite the 6 files to \SpotifyDownloader, and re-config it, The problem remains.

Silverfeelin commented 4 years ago

Well, then my next bet would be that my application isn't even being started.

Here's the flow of steps from pressing download to getting the audio file in your music folder:

  1. You press Download on a song in Spotify.
  2. Browser calls upon the spotdl protocol.
  3. The registry key for spotdl is used to launch the application using .NET Core.
    • dotnet "path_to_SpotifyDownloader.dll" song_link
  4. .NET Core launches path_to_SpotifyDownloader.dll and passes the song_link.
  5. My application launches and uses the song_link to call the Python library spotdl.
  6. spotdl downloads the track using the youtube-dl library.
  7. spotdl uses ffmpeg to convert the downloaded file into the desired format.
  8. My application should remain open if an error occurs from step 5 to 7.
  9. You press any key to exit.

I'm now guessing that the issue lies in step 4, which means that .NET Core either can't find the application (wrong path) or there's a version mismatch and your installed version(s) of .NET Core can't run the application.

Silverfeelin commented 4 years ago

Update: if you change the registry key you can make sure the terminal always waits for a key, which means it will remain open even if the dotnet command fails.

Add & PAUSE to the end like such:

cmd.exe /C dotnet "C:\Program Files (x86)\SpotDL-Handler\SpotifyDownloader.dll" %1 & PAUSE
DimRacker commented 4 years ago

Oh, Yeah! You're right! The problem is sovled.

On my PC, The \command key data is: cmd.exe /C dotnet "D:\Bak\Soft\DownloadTool\Spotify\SpotifyDownloader" %1

The file name is missing.

In my humble opinion, People are used to entering only paths when they run the regedit-install.bat.

So, I am hoping that the command is: %SystemRoot%\System32\reg.exe ADD HKEY_CLASSES_ROOT\spotdl\shell\open\command /ve /d "cmd.exe /C dotnet \"%path%\SpotifyDownloader.dll\" %%1" /f >nul

Your support is greatly appreciated!

Silverfeelin commented 4 years ago

The installer automatically adds the registry key as following:

WriteRegStr "HKCR" "spotdl\shell\open\command" "" 'cmd.exe /C dotnet "$INSTDIR\SpotifyDownloader.dll" %1'

The $INSTDIR variable here is replaced by the install directory (where the dll is located). If that didn't do the trick for you I honestly don't know why, because the installer does allow you to set an installation path (defaulting to C:\Program Files (x86)\SpotDL-Handler).

I will update the documentation telling people with the same or similar issues what they could try to solve or troubleshoot their problem. Thank you for your patience.


Edit: seems like I totally misinterpreted your reply. My apologies, it's still a bit early here. You did use the regedit-install.bat but only entered the directory. That makes a lot of sense. I will try to edit the batch to detect this and append it automatically when omitted.

DimRacker commented 4 years ago

Sorry to have bothered you. I'm not good at English, I'm so sorry i didn't make myself clear. Thank you for everything you've done.

Silverfeelin commented 4 years ago

You were very clear! The mistake was on my part. Glad I could help in the end.

I will leave this issue open until I have implemented the changes.