Skip to content

Instantly share code, notes, and snippets.

@mislav
Last active December 20, 2015 20:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mislav/6194381 to your computer and use it in GitHub Desktop.
Save mislav/6194381 to your computer and use it in GitHub Desktop.
Download a song from YouTube/SoundCloud and import the audio to iTunes
#!/bin/sh
# Usage: steal <YOUTUBE-URL>
# Requirements: youtube-dl, ffmpeg
set -e
# strip the YouTube playlist
url="${1%%&*}"
if [ -z "$url" ]; then
echo "no URL given" >&2
exit 1
fi
youtube-dl --no-mtime -xo '/tmp/%(title)s.%(ext)s' "$url"
shopt -s nullglob
mv "$(ls -t /tmp/*.{m4a,mp3,mp4} | head -1)" \
"$HOME/Music/iTunes/iTunes Media/Automatically Add to iTunes/"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment