This isn't really going to be useful for anyone else. But if you have a comic/manga collection where every series is stored in a directory that contains directories representing each chapter of the series, and you want to turn those directories into .cbz
files, this may be of some use for you.
Created
June 16, 2022 21:00
-
-
Save PythonCoderAS/2a9f8c7adf4657ca60c2eb115f444c27 to your computer and use it in GitHub Desktop.
A script to convert my existing manga directories to one compatible with komga
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from os import listdir, makedirs | |
from os.path import abspath, expanduser, isdir, join | |
from zipfile import ZIP_DEFLATED, ZipFile | |
from tqdm import tqdm | |
BASE = abspath(expanduser("~/Manga/downloaded-manga")) | |
KOMGA_BASE = abspath(expanduser("~/Manga/downloaded-manga-komga")) | |
for manga in tqdm(listdir(BASE), desc="Manga"): | |
manga_base = join(BASE, manga) | |
if not isdir(manga_base): | |
continue | |
komga_manga_base = join(KOMGA_BASE, manga) | |
makedirs(komga_manga_base, exist_ok=True) | |
for chapter in tqdm(listdir(manga_base), desc="Chapters", leave=False): | |
chapter_base = join(manga_base, chapter) | |
if not isdir(chapter_base): | |
continue | |
zipfile = ZipFile(join(komga_manga_base, chapter)[:250] + ".cbz", mode="w", compression=ZIP_DEFLATED) | |
for file in tqdm(listdir(chapter_base), desc="Files", leave=False): | |
zipfile.write(join(chapter_base, file), file) | |
zipfile.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tqdm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment