Skip to content

Commit 7dc0353

Browse files
committed
version 2.0.13
1 parent 5585be3 commit 7dc0353

File tree

2 files changed

+53
-17
lines changed

2 files changed

+53
-17
lines changed

getcomic/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
__version__='2.0.10'
1+
__version__='2.0.13'
22
name='getcomic'

getcomic/getcomic.py

Lines changed: 52 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,15 @@ def main():
3333
print('\nTo stop the script press Ctrl+C\n')
3434
#Get current directory path
3535
curdirpath=os.getcwd()
36+
#print(curdirpath)
3637

3738
#Get site name
3839
site=sys.argv[1]
40+
print(site)
3941

4042
#Detect link types
4143
types=detectlinktype(site)
44+
#print(types)
4245

4346
if types[0]==False and types[1]==False:
4447
print('\nInvalid Url\n')
@@ -51,14 +54,18 @@ def main():
5154
os.makedirs(dest)
5255

5356
#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'
5561

5662
if types[0]==True or types[1]==True:
5763
if types[2]==False and types[3]==False:
5864
editurl='http://'+editurl
5965

6066
#Extract comic name and issue no from url
6167
names=extractnames(site,types[1])
68+
#print(names)
6269

6370
#Create Directory for the comic if it doesn't already exists
6471
tdir=dest+"/"+names[0]
@@ -116,19 +123,29 @@ def main():
116123
for di in dmap:
117124
#print('\nDownloading issue '+dmap[di].issue+' of comic '+names[0]+' ...\n')
118125
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'):
122138
print('\nDownloading issue '+dmap[di].issue+' of comic '+names[0]+' ...\n')
123139
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'):
125141
print('\nDownloading issue '+dmap[di].issue+' of comic '+names[0]+' ...\n')
126142
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'):
128144
print('\nDownloading issue '+dmap[di].issue+' of comic '+names[0]+' ...\n')
129145
done&=singlecomic(dmap[di].cname,dmap[di].issue,dmap[di].link,chapterpath,curdirpath)
130146
if done:
131147
print('\nPdfs of all issues you want are ready :-D\nEnjoy reading',dmap[di].cname,'!\n')
148+
sys.exit()
132149

133150
#os.chdir(curdirpath)
134151
print()
@@ -217,36 +234,54 @@ def singlecomic(name,issue,url,chapterpath,curdirpath):
217234
return done
218235

219236
def detectlinktype(site):
237+
sitename=""
220238
isseries=False
221239
isissue=False
222240
hashttp=False
223241
hashttps=False
242+
if site.find("readcomiconline")!=-1:
243+
sitename="readcomiconline"
244+
elif site.find("kissmanga")!=-1:
245+
sitename="kissmanga"
246+
224247
#comicex=re.compile('^http://[A-Za-z0-9]+.[A-Za-z]+/Comic')
225248
httpex=re.compile('^http\:\/\/')
226249
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
234266

235267
if httpex.match(site):
236268
hashttp=True
237269
elif httpsex.match(site):
238270
hashttps=True
239271

240-
return (isseries,isissue,hashttp,hashttps)
272+
return (isseries,isissue,hashttp,hashttps,sitename)
241273

242274

243275
def extractnames(site,isissue):
244276
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
246281
comicname=arr[x]
247282
issueno=""
248283
if isissue:
249-
issueno=arr[x+1].split("?")[0]
284+
issueno=arr[len(arr)-1].split("?")[0]
250285
return (comicname,issueno)
251286

252287
def fetchcomic(url,curdirpath):
@@ -316,3 +351,4 @@ def createpdf(urls,sz,chapterpath,filename):
316351
print('\n\nBuilding pdf...\n')
317352
pdf.output(filename,"F")
318353

354+
main()

0 commit comments

Comments
 (0)