Advertisement
kapott

yt_mp3.cmd

Feb 1st, 2019
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @echo off
  2. setlocal enableDelayedExpansion
  3.  
  4. :: script globals
  5. set url="%1=%2"
  6. SET me=%~n0.cmd
  7.  
  8. goto start_application
  9. exit /B %errorlevel%
  10.  
  11. :start_application
  12. call :find_ytdl
  13. if !errorlevel! neq 0 (exit /b 1)
  14. call :find_ffmpeg
  15. if !errorlevel! neq 0 (exit /b 1)
  16. call :echo Trying to get !url!
  17. youtube-dl --extract-audio --audio-quality 0 --audio-format mp3 --output "%USERPROFILE%\Music\%%(title)s.%%(ext)s" !url!
  18. goto :eof
  19.  
  20. :find_ytdl
  21. where youtube-dl > nul
  22. if %errorlevel% neq 0 (
  23.     call :echo Could not locate youtube-dl binary in PATH
  24.     exit /B 1
  25. ) else (
  26.     call :echo Found youtube-dl^!
  27.     exit /B 0
  28. )
  29. exit /B 0
  30.  
  31. :find_ffmpeg
  32. where youtube-dl > nul
  33. if %errorlevel% neq 0 (
  34.     call :echo Could not locate ffmpeg binary in PATH
  35.     exit /B 1
  36. ) else (
  37.     call :echo Found ffmpeg^!
  38.     exit /B 0
  39. )
  40. exit /B 0
  41.  
  42. :echo
  43. ECHO [%me%] %*
  44. EXIT /B 0
  45.  
  46. endlocal
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement