forked from xicelord/mangadex-scripts
-
Notifications
You must be signed in to change notification settings - Fork 2
/
mangadex-uploader.sh
executable file
·105 lines (100 loc) · 2.44 KB
/
mangadex-uploader.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/bin/bash
#Load arguments
while getopts "v:c:t::g:m:l::f:u::p::" opt; do
case $opt in
v)
volume=$OPTARG;
;;
c)
chapter=$OPTARG;
;;
t)
title=$OPTARG;
;;
g)
group=$OPTARG;
;;
m)
manga=$OPTARG;
;;
l)
language=$OPTARG;
;;
f)
file=$OPTARG;
;;
u)
username=$OPTARG;
;;
p)
password=$OPTARG;
;;
esac
done
#Correct language
if ! [[ "$language" =~ ^[0-9]+$ ]]; then
language="1";
fi
#Verify input
if [[ "$volume" =~ ^[0-9]+$ ]] && [[ "$chapter" =~ ^[0-9]+([.][0-9]+)?$ ]] && [[ "$group" =~ ^[0-9]+$ ]] && [[ "$manga" =~ ^[0-9]+$ ]] && ! [ -z "$file" ]; then
#Show info
echo "Uploading the following chapter:";
echo "Manga: $manga";
echo "Group: $group";
echo "v${volume}c${chapter} - $title";
echo "Language: $language";
echo "File: $file";
#Get confirmation
echo "";
read -p "Continue (y/n)? " CONT
if [ "$CONT" = "y" ] || [ "$CONT" = "Y" ]; then
#Upload
echo "Uploading...";
curl -X POST "https://mangadex.com/ajax/actions.ajax.php?function=chapter_upload" \
-b "./mangadex-cookies" \
-H "X-Requested-With: XMLHttpRequest" \
-e "https://mangadex.com/upload/$manga" \
-F "manga_id=$manga" \
-F "chapter_name=$title" \
-F "volume_number=$volume" \
-F "chapter_number=$chapter" \
-F "group_id=$group" \
-F "lang_id=$language" \
-F "file=@$file"
else
echo "Aborted!";
fi
else
if ! [ -z "$username" ] && ! [ -z "$password" ]; then
#Log in
echo "Logging in...";
curl -X POST "https://mangadex.com/ajax/actions.ajax.php?function=login" \
-c "./mangadex-cookies" \
-H "X-Requested-With: XMLHttpRequest" \
-e "https://mangadex.com/login" \
-F "login_username=$username" \
-F "login_password=$password"
else
echo "MangaDex Uploader v0.1 by icelord";
echo "";
echo "Usage: mangadex.sh ARGUMENTS";
echo "";
echo "Login: Creates a cookie-jar-file";
echo " -u: Username (eg: 'test')";
echo " -p: Password (eg: 'test')";
echo "";
echo "Upload: Uploads a chapter; Make sure to login first!";
echo " -m: Manga (eg: 412) {required}";
echo " -g: Group (eg: 657) {required}";
echo " -v: Volume (eg: 1) {required}";
echo " -c: Chapter (eg: 1.1) {required}";
echo " -t: Title (eg: 'Title123')";
echo " -l: Language (eg: 1) (default: english)";
echo " -f: File (eg: './ch1.zip') {required}";
echo "";
echo "Examples":
echo "Login: mangadex -u test -p test";
echo "Upload: mangadex -m 412 -g 657 -v 1 -c 1 -t \"First\"";
exit 1;
fi
fi