diff options
| author | Horus3 | 2014-03-07 16:00:33 +0100 |
|---|---|---|
| committer | Horus3 | 2014-03-07 16:00:33 +0100 |
| commit | 2c0e3234808dccbd7c622be7c4250ea405f3e166 (patch) | |
| tree | 51610402061a6d8d73038e6901e83a1a9d58a35a /play | |
| parent | d1df3eefa5c764a873e3abe4432e0f8d0281219c (diff) | |
| download | dotfiles-2c0e3234808dccbd7c622be7c4250ea405f3e166.tar.gz | |
multi file support
Diffstat (limited to 'play')
| -rwxr-xr-x | play | 32 |
1 files changed, 18 insertions, 14 deletions
@@ -31,21 +31,21 @@ if [ ! $player ]; then exit 1 fi -file="$@" - if [ ! -d $ARCHIV ]; then echo "Note: Variable \$ARCHIV couldn't be found. It will play the file fine, but you should consider to organize your collection." - read -p "You can export it temporarily. If you do, just type the path to the folder (without the trailing slash!), if you don't, leave it empty. " path + read -p "You can export it temporarily. If you do, just type the path to the folder , if you don't, leave it empty. " path if [ $path ] && [ -d $path ] && [ -w $path ]; then export ARCHIV=$path echo "Roger that!" fi fi +pwd=$(pwd) + if [ -d /tmp ] && [ -w /tmp ]; then tmp="/tmp" else - read -p "Please name the directory (without the trailing slash!) to cache the file: " tmp + read -p "Please name the directory to cache the file: " tmp if [ ! -d $tmp ] || [ ! -w $tmp ]; then echo "Directory doesn't exist or you don't have write permission." exit 1 @@ -55,17 +55,18 @@ fi if [[ "$@" =~ ^https?://.* ]]; then read -p "Detected hyperlink. Should we try to download (caching)? Type something random to play direct with the mpv. [y/N] " download if [ $download = "ja" ] || [ $download = "yes" ] || [ $download = "j" ] || [ $download = "y" ] || [ $download = "Y" ]; then - wget $tmp/"$@" & + cd "$tmp" + wget "$@" & elif [ $player =~ .*/mpv$ ] && [ $download ] && ( [ ! $download = "n" ] || [ ! $download = "N" ] || [ ! $download = "no" ] || [ ! $download = "nein" ] || [ ! $download = "NO" ]); then echo "Playing directly using mpv." - mpv $@ + mpv "$@" exit 0 else echo "This script is designed to cache media files from a FTP share or network drive. Exiting. " exit 1 fi else - cp "$file" "$tmp" & + cp "$@" $tmp & fi echo -n "Preparing the awesome! Starting playback in.." @@ -75,26 +76,29 @@ echo -n " 1" sleep 1 echo " Start!" -$player $tmp/"$file" +cd $tmp +$player "$@" if [ $? -eq 0 ]; then if [ -d $ARCHIV ] && [ -w $ARCHIV ]; then - echo "Finished $file succesfull." + echo "Finished $@ succesfull." if [ $verify -eq 0 ]; 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 $tmp/"$file" "$ARCHIV" + mv -v "$@" "$ARCHIV" if [ $? -eq 0 ]; then - rm -v "$file" + 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 $tmp/"$file" "$path" + mv -v "$@" "$path" if [ $? -eq 0 ]; then - rm -v "$file" + cd $pwd + rm -v "$@" fi else echo "Sorry, \"$path\" doesn't exist." @@ -102,7 +106,7 @@ if [ $? -eq 0 ]; then 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 $tmp/"$file" + rm -v "$@" else echo "Okay, don't touching the files." fi |
