Created
February 7, 2022 03:49
-
-
Save nonrice/9e7f5cb3615f922fd2e41d180a2a270b to your computer and use it in GitHub Desktop.
Downloads songs from Youtube into iTunes music library (MacOS)
This file contains hidden or 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
#!/bin/zsh | |
# Downloads audio and cover art from youtube video and automatically adds to your iTunes music library. | |
# | |
# Required packages: | |
# youtube-dl | |
# eyeD3 | |
# imageMagick | |
# | |
# To use, first make the script runnable: | |
# chmod +x yt-itunes.sh | |
# | |
# Run and specify proper args: | |
# ./yt-itunes.sh [video_url] [song_title] [song_artist] | |
vid_id=${1: -11} | |
vid_name="$2.mp3" | |
youtube-dl -x --audio-format mp3 $1 -o "$2.%(ext)s" | |
curl "https://img.youtube.com/vi/${vid_id}/maxresdefault.jpg" > cover.jpg | |
convert cover.jpg -resize "720^>" -gravity center -crop 720x720+0+0 -strip cover.jpg | |
eyeD3 --add-image "cover.jpg:FRONT_COVER" ${vid_name} --artist $3 | |
mv ${vid_name} "$HOME/Music/Music/Media.localized/Automatically Add to Music.localized/" | |
rm cover.jpg |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment