Last active
May 20, 2016 11:46
-
-
Save starkers/badfe5f51d98bed3ff84fee37267fd3d to your computer and use it in GitHub Desktop.
simple youtube downloader, crude cleanup and tagging
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
| #!/usr/bin/env bash | |
| ##This is very crude.. but its enough for me [meh] | |
| # contents of this text file is a youtube URL per line.. EG: | |
| #-- | |
| #cat listofvideos.txt | |
| #https://www.youtube.com/watch?v=RrLAaDCPc3I | |
| #-- | |
| fileVideoList=listofvideos.txt | |
| menuPrint(){ | |
| cat <<-EOF | |
| This is a menu | |
| 1) download youtube videos from $fileVideoList | |
| 2) rename the files in this directory (strips anything thats not [a-z0-9] ) | |
| 3) tag them based on filename (apt install lltag) | |
| EOF | |
| read -p ": " input | |
| } | |
| do_tag(){ | |
| COMMENT="" | |
| ALBUM="VA - Youtube" | |
| ARTIST="VA" | |
| for file in *.ogg ; do | |
| TITLE="$(sed "s+.ogg$++1; s+^Best of ++g; s+^Best ++g" <<<"$file")" | |
| echo "Processing $file" | |
| # if [ -f "tmpfile" ]; then | |
| # rm -rf "tmpfile" | |
| # fi | |
| lltag "$file" --yes | |
| # sndfile-metadata-set \ | |
| # --str-comment "$COMMENT" \ | |
| # --str-title "$TITLE" \ | |
| # --str-album "$ALBUM" \ | |
| # --str-artist "$ARTIST" "$file" | |
| # #&& rm "$file" && mv tmpfile "$file" | |
| done | |
| } | |
| do_download(){ | |
| youtube-dl -x --audio-format vorbis --no-mtime -a "$fileVideoList" | |
| } | |
| do_rename(){ | |
| #anything not a-z+0-9 strip | |
| for src in * ; do | |
| # echo "src:$src" | |
| dst="$(echo $src | sed 's/[^a-zA-Z0-9.0 -]//g' | sed "s+ + +g")" | |
| mv -v "$src" "$dst" | |
| done | |
| } | |
| while true ; do | |
| menuPrint | |
| echo $input | |
| if [ ! X"$input" == X ] ; then | |
| case $input in | |
| 1) | |
| do_download | |
| ;; | |
| 2) | |
| do_rename | |
| ;; | |
| 3) | |
| do_tag | |
| ;; | |
| *) | |
| echo "dunno what that means" | |
| ;; | |
| esac | |
| fi | |
| sleep 1 | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment