-
Notifications
You must be signed in to change notification settings - Fork 0
/
9dl
executable file
·66 lines (56 loc) · 1.32 KB
/
9dl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
#
# Copyright © 2015 Antoine Piau <[email protected]>
# This work is free. You can redistribute it and/or modify it under the
# terms of the Do What The Fuck You Want To Public License, Version 2,
# as published by Sam Hocevar. See http://www.wtfpl.net/ for more details.
dl_directory=$HOME/Images/new_fun
grep_id () {
if [[ $(echo "$i"|grep "m.9gag.com") ]]; then
id=$(echo $i |awk -F"http://m.9gag.com/gag/" '{print $2}')
else
id=$(echo $i |awk -F"http://9gag.com/gag/" '{print $2}')
fi
}
convert_link_img () {
grep_id
to_dl=http://img-9gag-fun.9cache.com/photo/"$id"_700b.jpg
}
convert_link_vid () {
grep_id
to_dl=http://img-9gag-fun.9cache.com/photo/"$id"_460sv.mp4
}
## Partie conversion d'un lien
if [ $1 = "conv" ]; then
i=$2
convert_link_img
echo $to_dl
echo or
convert_link_vid
echo $to_dl
exit 0
fi
## Partie téléchargement
read -p 'Sauvegarder dans Images/new_fun (défaut) ou ici ? [taper . pour ici] ' ans
if [[ "$ans" != "." ]]; then
cd $dl_directory
fi
for i in $*; do
convert_link_vid
wget $to_dl
if [ $? != 0 ]; then
convert_link_img
wget $to_dl
if [[ $? = 0 ]]; then
echo "$i est téléchargé"
else
echo "ÇA N'A PAS MARCHÉ"
prob=1
fi
else
echo "$i est téléchargé"
fi
done
if [[ $prob ]]; then
echo "UN OU PLUSIEURS FICHIERS N'ONT PAS ÉTÉ TÉLÉCHARGÉ"
fi