Skip to content

Instantly share code, notes, and snippets.

@rkrishnasanka
Created April 7, 2013 13:33
Show Gist options
  • Save rkrishnasanka/5330497 to your computer and use it in GitHub Desktop.
Save rkrishnasanka/5330497 to your computer and use it in GitHub Desktop.
A simple script that downloads the JL8 Comics from http://www.limbero.org and makes it into a cbz
import urllib2
import os
import zipfile
def downloadimage(img):
r = urllib2.urlopen("http://www.limbero.org/jl8/comics/"+img)
f= open(path+'\\'+img,'wb')
f.write(r.read())
f.close()
print img + ' has been downloaded and saved ! \n'
path = 'jl8'
if not os.path.isdir(path):
os.mkdir(path)
print "downloading images \n"
for i in range(1,119):
img = str(i)+".jpeg"
try:
downloadimage(img)
except:
print img + ' could not be downloaded'
for ii in range(1,50):
img = str(i)+"_"+str(ii)+".jpeg"
try:
downloadimage(img)
except:
print img + ' could not be downloaded'
break
zip = zipfile.ZipFile((str(path)+'.cbz'),'w')
out = 1
for root, dirs, files in os.walk(path):
for file in files:
outfilename = str(out) + '.jpeg'
zip.write(str(path)+'\\'+file,outfilename)
out = out + 1
zip.close()
for root , dirs , files in os.walk(path):
for name in files:
os.remove(os.path.join(root, name))
for name in dirs:
os.rmdir(os.path.join(root, name))
os.rmdir(root)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment