cdpDumpingUtils 0.2.0__tar.gz → 0.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {cdpDumpingUtils-0.2.0 → cdpDumpingUtils-0.2.1}/PKG-INFO +11 -7
- {cdpDumpingUtils-0.2.0 → cdpDumpingUtils-0.2.1}/README.md +10 -6
- {cdpDumpingUtils-0.2.0 → cdpDumpingUtils-0.2.1}/cdpDumpingUtils/main.py +112 -26
- cdpDumpingUtils-0.2.1/cdpDumpingUtils/version.py +1 -0
- {cdpDumpingUtils-0.2.0 → cdpDumpingUtils-0.2.1}/cdpDumpingUtils.egg-info/PKG-INFO +11 -7
- cdpDumpingUtils-0.2.0/cdpDumpingUtils/version.py +0 -1
- {cdpDumpingUtils-0.2.0 → cdpDumpingUtils-0.2.1}/LICENSE +0 -0
- {cdpDumpingUtils-0.2.0 → cdpDumpingUtils-0.2.1}/cdpDumpingUtils/__init__.py +0 -0
- {cdpDumpingUtils-0.2.0 → cdpDumpingUtils-0.2.1}/cdpDumpingUtils.egg-info/SOURCES.txt +0 -0
- {cdpDumpingUtils-0.2.0 → cdpDumpingUtils-0.2.1}/cdpDumpingUtils.egg-info/dependency_links.txt +0 -0
- {cdpDumpingUtils-0.2.0 → cdpDumpingUtils-0.2.1}/cdpDumpingUtils.egg-info/entry_points.txt +0 -0
- {cdpDumpingUtils-0.2.0 → cdpDumpingUtils-0.2.1}/cdpDumpingUtils.egg-info/requires.txt +0 -0
- {cdpDumpingUtils-0.2.0 → cdpDumpingUtils-0.2.1}/cdpDumpingUtils.egg-info/top_level.txt +0 -0
- {cdpDumpingUtils-0.2.0 → cdpDumpingUtils-0.2.1}/setup.cfg +0 -0
- {cdpDumpingUtils-0.2.0 → cdpDumpingUtils-0.2.1}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: cdpDumpingUtils
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: Download all your courses filles from cahier de prepa
|
|
5
5
|
Home-page: https://github.com/Azuxul/cahier-de-prepa-downloader
|
|
6
6
|
Author: azuxul
|
|
@@ -55,30 +55,34 @@ cdpDumpingUtils -h
|
|
|
55
55
|
```
|
|
56
56
|
|
|
57
57
|
```
|
|
58
|
-
usage: cdpDumpingUtils [-h] [-v] [-l USERNAME] [-p PASSWORD] -o OUTPUT -u URL
|
|
58
|
+
usage: cdpDumpingUtils [-h] [--edit-cfg] [-v] [-l USERNAME] [-p PASSWORD] [-o OUTPUT] [-u URL]
|
|
59
59
|
|
|
60
60
|
options:
|
|
61
61
|
-h, --help show this help message and exit
|
|
62
62
|
|
|
63
63
|
arguments optionnels:
|
|
64
|
+
--edit-cfg Modification du fichier de configuration
|
|
64
65
|
-v, --verbose Augmente la quantité de texte affiché
|
|
65
66
|
-l USERNAME, --username USERNAME
|
|
66
67
|
Nom d'utilisateur du compte cahier de prepa (utilisation sans compte possible)
|
|
67
68
|
-p PASSWORD, --password PASSWORD
|
|
68
69
|
Mot de passe de connexion cahier de prepa
|
|
69
|
-
|
|
70
|
-
arguments requis:
|
|
71
70
|
-o OUTPUT, --output OUTPUT
|
|
72
|
-
Chemin d'acces du dossier de sortie
|
|
71
|
+
Chemin d'acces du dossier de sortie, par default le dossier actuel
|
|
73
72
|
-u URL, --url URL URL de l'instance cahier de prepa
|
|
74
73
|
```
|
|
75
74
|
|
|
76
|
-
To run cdpDumpingUtils
|
|
75
|
+
To run cdpDumpingUtils with a config file (if no config file it will be created) :
|
|
76
|
+
```
|
|
77
|
+
cdpDumpingUtils -o ./output
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
To run cdpDumpingUtils and specify an url without an account:
|
|
77
81
|
```
|
|
78
82
|
cdpDumpingUtils -u https://cahier-de-prepa.fr/XXX/ -o ./output
|
|
79
83
|
```
|
|
80
84
|
|
|
81
|
-
To run cdpDumpingUtils with an account:
|
|
85
|
+
To run cdpDumpingUtils and specify an url with an account:
|
|
82
86
|
```
|
|
83
87
|
cdpDumpingUtils -u https://cahier-de-prepa.fr/XXX/ -l username -p password -o ./output
|
|
84
88
|
```
|
|
@@ -39,30 +39,34 @@ cdpDumpingUtils -h
|
|
|
39
39
|
```
|
|
40
40
|
|
|
41
41
|
```
|
|
42
|
-
usage: cdpDumpingUtils [-h] [-v] [-l USERNAME] [-p PASSWORD] -o OUTPUT -u URL
|
|
42
|
+
usage: cdpDumpingUtils [-h] [--edit-cfg] [-v] [-l USERNAME] [-p PASSWORD] [-o OUTPUT] [-u URL]
|
|
43
43
|
|
|
44
44
|
options:
|
|
45
45
|
-h, --help show this help message and exit
|
|
46
46
|
|
|
47
47
|
arguments optionnels:
|
|
48
|
+
--edit-cfg Modification du fichier de configuration
|
|
48
49
|
-v, --verbose Augmente la quantité de texte affiché
|
|
49
50
|
-l USERNAME, --username USERNAME
|
|
50
51
|
Nom d'utilisateur du compte cahier de prepa (utilisation sans compte possible)
|
|
51
52
|
-p PASSWORD, --password PASSWORD
|
|
52
53
|
Mot de passe de connexion cahier de prepa
|
|
53
|
-
|
|
54
|
-
arguments requis:
|
|
55
54
|
-o OUTPUT, --output OUTPUT
|
|
56
|
-
Chemin d'acces du dossier de sortie
|
|
55
|
+
Chemin d'acces du dossier de sortie, par default le dossier actuel
|
|
57
56
|
-u URL, --url URL URL de l'instance cahier de prepa
|
|
58
57
|
```
|
|
59
58
|
|
|
60
|
-
To run cdpDumpingUtils
|
|
59
|
+
To run cdpDumpingUtils with a config file (if no config file it will be created) :
|
|
60
|
+
```
|
|
61
|
+
cdpDumpingUtils -o ./output
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
To run cdpDumpingUtils and specify an url without an account:
|
|
61
65
|
```
|
|
62
66
|
cdpDumpingUtils -u https://cahier-de-prepa.fr/XXX/ -o ./output
|
|
63
67
|
```
|
|
64
68
|
|
|
65
|
-
To run cdpDumpingUtils with an account:
|
|
69
|
+
To run cdpDumpingUtils and specify an url with an account:
|
|
66
70
|
```
|
|
67
71
|
cdpDumpingUtils -u https://cahier-de-prepa.fr/XXX/ -l username -p password -o ./output
|
|
68
72
|
```
|
|
@@ -28,7 +28,12 @@ from bs4 import BeautifulSoup
|
|
|
28
28
|
|
|
29
29
|
from cdpDumpingUtils.version import __version__
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
import os
|
|
32
|
+
import configparser
|
|
33
|
+
|
|
34
|
+
config_file = 'cdpDumpingUtils.cfg'
|
|
35
|
+
|
|
36
|
+
output_dir = os.getcwd()
|
|
32
37
|
base_url = None
|
|
33
38
|
username = None
|
|
34
39
|
password = None
|
|
@@ -44,29 +49,37 @@ def start():
|
|
|
44
49
|
# username = credentials.LOGIN
|
|
45
50
|
# password = credentials.PASSWORD
|
|
46
51
|
|
|
47
|
-
log_user = username is not None and password is not None
|
|
52
|
+
log_user = username is not None and password is not None and username != "" and password != ""
|
|
48
53
|
|
|
49
54
|
# Remove trailing slash if present
|
|
50
55
|
if(base_url.endswith("/")):
|
|
51
56
|
base_url = base_url[:-1]
|
|
52
57
|
|
|
53
|
-
data = {
|
|
54
|
-
"csrf-token": "undefined",
|
|
55
|
-
"login": username,
|
|
56
|
-
"motdepasse": password,
|
|
57
|
-
"connexion": "1"
|
|
58
|
-
}
|
|
59
|
-
|
|
60
58
|
session = requests.Session()
|
|
61
59
|
jsonRep = None
|
|
62
60
|
|
|
63
61
|
if log_user:
|
|
62
|
+
print("Connexion en cours...")
|
|
63
|
+
|
|
64
|
+
data = {
|
|
65
|
+
"csrf-token": "undefined",
|
|
66
|
+
"login": username,
|
|
67
|
+
"motdepasse": password,
|
|
68
|
+
"connexion": "1"
|
|
69
|
+
}
|
|
70
|
+
|
|
64
71
|
response = session.post(base_url + "/ajax.php", data=data)
|
|
65
72
|
|
|
66
73
|
if response.status_code != 200:
|
|
74
|
+
print("Erreur lors de la connexion")
|
|
67
75
|
exit()
|
|
68
76
|
|
|
69
77
|
jsonRep = json.loads(response.text)
|
|
78
|
+
if jsonRep is not None and jsonRep["etat"] != "ok":
|
|
79
|
+
print("Informations de connexion incorectes")
|
|
80
|
+
exit()
|
|
81
|
+
|
|
82
|
+
print("Connexion réussie")
|
|
70
83
|
|
|
71
84
|
pages = {}
|
|
72
85
|
docs = {}
|
|
@@ -103,16 +116,12 @@ def start():
|
|
|
103
116
|
sec = BeautifulSoup(rep.text, features="html5lib").find("title")
|
|
104
117
|
title = sec.text
|
|
105
118
|
|
|
106
|
-
|
|
107
|
-
print("Informations de connexion incorectes")
|
|
108
|
-
exit()
|
|
109
|
-
|
|
110
|
-
print("Exploration de ", title, " en cours...")
|
|
119
|
+
print("Exploration de", title, "en cours...")
|
|
111
120
|
|
|
112
121
|
for i in range(100):
|
|
113
122
|
explore(i)
|
|
114
123
|
|
|
115
|
-
print("Exploration terminée. (", len(pages), "
|
|
124
|
+
print("Exploration terminée. (", len(pages), "pages trouvées )")
|
|
116
125
|
print()
|
|
117
126
|
print("Téléchargement des documents...")
|
|
118
127
|
|
|
@@ -120,7 +129,7 @@ def start():
|
|
|
120
129
|
nbDocRef = 0
|
|
121
130
|
|
|
122
131
|
for p in docs.keys():
|
|
123
|
-
print("Page
|
|
132
|
+
print("Page", p, ":", pages[p].replace(" / ", "/"))
|
|
124
133
|
|
|
125
134
|
for d in docs[p]:
|
|
126
135
|
dl = session.get(base_url + "/download?id=" + str(d) + "&dl")
|
|
@@ -138,7 +147,7 @@ def start():
|
|
|
138
147
|
nbDocRef += 1
|
|
139
148
|
|
|
140
149
|
if access:
|
|
141
|
-
print("Document
|
|
150
|
+
print("Document", d, ":", docs[p][d])
|
|
142
151
|
file_name = dl.headers["Content-Disposition"].replace("filename=", "").replace("attachment; ", "").replace("inline; ", "")
|
|
143
152
|
|
|
144
153
|
title = re.sub(r"[:?\"<>/|]", "", re.sub(r"[*]", "(etoile)", title))
|
|
@@ -154,20 +163,84 @@ def start():
|
|
|
154
163
|
nbDoc += 1
|
|
155
164
|
print("--")
|
|
156
165
|
|
|
157
|
-
print(nbDoc, "
|
|
158
|
-
print(nbDocRef, "
|
|
166
|
+
print(nbDoc, "documents téléchargés")
|
|
167
|
+
print(nbDocRef, "documents protégés")
|
|
168
|
+
|
|
169
|
+
def prompt_config_setup():
|
|
170
|
+
global config_file, output_dir
|
|
171
|
+
|
|
172
|
+
config_path = os.path.join(output_dir, config_file)
|
|
173
|
+
|
|
174
|
+
if os.path.isfile(config_path):
|
|
175
|
+
# Load the existing config file
|
|
176
|
+
config = configparser.ConfigParser()
|
|
177
|
+
config.read(config_path)
|
|
178
|
+
else:
|
|
179
|
+
# Create the output directory if it doesn't exist
|
|
180
|
+
if not os.path.exists(output_dir):
|
|
181
|
+
os.makedirs(output_dir)
|
|
182
|
+
|
|
183
|
+
# Create a new config file
|
|
184
|
+
config = configparser.ConfigParser()
|
|
185
|
+
config["cahier_de_prepa"] = {}
|
|
186
|
+
|
|
187
|
+
url = input("URL de l'instance cahier de prepa : ")
|
|
188
|
+
if url is not None and url != "":
|
|
189
|
+
config["cahier_de_prepa"]["url"] = url
|
|
190
|
+
|
|
191
|
+
login = input("Connexion avec compte utilisateur ? (y/n): ")
|
|
192
|
+
if login.lower() == "y":
|
|
193
|
+
username = input("Nom d'utilisateur : ")
|
|
194
|
+
password = input("Mot de passe : ")
|
|
195
|
+
config["cahier_de_prepa.credentials"] = {"username": username, "password": password}
|
|
196
|
+
else:
|
|
197
|
+
config["cahier_de_prepa.credentials"] = {"username": '', "password": ''}
|
|
198
|
+
|
|
199
|
+
# Save the config file
|
|
200
|
+
with open(config_path, "w") as f:
|
|
201
|
+
config.write(f)
|
|
202
|
+
|
|
203
|
+
def load_config(prompt_no_config=False):
|
|
204
|
+
global config_file, output_dir, base_url, username, password
|
|
205
|
+
|
|
206
|
+
config_path = os.path.join(output_dir, config_file)
|
|
207
|
+
|
|
208
|
+
if os.path.isfile(config_path):
|
|
209
|
+
# Load the existing config file
|
|
210
|
+
config = configparser.ConfigParser()
|
|
211
|
+
config.read(config_path)
|
|
212
|
+
|
|
213
|
+
if "cahier_de_prepa" in config:
|
|
214
|
+
|
|
215
|
+
base_url = config["cahier_de_prepa"]["url"]
|
|
216
|
+
|
|
217
|
+
if "username" in config["cahier_de_prepa.credentials"] and "password" in config["cahier_de_prepa.credentials"]:
|
|
218
|
+
username = config["cahier_de_prepa.credentials"]["username"]
|
|
219
|
+
password = config["cahier_de_prepa.credentials"]["password"]
|
|
220
|
+
else:
|
|
221
|
+
print("Impossible de lire le fichier de configuration")
|
|
222
|
+
exit()
|
|
159
223
|
|
|
224
|
+
else:
|
|
225
|
+
if prompt_no_config:
|
|
226
|
+
prompt_config_setup()
|
|
227
|
+
load_config()
|
|
228
|
+
else:
|
|
229
|
+
print("Impossible de trouver le fichier de configuration")
|
|
230
|
+
exit()
|
|
231
|
+
|
|
232
|
+
|
|
160
233
|
def main(args=None):
|
|
161
234
|
global output_dir, base_url, username, password, verbose
|
|
162
235
|
|
|
163
236
|
parser = argparse.ArgumentParser()
|
|
164
237
|
optional = parser.add_argument_group("arguments optionnels")
|
|
238
|
+
optional.add_argument("--edit-cfg", help="Modification du fichier de configuration", action="store_true")
|
|
165
239
|
optional.add_argument("-v", "--verbose", help="Augmente la quantité de texte affiché", action="store_true")
|
|
166
240
|
optional.add_argument("-l", "--username", help="Nom d'utilisateur du compte cahier de prepa (utilisation sans compte possible)")
|
|
167
241
|
optional.add_argument("-p", "--password", help="Mot de passe de connexion cahier de prepa")
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
required.add_argument("-u", "--url", help="URL de l'instance cahier de prepa", required=True)
|
|
242
|
+
optional.add_argument("-o", "--output", help="Chemin d'acces du dossier de sortie, par default le dossier actuel")
|
|
243
|
+
optional.add_argument("-u", "--url", help="URL de l'instance cahier de prepa")
|
|
171
244
|
|
|
172
245
|
args = parser.parse_args()
|
|
173
246
|
|
|
@@ -176,10 +249,23 @@ def main(args=None):
|
|
|
176
249
|
|
|
177
250
|
verbose = args.verbose
|
|
178
251
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
252
|
+
if args.output is not None:
|
|
253
|
+
output_dir = args.output
|
|
254
|
+
|
|
255
|
+
if args.edit_cfg:
|
|
256
|
+
prompt_config_setup()
|
|
257
|
+
exit()
|
|
258
|
+
|
|
259
|
+
load_config(prompt_no_config=args.url is None)
|
|
260
|
+
|
|
261
|
+
if args.url is not None:
|
|
262
|
+
base_url = args.url
|
|
263
|
+
|
|
264
|
+
if args.username is not None:
|
|
265
|
+
username = args.username
|
|
266
|
+
|
|
267
|
+
if args.password is not None:
|
|
268
|
+
password = args.password
|
|
183
269
|
|
|
184
270
|
print("cdpDumpingUtils v", __version__)
|
|
185
271
|
print()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = '0.2.1'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: cdpDumpingUtils
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: Download all your courses filles from cahier de prepa
|
|
5
5
|
Home-page: https://github.com/Azuxul/cahier-de-prepa-downloader
|
|
6
6
|
Author: azuxul
|
|
@@ -55,30 +55,34 @@ cdpDumpingUtils -h
|
|
|
55
55
|
```
|
|
56
56
|
|
|
57
57
|
```
|
|
58
|
-
usage: cdpDumpingUtils [-h] [-v] [-l USERNAME] [-p PASSWORD] -o OUTPUT -u URL
|
|
58
|
+
usage: cdpDumpingUtils [-h] [--edit-cfg] [-v] [-l USERNAME] [-p PASSWORD] [-o OUTPUT] [-u URL]
|
|
59
59
|
|
|
60
60
|
options:
|
|
61
61
|
-h, --help show this help message and exit
|
|
62
62
|
|
|
63
63
|
arguments optionnels:
|
|
64
|
+
--edit-cfg Modification du fichier de configuration
|
|
64
65
|
-v, --verbose Augmente la quantité de texte affiché
|
|
65
66
|
-l USERNAME, --username USERNAME
|
|
66
67
|
Nom d'utilisateur du compte cahier de prepa (utilisation sans compte possible)
|
|
67
68
|
-p PASSWORD, --password PASSWORD
|
|
68
69
|
Mot de passe de connexion cahier de prepa
|
|
69
|
-
|
|
70
|
-
arguments requis:
|
|
71
70
|
-o OUTPUT, --output OUTPUT
|
|
72
|
-
Chemin d'acces du dossier de sortie
|
|
71
|
+
Chemin d'acces du dossier de sortie, par default le dossier actuel
|
|
73
72
|
-u URL, --url URL URL de l'instance cahier de prepa
|
|
74
73
|
```
|
|
75
74
|
|
|
76
|
-
To run cdpDumpingUtils
|
|
75
|
+
To run cdpDumpingUtils with a config file (if no config file it will be created) :
|
|
76
|
+
```
|
|
77
|
+
cdpDumpingUtils -o ./output
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
To run cdpDumpingUtils and specify an url without an account:
|
|
77
81
|
```
|
|
78
82
|
cdpDumpingUtils -u https://cahier-de-prepa.fr/XXX/ -o ./output
|
|
79
83
|
```
|
|
80
84
|
|
|
81
|
-
To run cdpDumpingUtils with an account:
|
|
85
|
+
To run cdpDumpingUtils and specify an url with an account:
|
|
82
86
|
```
|
|
83
87
|
cdpDumpingUtils -u https://cahier-de-prepa.fr/XXX/ -l username -p password -o ./output
|
|
84
88
|
```
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = '0.2.0'
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{cdpDumpingUtils-0.2.0 → cdpDumpingUtils-0.2.1}/cdpDumpingUtils.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|