diff options
| author | Horus3 | 2014-04-19 02:30:49 +0200 |
|---|---|---|
| committer | Horus3 | 2014-04-19 02:30:49 +0200 |
| commit | 1cae96dbcaf032d417ebf8d7e49a8577c84ad9f9 (patch) | |
| tree | 2b655e34fcbcda92f0e133b7b288658b4c3bd4a3 /bin | |
| parent | 1073777cdca41b69505a0098fb96ba266e274016 (diff) | |
| download | dotfiles-1cae96dbcaf032d417ebf8d7e49a8577c84ad9f9.tar.gz | |
Added 2 zsh functions and play.sh skip now the copy and sleep process if file exists in
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/play | 106 |
1 files changed, 60 insertions, 46 deletions
@@ -11,12 +11,13 @@ printhelp(){ echo "Bash script to play and cache files from a slow network ressource" echo "" - echo "-y move to archiv without question" - echo "-n don't ask for moving" - echo "-o ask for a different archiv" - echo "-r only remove the file in /tmp" - echo "-d don't ask for downloading" - echo "-h prints this help" + echo " -d only remove the file in /tmp" + echo " -g don't ask for downloading" + echo " -h prints this help" + echo " -n don't ask for moving" + echo " -y move to archiv without question" + echo " -o ask for a different archiv" + echo " -no-cache Not caching the file, instead play's directly" exit 0 } @@ -54,6 +55,16 @@ if [ $# -eq 0 ]; then printhelp fi +if [ $# -gt 1 ]; then + echo "Do not commit more than one file." + exit 1 +fi + +if [ ! -f "$1" ]; then + echo "No valid file input." + exit +fi + player[0]=$(command -v mpv) #media player of choice player[1]=$(command -v mplayer) player[2]=$(command -v vlc) #you shouldn't use vlc @@ -101,7 +112,7 @@ if [ $cache -gt 0 ]; then wget -q -O "file" "$@" & echo "Starting download. Ready to play in 2 sec." sleep 2 - mpv file + mpv $file echo "TODO: Moving to archiv. Not implemented yet." exit 0 elif [[ $player =~ mpv$ ]] && [ $download ] && ( [ ! $download = "n" ] && [ ! $download = "N" ] && [ ! $download = "no" ] && [ ! $download = "nein" ] && [ ! $download = "NO" ]); then @@ -119,16 +130,23 @@ if [ $cache -gt 0 ]; then exit 1 fi else - cp "$@" "$tmp" & + file=$(basename "$@") + if [ -f "$tmp/$file" ]; then + skip=true + fi + cp -u -i "$@" "$tmp" & cd "$tmp" - file=${@##*/} - - echo -n "Preparing the awesome! Starting playback in.." - echo -n " 2," - sleep 1 - echo -n " 1" - sleep 1 - echo " Start!" + #file=${@##*/} + + if [ ! $skip ]; then + echo -n "Preparing the awesome! Starting playback in.." + echo -n " 2," + sleep 1 + echo -n " 1 " + sleep 1 + fi + + echo "Start!" fi else echo -n "Preparing the awesome! Starting playback in.." @@ -138,44 +156,40 @@ fi $player "$file" if [ $? -eq 0 ]; then - if [ $cache -gt 0 ]; then - if [ -d $ARCHIV ] && [ -w $ARCHIV ] && [ $ARCHIV ]; then - echo "Finished $file succesfull." - if [ ! $verify ]; then - read -p "Should we move everything to the archiv? ($ARCHIV) [Y/n/rm/other] " verify + if [ -d $ARCHIV ] && [ -w $ARCHIV ] && [ $ARCHIV ]; then + echo "Finished $file succesfull." + if [ ! $verify ]; then + read -p "Should we move everything to the archiv? ($ARCHIV) [Y/n/rm/other] " verify + fi + if [ ! $verify ] || [ $verify = "ja" ] || [ $verify = "yes" ] || [ $verify = "j" ] || [ $verify = "y" ] || [ $verify = "Y" ]; then + echo "Moving the stuff to $ARCHIV." + mv -v "$file" "$ARCHIV" + if [ $? -eq 0 ]; then + cd "$pwd" + rm -v "$@" fi - if [ ! $verify ] || [ $verify = "ja" ] || [ $verify = "yes" ] || [ $verify = "j" ] || [ $verify = "y" ] || [ $verify = "Y" ]; then - echo "Moving the stuff to $ARCHIV." - mv -v "$file" "$ARCHIV" + elif [ $verify = "other" ] || [ $verify = "o" ] || [ $verify = "O" ] || [ $verify = "OTHER" ]; then + read -p "Please tell us the absolute path: " path + if [ -d $path ] && [ -w $path ]; then + echo "Moving to $path." + mv -v "$file" "$path" if [ $? -eq 0 ]; then cd "$pwd" - rm -v "$@" - fi - elif [ $verify = "other" ] || [ $verify = "o" ] || [ $verify = "O" ] || [ $verify = "OTHER" ]; then - read -p "Please tell us the absolute path: " path - if [ -d $path ] && [ -w $path ]; then - echo "Moving to $path." - mv -v "$file" "$path" - if [ $? -eq 0 ]; then - cd "$pwd" - rm -v "$@" - fi - else - echo "Sorry, \"$path\" doesn't exist." - exit 1 - fi - elif [ $verify = "r" ] || [ $verify = "rm" ] || [ $verify = "remove" ] || [ $verify = "RM" ] || [ $verify = "R" ]; then - echo "Cleaning the mess up. Only removing files from $tmp." - rm -v "$file" + rm -v "$@" + fi else - echo "Okay, don't touching the files." + echo "Sorry, \"$path\" doesn't exist." + exit 1 fi + elif [ $verify = "r" ] || [ $verify = "rm" ] || [ $verify = "remove" ] || [ $verify = "RM" ] || [ $verify = "R" ]; then + echo "Cleaning the mess up. Only removing files from $tmp." + rm -v "$file" else - echo "Can't move to \"$ARCHIV\". Directory doesn't exist or you don't have write permission." - exit 1 + echo "Okay, don't touching the files." fi else - echo "Nothing was cached, nothing is touched." + echo "Can't move to \"$ARCHIV\". Directory doesn't exist or you don't have write permission." + exit 1 fi else echo "Something is broken with the media player!" |
