Guest User

Manga-to-Kindle

a guest
Mar 27th, 2019
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.99 KB | None | 0 0
  1. # pip install manga-py
  2. # pip install KindleComicConverter
  3.  
  4. import os
  5. import zipfile
  6. from tqdm import tqdm
  7.  
  8. # Supported site where you download form (for reference: https://manga-dl.yuru-yuri.sttv.me/#resources-list)
  9. WEBSITE = ""
  10. # No spaces is mandatory 'cause I'm lazy (e.g. Blue_Exorcist)
  11. MANGA_NAME = ""
  12. # How many chapters you want per kindle file? (not too much, not too little)
  13. CHAPTERS_PER_FILE = 10
  14.  
  15. # Download manga in Manga/<MANGA_NAME>
  16. os.system("manga-py " + WEBSITE + " --name " + MANGA_NAME)
  17.  
  18. # DECOMPRESS
  19.  
  20. directory = "Manga/" + MANGA_NAME
  21.  
  22. zip_volumes = os.listdir(directory)
  23.  
  24. j = 1
  25. for i, zip_name in tqdm(list(enumerate(list(zip_volumes)))):
  26.     volume_name = zip_name[:-4]
  27.     file_name = MANGA_NAME + "_" + str(j)
  28.     os.system("mkdir " + directory + "\\decomp\\" +
  29.               file_name + "\\" + volume_name)
  30.     zip_file = zipfile.ZipFile(directory + "/" + zip_name)
  31.     zip_file.extractall(directory + "/decomp/" + file_name + "/" + volume_name)
  32.  
  33.     pages = os.listdir(directory + "/decomp/" + file_name + "/" + volume_name)
  34.     for page in pages:
  35.         if page == "info.txt":
  36.             os.remove(directory + "/decomp/" + file_name +
  37.                       "/" + volume_name + "/" + page)
  38.         else:
  39.             os.rename(directory + "/decomp/" + file_name + "/" + volume_name + "/" + page,
  40.                       directory + "/decomp/" + file_name + "/" + volume_name + "/" + page[:3] + ".webp")
  41.     if (i + 1) % CHAPTERS_PER_FILE == 0:
  42.         j += 1
  43.  
  44. # CREATE
  45.  
  46. creator_list = os.listdir(directory + "/decomp/")
  47.  
  48. for element in creator_list:
  49.     os.system(
  50.         # for reference visit: https://github.com/ciromattia/kcc
  51.         # REMEMBER TO SET UP YOUR KindleGen so that is reachable somewhere in your PATH variable!!!
  52.         "kcc-c2e " + directory.replace('/','\\') + "\\decomp\\" + element
  53.     )
  54.  
  55. # Final note: be sure to navigate the comic book with "panel view" disabled! So that you go page after page and not by randomly zooming all around!
Advertisement
Add Comment
Please, Sign In to add comment