x

Programs, configuration and documentation that don't fit anywhere else
Log | Files | Refs | README | LICENSE

hlsget (761B)


      1 #!/bin/sh
      2 
      3 usage="usage: hlsget [-d] [-ls] url"
      4 
      5 args=`getopt dls $*`
      6 if [ $? -ne 0 ]
      7 then
      8 	echo $usage
      9 	exit 2
     10 fi
     11 set -- $args
     12 while [ $# -ne 0 ]
     13 do
     14 	case "$1"
     15 	in
     16 		-l)
     17 			list=true; shift;;
     18 			debug=true; shift;;
     19 		-s)
     20 			split=true; shift;;
     21 		-d)
     22 			debug=true; shift;;
     23 		--)
     24 			shift; break;;
     25 	esac
     26 done
     27 
     28 if test $# -eq 0
     29 then
     30 	echo $usage
     31 	exit 2
     32 fi
     33 
     34 url=$1
     35 # basename may not have the -d option, so try dirname too.
     36 base=`basename -d $url || dirname $url`
     37 
     38 # strip manifest tags and carriage returns
     39 segments=`curl -s "$url" | grep -v '^#' | tr -d '\015'`
     40 
     41 for seg in $segments
     42 do
     43 	if test $debug
     44 	then
     45 		echo "$base/$seg" 1>&2
     46 	elif test $list
     47 	then
     48 		continue
     49 	elif test $split
     50 	then
     51 		curl -s -O "$base/$seg"
     52 		continue
     53 	fi
     54 	curl -s "$base/$seg"
     55 done