@@ -33,12 +33,15 @@ def main():
33
33
print ('\n To stop the script press Ctrl+C\n ' )
34
34
#Get current directory path
35
35
curdirpath = os .getcwd ()
36
+ #print(curdirpath)
36
37
37
38
#Get site name
38
39
site = sys .argv [1 ]
40
+ print (site )
39
41
40
42
#Detect link types
41
43
types = detectlinktype (site )
44
+ #print(types)
42
45
43
46
if types [0 ]== False and types [1 ]== False :
44
47
print ('\n Invalid Url\n ' )
@@ -51,14 +54,18 @@ def main():
51
54
os .makedirs (dest )
52
55
53
56
#Edit url to download all pages of the comic
54
- editurl = str (site )+ '?readType=1'
57
+ if types [4 ]== "readcomiconline" :
58
+ editurl = str (site )+ '?readType=1'
59
+ else :
60
+ editurl = str (site )+ '&readType=1'
55
61
56
62
if types [0 ]== True or types [1 ]== True :
57
63
if types [2 ]== False and types [3 ]== False :
58
64
editurl = 'http://' + editurl
59
65
60
66
#Extract comic name and issue no from url
61
67
names = extractnames (site ,types [1 ])
68
+ #print(names)
62
69
63
70
#Create Directory for the comic if it doesn't already exists
64
71
tdir = dest + "/" + names [0 ]
@@ -116,19 +123,29 @@ def main():
116
123
for di in dmap :
117
124
#print('\nDownloading issue '+dmap[di].issue+' of comic '+names[0]+' ...\n')
118
125
tel = dmap [di ].issue .split ('-' )
119
- subno = int (tel [- 1 ])
120
- sub = tel [- 2 ]
121
- if (an == 'y' and subno >= a1 and subno <= a2 and sub == 'Annual' ):
126
+ #subno=int(tel[-1])
127
+ subno = - 1
128
+ subst = ""
129
+ if (tel [- 1 ].isdigit ()):
130
+ subno = int (tel [- 1 ])
131
+ else :
132
+ subst = tel [- 1 ]
133
+ sub = ""
134
+ #print(chs,subno,v1,v2)
135
+ if subno != - 1 :
136
+ sub = tel [- 2 ]
137
+ if (an == 'y' and subno != - 1 and subno >= a1 and subno <= a2 and sub == 'Annual' ):
122
138
print ('\n Downloading issue ' + dmap [di ].issue + ' of comic ' + names [0 ]+ ' ...\n ' )
123
139
done &= singlecomic (dmap [di ].cname ,dmap [di ].issue ,dmap [di ].link ,chapterpath ,curdirpath )
124
- if (chs == 'y' and subno >= v1 and subno <= v2 and sub != 'Annual' ):
140
+ if (chs == 'y' and subno != - 1 and subno >= v1 and subno <= v2 and sub != 'Annual' ):
125
141
print ('\n Downloading issue ' + dmap [di ].issue + ' of comic ' + names [0 ]+ ' ...\n ' )
126
142
done &= singlecomic (dmap [di ].cname ,dmap [di ].issue ,dmap [di ].link ,chapterpath ,curdirpath )
127
- if ch == 'n' :
143
+ elif ( subno == - 1 or subst != "" or ch == 'n' ) :
128
144
print ('\n Downloading issue ' + dmap [di ].issue + ' of comic ' + names [0 ]+ ' ...\n ' )
129
145
done &= singlecomic (dmap [di ].cname ,dmap [di ].issue ,dmap [di ].link ,chapterpath ,curdirpath )
130
146
if done :
131
147
print ('\n Pdfs of all issues you want are ready :-D\n Enjoy reading' ,dmap [di ].cname ,'!\n ' )
148
+ sys .exit ()
132
149
133
150
#os.chdir(curdirpath)
134
151
print ()
@@ -217,36 +234,54 @@ def singlecomic(name,issue,url,chapterpath,curdirpath):
217
234
return done
218
235
219
236
def detectlinktype (site ):
237
+ sitename = ""
220
238
isseries = False
221
239
isissue = False
222
240
hashttp = False
223
241
hashttps = False
242
+ if site .find ("readcomiconline" )!= - 1 :
243
+ sitename = "readcomiconline"
244
+ elif site .find ("kissmanga" )!= - 1 :
245
+ sitename = "kissmanga"
246
+
224
247
#comicex=re.compile('^http://[A-Za-z0-9]+.[A-Za-z]+/Comic')
225
248
httpex = re .compile ('^http\:\/\/' )
226
249
httpsex = re .compile ('^https\:\/\/' )
227
- comicex = re .compile ('((https?\:\/\/)?[A-Za-z0-9]+\.[A-Za-z]+/Comic/[A-Za-z0-9\-]+)' )
228
- issueex = re .compile ('((https?\:\/\/)?[A-Za-z0-9]+\.[A-Za-z]+/Comic/[A-Za-z0-9\-]+/[A-Za-z0-9\-]+\?id=[0-9]+)' )
229
-
230
- if comicex .match (site ):
231
- isseries = True
232
- if issueex .match (site ):
233
- isissue = True
250
+ if sitename == "readcomiconline" :
251
+ comicex = re .compile ('((https?\:\/\/)?[A-Za-z0-9]+\.[A-Za-z]+/Comic/[A-Za-z0-9\-]+)' )
252
+ issueex = re .compile ('((https?\:\/\/)?[A-Za-z0-9]+\.[A-Za-z]+/Comic/[A-Za-z0-9\-]+/[A-Za-z0-9\-]+\?id=[0-9]+)' )
253
+
254
+ if comicex .match (site ):
255
+ isseries = True
256
+ if issueex .match (site ):
257
+ isissue = True
258
+ elif sitename == "kissmanga" :
259
+ comicex = re .compile ('((https?\:\/\/)?[A-Za-z0-9]+\.[A-Za-z]+/Manga/[A-Za-z0-9\-]+)' )
260
+ issueex = re .compile ('((https?\:\/\/)?[A-Za-z0-9]+\.[A-Za-z]+/Manga/[A-Za-z0-9\-]+/[A-Za-z0-9\-]+\?id=[0-9]+)' )
261
+
262
+ if comicex .match (site ):
263
+ isseries = True
264
+ if issueex .match (site ):
265
+ isissue = True
234
266
235
267
if httpex .match (site ):
236
268
hashttp = True
237
269
elif httpsex .match (site ):
238
270
hashttps = True
239
271
240
- return (isseries ,isissue ,hashttp ,hashttps )
272
+ return (isseries ,isissue ,hashttp ,hashttps , sitename )
241
273
242
274
243
275
def extractnames (site ,isissue ):
244
276
arr = site .split ("/" )
245
- x = arr .index ("Comic" )+ 1
277
+ if ("Comic" in arr ) and arr .index ("Comic" )!= - 1 :
278
+ x = arr .index ("Comic" )+ 1
279
+ elif ("Manga" in arr ) and arr .index ("Manga" )!= - 1 :
280
+ x = arr .index ("Manga" )+ 1
246
281
comicname = arr [x ]
247
282
issueno = ""
248
283
if isissue :
249
- issueno = arr [x + 1 ].split ("?" )[0 ]
284
+ issueno = arr [len ( arr ) - 1 ].split ("?" )[0 ]
250
285
return (comicname ,issueno )
251
286
252
287
def fetchcomic (url ,curdirpath ):
@@ -316,3 +351,4 @@ def createpdf(urls,sz,chapterpath,filename):
316
351
print ('\n \n Building pdf...\n ' )
317
352
pdf .output (filename ,"F" )
318
353
354
+ main ()
0 commit comments