Last active
August 20, 2023 10:01
-
-
Save Jaezmien/c36c779cd4935657744e5e6e0159bf0d to your computer and use it in GitHub Desktop.
Quick lazy script to download youtube videos as mp3 using yt-dlp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
rem ; Set environment to local so that we don't leak variables | |
setlocal | |
set ytid=%1 | |
IF "%ytid:~0,24%"=="https://www.youtube.com/" goto warning-link | |
IF "%ytid:~0,23%"=="http://www.youtube.com/" goto warning-link | |
IF "%ytid:~0,20%"=="https://youtube.com/" goto warning-link | |
IF "%ytid:~0,19%"=="http://youtube.com/" goto warning-link | |
IF "%ytid:~0,22%"=="https://www.youtu.be/" goto skip-id-check | |
IF "%ytid:~0,21%"=="http://www.youtu.be/" goto skip-id-check | |
IF "%ytid:~0,17%"=="http://youtu.be/" goto skip-id-check | |
IF "%ytid:~0,16%"=="https://youtu.be/" goto skip-id-check | |
rem ; Possibly video-id only. | |
set ytid=https://youtu.be/%ytid% | |
goto skip-id-check | |
:skip-id-check | |
@echo on | |
yt-dlp --no-playlist -f bestaudio -x --audio-format mp3 --audio-quality 0 --add-metadata --embed-thumbnail -o "%%(artist,uploader,channel)s - %%(title,alt_title)s [%%(id)s].%%(ext)s" "%ytid%" | |
@echo off | |
goto end-download | |
:warning-link | |
echo Using youtube.com / youtu.be link, CMD truncates equal signs - ignoring. | |
goto end-download | |
:end-download | |
rem ; End of script | |
endlocal |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment