2013-08-27 15:14:44 +04:00
|
|
|
#!/bin/bash
|
|
|
|
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
|
2014-07-07 22:06:38 +04:00
|
|
|
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
|
|
|
|
urequire DEFAULTS
|
2013-08-27 15:14:44 +04:00
|
|
|
|
|
|
|
function display_help() {
|
|
|
|
uecho "$scriptname: Télécharger un fichier avec wget ou curl
|
|
|
|
|
|
|
|
USAGE
|
|
|
|
$scriptname <file.url|file.desktop|URL> [wget options]"
|
|
|
|
}
|
|
|
|
|
|
|
|
parse_opts + "${PRETTYOPTS[@]}" \
|
|
|
|
--help '$exit_with display_help' \
|
|
|
|
@ args -- "$@" && set -- "${args[@]}" || die "$args"
|
|
|
|
|
2015-07-22 12:28:52 +04:00
|
|
|
"$scriptdir/caturl" --check "$1"
|
|
|
|
case $? in
|
|
|
|
2) die "Vous devez spécifier l'url à ouvrir";;
|
|
|
|
3) die "Le fichier spécifié ne contient pas d'url";;
|
|
|
|
esac
|
|
|
|
setx url="$scriptdir/caturl" "$1" || die
|
2013-08-27 15:14:44 +04:00
|
|
|
shift
|
|
|
|
|
|
|
|
filename="$(basename "$url")"
|
|
|
|
if progexists wget; then
|
|
|
|
if [ -f "$filename" ]; then
|
|
|
|
wget -c "$@" "$url"
|
|
|
|
else
|
|
|
|
wget "$@" "$url"
|
|
|
|
fi
|
|
|
|
elif progexists curl; then
|
|
|
|
if [ -f "$filename" ]; then
|
|
|
|
curl -C - -o "$filename" "$@" "$url"
|
|
|
|
else
|
|
|
|
curl -o "$filename" "$@" "$url"
|
2015-08-20 07:58:17 +04:00
|
|
|
fi
|
2013-08-27 15:14:44 +04:00
|
|
|
else
|
|
|
|
die "Aucune méthode de téléchargement n'a été détectée"
|
|
|
|
fi
|