Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save alexnum/b24b9cb67848befdf1d76798d8e9ed59 to your computer and use it in GitHub Desktop.
Save alexnum/b24b9cb67848befdf1d76798d8e9ed59 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
#Só funciona para o site https://lermangasonline.xyz
#Exemplo de execução:
#Recebe 3 argumentos:
#primeiro: Url para o manga
#Segundo e Terceiro: Do capitulo X até o capitulo Y, sendo X o segundo argumento e Y o terceiro.
#Exemplo:
#python main.py https://lermangasonline.xyz/sys_mangas/00sdfrw/S/shingeki-no-kyojin 61 90
import sys
import os
import urllib
MANGA_FOLDER = 'D:\Manga\\'
mangaUrl = sys.argv[1]
fromChapter = int(sys.argv[2])
toChapter = int(sys.argv[3])
ext = "jpg"
separator = '-'
mangaName = mangaUrl.split('/')[-1]
def switch_separator(separator):
return '_' if separator == '-' else '-'
def switch_ext(ext):
return 'jpg' if ext == 'png' else 'png'
for i in range(fromChapter, toChapter + 1):
page = 1
dir = MANGA_FOLDER+mangaName+"_"+str(i)
tries = 0;
print("downloading chapter: " + str(i))
if not os.path.exists(dir):
os.makedirs(dir)
while 1:
print("url: " + mangaUrl+'/cap'+separator+str(i)+'/'+'{:04}'.format(page)+'.'+ext)
filePath = dir+'\\'+ str(page)+"." + ext;
status = urllib.urlretrieve(mangaUrl+'/cap'+separator+str(i)+'/'+'{:04}'.format(page)+'.'+ext, dir+'\\'+ str(page)+"." + ext)
if 'text' in status[1].gettype():
os.remove(filePath)
if tries == 0:
separator = switch_separator(separator)
tries += 1
elif tries == 1:
ext = switch_ext(ext)
tries += 1
elif tries == 2:
separator = switch_separator(separator)
tries += 1
else:
break;
else:
tries = 0;
page += 1
print('Done')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment