-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetFilesFromIMobilco.sh
executable file
·68 lines (55 loc) · 1.3 KB
/
getFilesFromIMobilco.sh
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
67
68
#! /bin/sh
# A few defaults
LOGIN_URL="http://www.imobilco.ru/login/"
BADOPTSHELP="Option is not recognized"
DEST_DIR="/Volumes/media/BitTorrent/Детские/"
URLQUEUE_FILE="queue.txt"
URL_LIST=""
function showUsage {
cat <<EOT
getFilesFromIMobilco [options] [file_url]
Options:
-u Specify iMobilco user name
-p Specify iMobilco password
-q Specify alternate URL queue file (in this case file_url is ignored).
Default is queue.txt in current directory.
-d DEST_DIR directory
-h Shows this
EOT
exit
}
# just print error and exit
function printErrorHelpAndExit {
echo $1
exit
}
# read in queue file with URLs, one URL per line. See sample file queue.txt
function readDownloadLinks {
URL_LIST=$(cat $URLQUEUE_FILE | egrep -v '^#' )
}
function getFiles {
readDownloadLinks
cd $DEST_DIR
for url in $URL_LIST
do
curl --cookie-jar cjar --location \
--data login=$ULOGIN \
--data password=$UPASSWD $LOGIN_URL
echo Fetching $url...
curl --cookie cjar --location --remote-name $url
done
}
# let it all begin
#args=`getopt hd:q:u:p: $*`
while getopts "hd:q:u:p:" optionName; do
case "$optionName" in
u) ULOGIN="$OPTARG";;
p) UPASSWD="$OPTARG";;
q) URLQUEUE_FILE="$OPTARG";;
d) DEST_DIR="$OPTARG";;
h) showUsage;;
[?]) printErrorHelpAndExit "$BADOPTSHELP";;
esac
done
getFiles
# EOF