-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_handler_mangadex.py
346 lines (230 loc) · 10.4 KB
/
test_handler_mangadex.py
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
import logging
from handler_mangadex import *
from constants import *
from os.path import expanduser
import multiprocessing as mp
def download(tid):
if tid == 0:
mh = HandlerMangaDex(0, SOURCE_MANGADEX)
mh.reset_for_next_title()
mh.init_for_title("test/", "https://mangadex.org/title/879af0bb-ce30-47e4-a74e-cd1ce874c6e3/isekai-nonbiri-nouka")
mh.extract_metadata()
mh.start_driver()
mh.init_for_chapter("216", "https://mangadex.org/chapter/d1d38099-b7a4-459b-ad4c-729bd74c55f9")
mh.extract_chapter_images()
mh.reset_for_next_chapter()
mh.terminate_driver()
elif tid == 1:
mh = HandlerMangaDex(1, SOURCE_MANGADEX)
mh.reset_for_next_title()
mh.init_for_title("test/", "https://mangadex.org/title/ffe69cc2-3f9e-4eab-a7f7-c963cea9ec25/hitoribocchi-no-isekai-kouryaku")
mh.extract_metadata()
mh.start_driver()
mh.init_for_chapter("216", "https://mangadex.org/chapter/207f85d5-06cd-4e01-ac3a-64c009bfad93")
mh.extract_chapter_images()
mh.reset_for_next_chapter()
mh.terminate_driver()
else:
assert(0)
def test_mp():
p = mp.Pool(2)
p.map(download, [i for i in range(2)])
def test_chapter_download():
mh = HandlerMangaDex(0, SOURCE_MANGADEX)
mh.reset_for_next_title()
mh.init_for_title("test/", "https://mangadex.org/title/879af0bb-ce30-47e4-a74e-cd1ce874c6e3/isekai-nonbiri-nouka")
mh.extract_metadata()
mh.start_driver()
mh.init_for_chapter("216", "https://mangadex.org/chapter/d1d38099-b7a4-459b-ad4c-729bd74c55f9")
mh.extract_chapter_images()
mh.reset_for_next_chapter()
mh.terminate_driver()
def test_comicinfo_and_zip():
mh = HandlerMangaDex(0, SOURCE_MANGADEX)
mh.reset_for_next_title()
mh.init_for_title("test/", "https://mangadex.org/title/879af0bb-ce30-47e4-a74e-cd1ce874c6e3/isekai-nonbiri-nouka")
mh.extract_metadata()
mh.start_driver()
mh.init_for_chapter("216", "https://mangadex.org/chapter/d1d38099-b7a4-459b-ad4c-729bd74c55f9")
mh.extract_chapter_images()
mh.create_comic_info()
mh.create_cbz()
mh.reset_for_next_chapter()
mh.terminate_driver()
def test_title_metadata():
mh = HandlerMangaDex(0, SOURCE_MANGADEX)
mh.reset_for_next_title()
mh.init_for_title("test/", "https://mangadex.org/title/879af0bb-ce30-47e4-a74e-cd1ce874c6e3/isekai-nonbiri-nouka")
mh.extract_metadata()
mh.metadata.dump()
def test_title_metadata2():
mh = HandlerMangaDex(0, SOURCE_MANGADEX)
mh.reset_for_next_title()
mh.init_for_title("test/", "https://mangadex.org/title/ffe69cc2-3f9e-4eab-a7f7-c963cea9ec25/hitoribocchi-no-isekai-kouryaku")
mh.extract_metadata()
mh.metadata.dump()
def test_title_metadata3():
mh = HandlerMangaDex(0, SOURCE_MANGADEX)
mh.reset_for_next_title()
mh.init_for_title("test/", "https://mangadex.org/title/027df837-7a15-4893-9dc3-e2ae11b94717/2d5bcdb0-e2a3-4352-9043-2ab218bee11b")
mh.extract_metadata()
mh.metadata.dump()
def test_title_metadata4():
mh = HandlerMangaDex(0, SOURCE_MANGADEX)
mh.reset_for_next_title()
mh.init_for_title("test/", "https://mangadex.org/title/076b3757-2050-4362-b0ad-52513ecefa3f")
mh.extract_metadata()
mh.metadata.dump(log=True)
def test_title_metadata5():
mh = HandlerMangaDex(0, SOURCE_MANGADEX)
mh.reset_for_next_title()
mh.init_for_title("test/", "https://mangadex.org/title/0e009a58-6ebf-445b-8057-a1a69b8f8c7f/202cf5e2-44c9-4b4c-8c99-55f354f518fb")
mh.extract_metadata()
mh.metadata.dump(log=True)
def test_title_metadata6():
mh = HandlerMangaDex(0, SOURCE_MANGADEX)
mh.reset_for_next_title()
mh.init_for_title(expanduser("test/"), "https://mangadex.org/title/12e28a8a-cbfe-4e12-bab8-b6fb0b9a59b4/09960d27-f0a4-42bc-9e2b-c77ac93eec2a")
mh.extract_metadata()
mh.metadata.dump(log=True)
def test_language_selection():
mh = HandlerMangaDex(0, SOURCE_MANGADEX)
mh.reset_for_next_title()
mh.start_driver()
mh.init_for_title("test/", "https://mangadex.org/title/879af0bb-ce30-47e4-a74e-cd1ce874c6e3/isekai-nonbiri-nouka")
mh.select_chapter_language()
mh.terminate_driver()
def test_language_selection1():
mh = HandlerMangaDex(0, SOURCE_MANGADEX)
mh.reset_for_next_title()
mh.init_for_title("test/", "https://mangadex.org/title/00b64b8f-cb7e-4322-9855-3669fe210ac7/766f76d8-316d-4174-aca1-971c00f830c3")
mh.extract_metadata()
def test_full():
mh = HandlerMangaDex(0, SOURCE_MANGADEX, "test_missing.txt")
mh.reset_for_next_title()
mh.init_for_title("test/", "https://mangadex.org/title/6af5379f-ace2-453f-a9dd-94f7c443937a/shinozaki-himeno-s-love-q-a")
mh.extract_metadata()
mh.get_update()
def test_full1():
mh = HandlerMangaDex(0, SOURCE_MANGADEX)
mh.reset_for_next_title()
mh.init_for_title("test/", "https://mangadex.org/title/010abcb5-c705-4dcb-a51d-49b2c518b673/ea4a2fff-90fa-46f2-9d4e-ced50b02af52")
mh.extract_metadata()
mh.get_update()
def test_full2():
mh = HandlerMangaDex(0, SOURCE_MANGADEX)
mh.reset_for_next_title()
mh.init_for_title("test/", "https://mangadex.org/title/009c62ce-6064-4409-9949-4f00ba6d593c/cheat-skill-shisha-sosei-ga-kakusei-shite-inishie-no-maougun-wo-fukkatsu-sasete-shimaimashita")
mh.extract_metadata()
mh.get_update()
def test_full3():
mh = HandlerMangaDex(0, SOURCE_MANGADEX)
mh.reset_for_next_title()
mh.init_for_title("test/", "https://mangadex.org/title/009c62ce-6064-4409-9949-4f00ba6d593c/daf63c4b-af64-47a3-8c0c-0363db7f0547")
mh.extract_metadata()
mh.get_update()
def test_full4():
"""
webtoon test
"""
mh = HandlerMangaDex(0, SOURCE_MANGADEX)
mh.reset_for_next_title()
mh.init_for_title("test/", "https://mangadex.org/title/0b9dfda1-8255-46ff-90f5-f0980923a1b0/1e8f8b80-49a6-4ac4-84ee-20715aa49b45")
mh.extract_metadata()
mh.get_update()
def test_full5():
"""
Ch 200 first page has weird class that differs
and therefore could not be found by XPATH
Need to check for the image some other way in order for it to be found
Possibly find by //img that has a blob and not display none
Also need to modify the execute script part to ensure that the class passed through
is obtained via selenium
"""
mh = HandlerMangaDex(0, SOURCE_MANGADEX)
mh.reset_for_next_title()
mh.init_for_title("test/", "https://mangadex.org/title/259dfd8a-f06a-4825-8fa6-a2dcd7274230/bd573ff3-2cf0-4ed2-968d-da046d26f3b2")
mh.extract_metadata()
mh.get_update()
def test_get_mangaupdates_link():
mh = HandlerMangaDex(0, SOURCE_MANGADEX)
mh.reset_for_next_title()
mh.init_for_title("test/", "https://mangadex.org/title/0b9dfda1-8255-46ff-90f5-f0980923a1b0/1e8f8b80-49a6-4ac4-84ee-20715aa49b45")
mh.extract_mangaupdates_url()
logging.info("MangaUpdates URL: " + mh.current_title_manga_updates_base_url)
def test_get_mangaupdates_translated_chs():
mh = HandlerMangaDex(0, SOURCE_MANGADEX, "test_missing.txt")
mh.reset_for_next_title()
mh.init_for_title("test/", "https://mangadex.org/title/0b9dfda1-8255-46ff-90f5-f0980923a1b0/1e8f8b80-49a6-4ac4-84ee-20715aa49b45")
mh.extract_mangaupdates_url()
logging.info("MangaUpdates URL: " + mh.current_title_manga_updates_base_url)
mh.check_manga_updates_status()
def test_get_mangaupdates_translated_chs1():
mh = HandlerMangaDex(0, SOURCE_MANGADEX, "test_missing.txt")
mh.reset_for_next_title()
mh.init_for_title("test/", "https://mangadex.org/title/6af5379f-ace2-453f-a9dd-94f7c443937a/shinozaki-himeno-s-love-q-a")
mh.extract_mangaupdates_url()
logging.info("MangaUpdates URL: " + mh.current_title_manga_updates_base_url)
mh.check_manga_updates_status()
def test_get_mangaupdates_translated_chs2():
mh = HandlerMangaDex(0, SOURCE_MANGADEX)
mh.reset_for_next_title()
mh.init_for_title("test/", "https://mangadex.org/title/10db587f-a232-485d-b4a8-68ee0cb15e3c/93ee0736-016a-42cf-bd09-7129280318f5")
mh.extract_mangaupdates_url()
logging.info("MangaUpdates URL: " + mh.current_title_manga_updates_base_url)
mh.check_manga_updates_status()
# mh.get_update()
def test_get_mangaupdates_translated_chs2():
"""
Test 14c chapter
"""
mh = HandlerMangaDex(0, SOURCE_MANGADEX, "test_missing.txt")
mh.reset_for_next_title()
mh.init_for_title("test/", "https://mangadex.org/title/024af7a5-f8ad-4b67-b950-b1708f52b018/7875e964-5034-4fd9-aacd-0e65eb181db4")
mh.extract_mangaupdates_url()
logging.info("MangaUpdates URL: " + mh.current_title_manga_updates_base_url)
mh.check_manga_updates_status()
def test_get_mangaupdates_translated_chs3():
"""
MangaUpdates containts things like
Extras
20 (End)
https://mangadex.org/title/051e6a66-7373-4583-98b6-b746153041e9/e9985bbe-ace2-4cc0-a56c-99cd25de0990
"""
mh = HandlerMangaDex(0, SOURCE_MANGADEX, "test_missing.txt")
mh.reset_for_next_title()
mh.init_for_title("test/", "https://mangadex.org/title/051e6a66-7373-4583-98b6-b746153041e9/e9985bbe-ace2-4cc0-a56c-99cd25de0990")
mh.extract_mangaupdates_url()
logging.info("MangaUpdates URL: " + mh.current_title_manga_updates_base_url)
mh.check_manga_updates_status()
def test_get_mangaupdates_translated_chs4():
mh = HandlerMangaDex(0, SOURCE_MANGADEX, "test_missing.txt")
mh.reset_for_next_title()
mh.init_for_title("test/", "https://mangadex.org/title/08ff391a-7991-4c43-8741-531d7d0b2165/e14c3d10-7cd3-481b-b602-e3b68b6084d2")
mh.extract_mangaupdates_url()
logging.info("MangaUpdates URL: " + mh.current_title_manga_updates_base_url)
mh.check_manga_updates_status()
def test_mangaupdates_missing():
mh = HandlerMangaDex(0, SOURCE_MANGADEX, "test_missing.txt")
mh.reset_for_next_title()
mh.init_for_title("test/", "https://mangadex.org/title/10227f74-9134-4262-b01d-8966bc149c4d/b7d1a6ea-fbb9-4fa5-a6a4-098320656f24")
mh.extract_mangaupdates_url()
logging.info("MangaUpdates URL: " + mh.current_title_manga_updates_base_url)
mh.check_manga_updates_status()
if __name__ == "__main__":
# Setup Logging
logging.basicConfig(level=logging.INFO
, format="%(asctime)s;%(levelname)s;%(message)s"
, datefmt="%Y-%m-%d %H:%M:%S"
, filename="test_log.txt"
, filemode="w")
# define a Handler which writes INFO messages or higher to the sys.stderr
console = logging.StreamHandler()
console.setLevel(logging.INFO)
# set a format which is simpler for console use
formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s')
# tell the handler to use this format
console.setFormatter(formatter)
# add the handler to the root logger
logging.getLogger().addHandler(console)
test_full4()