scripts

misc scripts and tools
git clone git://git.2f30.org/scripts.git
Log | Files | Refs

commit c97e0f87dbe8461c623f3efcff5db1bd2f6a3a0e
parent b32d19fd418f9363468e6eeb8a976208b244a0fc
Author: sin <sin@2f30.org>
Date:   Mon,  4 Nov 2013 16:26:02 +0000

Use find to encode all files

Always download in .mp4 format.

Diffstat:
ytfetch | 18++++--------------
1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/ytfetch b/ytfetch @@ -3,8 +3,6 @@ # Simple script to download songs from youtube and encode # them to mp3 using ffmpeg. This script also handles playlists. -out=$HOME/music/yt - if test -z "$1"; then echo "usage: $(basename $0) yt-url..." 1>&2 exit 1 @@ -16,23 +14,15 @@ which youtube-dl >/dev/null || \ which ffmpeg >/dev/null || \ { echo "I can't find ffmpeg, please install it" 1>&2; exit 1; } -mkdir -p "$out" scratch=$(mktemp -d) # Download all songs to the scratch space -for i in "$@"; do - youtube-dl -o "$scratch/%(title)s.%(ext)s" "$i" +for v in "$@"; do + youtube-dl -f mp4 -o "$scratch/%(title)s.%(ext)s" "$v" done -function encode { - in="$1" - out="$2" - ffmpeg -y -i "$in" "$out" -} +mkdir -p $HOME/music/yt # Encode all of them cd $scratch -for i in *; do - outfile="${i%.*}.mp3" - encode "$i" "$out/$outfile" -done +find . -iname "*.mp4" -exec sh -c 'ffmpeg -i "$0" "$HOME/music/yt/${0%.*}.mp3"' {} \;