|
46 | 46 | import settings as settings_file
|
47 | 47 |
|
48 | 48 | # Version of the script
|
49 |
| -script_version = (2, 5, 27) |
| 49 | +script_version = (2, 5, 28) |
50 | 50 | script_version_text = "v{}.{}.{}".format(*script_version)
|
51 | 51 |
|
52 | 52 | # Paths = existing library
|
@@ -321,6 +321,8 @@ def __str__(self):
|
321 | 321 | r"(\]|\}|\)) -",
|
322 | 322 | r"\bZom(\s)",
|
323 | 323 | r"Tail -",
|
| 324 | + r"꞉", |
| 325 | + r":", |
324 | 326 | ]
|
325 | 327 |
|
326 | 328 | 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):
|
2581 | 2583 |
|
2582 | 2584 | # Replace "- One-shot" after series name
|
2583 | 2585 | 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() |
2585 | 2587 |
|
2586 | 2588 | # replace underscores
|
2587 | 2589 | 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):
|
2754 | 2756 |
|
2755 | 2757 | # Replace "- One-shot" after series name
|
2756 | 2758 | 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() |
2758 | 2760 |
|
2759 | 2761 | # Remove dual space
|
2760 | 2762 | name = remove_dual_space(name).strip()
|
@@ -3467,12 +3469,13 @@ def upgrade_to_volume_class(
|
3467 | 3469 | not test_mode
|
3468 | 3470 | and file_obj.extension in manga_extensions
|
3469 | 3471 | 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) |
3473 | 3474 | ):
|
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 | + |
3476 | 3479 |
|
3477 | 3480 | if file_obj.is_one_shot:
|
3478 | 3481 | file_obj.volume_number = 1
|
@@ -11747,6 +11750,26 @@ def move_series_to_correct_library(paths_to_search=paths_with_types):
|
11747 | 11750 | send_message(f"\n\t\tError: {e}", error=True)
|
11748 | 11751 |
|
11749 | 11752 |
|
| 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 | + |
11750 | 11773 | # Optional features below, use at your own risk.
|
11751 | 11774 | # Activate them in settings.py
|
11752 | 11775 | def main():
|
@@ -11987,7 +12010,7 @@ def main():
|
11987 | 12010 | if library["id"] in libraries_to_scan:
|
11988 | 12011 | continue
|
11989 | 12012 |
|
11990 |
| - if library["root"] in path: |
| 12013 | + if is_root_present(library["root"], path): |
11991 | 12014 | libraries_to_scan.append(library["id"])
|
11992 | 12015 |
|
11993 | 12016 | # Send scan requests to each komga library
|
|
0 commit comments