From d1df3eefa5c764a873e3abe4432e0f8d0281219c Mon Sep 17 00:00:00 2001 From: Horus3 Date: Fri, 7 Mar 2014 02:18:55 +0100 Subject: detects hyperlink --- play | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/play b/play index e836033..ee22b22 100755 --- a/play +++ b/play @@ -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 -- cgit v1.2.3