Skip to content

Commit 4b62ba6

Browse files
authoredMar 11, 2025··
v2.5.28
1 parent d714c94 commit 4b62ba6

File tree

1 file changed

+32
-9
lines changed

1 file changed

+32
-9
lines changed
 

‎komga_cover_extractor.py

+32-9
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
import settings as settings_file
4747

4848
# Version of the script
49-
script_version = (2, 5, 27)
49+
script_version = (2, 5, 28)
5050
script_version_text = "v{}.{}.{}".format(*script_version)
5151

5252
# Paths = existing library
@@ -321,6 +321,8 @@ def __str__(self):
321321
r"(\]|\}|\)) -",
322322
r"\bZom(\s)",
323323
r"Tail -",
324+
r"꞉",
325+
r":",
324326
]
325327

326328
subtitle_exclusion_keywords = [r"-(\s)", r"-", r"-\s[A-Za-z]+\s"]
@@ -2581,7 +2583,7 @@ def get_series_name_from_volume(name, root, test_mode=False, second=False):
25812583

25822584
# Replace "- One-shot" after series name
25832585
if "one" in name.lower() and "shot" in name.lower():
2584-
name = re.sub(r"(-\s*)One(-|)shot\s*", "", name, flags=re.IGNORECASE).strip()
2586+
name = re.sub(r"(-\s*)Ones?(-|)shot\s*", "", name, flags=re.IGNORECASE).strip()
25852587

25862588
# replace underscores
25872589
name = replace_underscores(name) if "_" in name else name
@@ -2754,7 +2756,7 @@ def get_series_name_from_chapter(name, root, chapter_number="", second=False):
27542756

27552757
# Replace "- One-shot" after series name
27562758
if "one" in name.lower() and "shot" in name.lower():
2757-
name = re.sub(r"(-\s*)One(-|)shot\s*", "", name, flags=re.IGNORECASE).strip()
2759+
name = re.sub(r"(-\s*)Ones?(-|)shot\s*", "", name, flags=re.IGNORECASE).strip()
27582760

27592761
# Remove dual space
27602762
name = remove_dual_space(name).strip()
@@ -3467,12 +3469,13 @@ def upgrade_to_volume_class(
34673469
not test_mode
34683470
and file_obj.extension in manga_extensions
34693471
and file_obj.file_type != "chapter"
3470-
and not file_obj.volume_number
3471-
and check_for_exception_keywords(file_obj.name, exception_keywords)
3472-
and (is_first_image_black_and_white(file_obj.path) or count_images_in_cbz(file.path) <= average_chapter_image_count)
3472+
and (not file_obj.volume_number or file_obj.is_one_shot)
3473+
and (check_for_exception_keywords(file_obj.name, exception_keywords) or file_obj.is_one_shot)
34733474
):
3474-
file_obj.file_type = "chapter"
3475-
file_obj.is_one_shot = True
3475+
if is_first_image_black_and_white(file_obj.path) or count_images_in_cbz(file_obj.path) <= average_chapter_image_count:
3476+
file_obj.file_type = "chapter"
3477+
file_obj.is_one_shot = True
3478+
34763479

34773480
if file_obj.is_one_shot:
34783481
file_obj.volume_number = 1
@@ -11747,6 +11750,26 @@ def move_series_to_correct_library(paths_to_search=paths_with_types):
1174711750
send_message(f"\n\t\tError: {e}", error=True)
1174811751

1174911752

11753+
# Normalize path separators and remove Windows drive letters if present.
11754+
def normalize_path(path):
11755+
path = os.path.normpath(path)
11756+
11757+
# Remove Windows drive letters (e.g., "Z:\example\path" -> "\example\path")
11758+
if ":" in path:
11759+
path = re.sub(r"^[A-Za-z]:", "", path)
11760+
11761+
# Convert backslashes to forward slashes for uniform comparison
11762+
return path.replace("\\", "/")
11763+
11764+
11765+
# Check if root_path is a prefix of target_path, handling Windows and Linux paths.
11766+
def is_root_present(root_path, target_path):
11767+
root_path = normalize_path(root_path)
11768+
target_path = normalize_path(target_path)
11769+
11770+
return root_path in target_path
11771+
11772+
1175011773
# Optional features below, use at your own risk.
1175111774
# Activate them in settings.py
1175211775
def main():
@@ -11987,7 +12010,7 @@ def main():
1198712010
if library["id"] in libraries_to_scan:
1198812011
continue
1198912012

11990-
if library["root"] in path:
12013+
if is_root_present(library["root"], path):
1199112014
libraries_to_scan.append(library["id"])
1199212015

1199312016
# Send scan requests to each komga library

0 commit comments

Comments
 (0)
Please sign in to comment.