diff options
| author | Horus3 | 2014-03-07 02:18:55 +0100 |
|---|---|---|
| committer | Horus3 | 2014-03-07 02:18:55 +0100 |
| commit | d1df3eefa5c764a873e3abe4432e0f8d0281219c (patch) | |
| tree | b3ac2b872e084fd029a969231b3a339f0529c696 | |
| parent | 7fd44bc8b74b2deebcfa37b5b72d73734cdad9a9 (diff) | |
| download | dotfiles-d1df3eefa5c764a873e3abe4432e0f8d0281219c.tar.gz | |
detects hyperlink
| -rwxr-xr-x | play | 25 |
1 files changed, 19 insertions, 6 deletions
@@ -1,6 +1,6 @@ #!/bin/bash -# bash script to play files from a slow network ressource using mpv +# bash script to play files from a slow network ressource, FTP folder, samba share or network drive etc. # caches the file in /tmp and moves to $ARCHIV # -y to skip verification # export global variable $ARCHIV @@ -44,19 +44,32 @@ fi if [ -d /tmp ] && [ -w /tmp ]; then tmp="/tmp" - cp "$file" /tmp & else read -p "Please name the directory (without the trailing slash!) to cache the file: " tmp - if [ -d $tmp ] && [ -w $tmp ]; then - cp "$file" "$tmp" & - else + if [ ! -d $tmp ] || [ ! -w $tmp ]; then echo "Directory doesn't exist or you don't have write permission." exit 1 fi 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/"$@" & + elif [ $player =~ .*/mpv$ ] && [ $download ] && ( [ ! $download = "n" ] || [ ! $download = "N" ] || [ ! $download = "no" ] || [ ! $download = "nein" ] || [ ! $download = "NO" ]); then + echo "Playing directly using 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" & +fi + echo -n "Preparing the awesome! Starting playback in.." -echo -n " 2" +echo -n " 2," sleep 1 echo -n " 1" sleep 1 |
