Skip to content

Commit 2eaf502

Browse files
authored
v2.5.20
1 parent 6a59f43 commit 2eaf502

File tree

1 file changed

+29
-28
lines changed

1 file changed

+29
-28
lines changed

Diff for: komga_cover_extractor.py

+29-28
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, 19)
49+
script_version = (2, 5, 20)
5050
script_version_text = "v{}.{}.{}".format(*script_version)
5151

5252
# Paths = existing library
@@ -1730,7 +1730,7 @@ def handle_fields(embed, fields):
17301730

17311731

17321732
# Handles picking a webhook url, to evenly distribute the load
1733-
@lru_cache(maxsize=None)
1733+
@lru_cache(maxsize=10)
17341734
def pick_webhook(hook, passed_webhook=None, url=None):
17351735
global last_hook_index
17361736

@@ -1853,7 +1853,7 @@ def ends_with_bracket(s):
18531853

18541854

18551855
# check if volume file name is a chapter
1856-
@lru_cache(maxsize=None)
1856+
@lru_cache(maxsize=3500)
18571857
def contains_chapter_keywords(file_name):
18581858
# Replace "_extra"
18591859
file_name_clean = file_name.replace("_extra", ".5")
@@ -1925,7 +1925,7 @@ def contains_brackets(s):
19251925

19261926
# Removes bracketed content from the string, alongwith any whitespace.
19271927
# As long as the bracketed content is not immediately preceded or followed by a dash.
1928-
@lru_cache(maxsize=None)
1928+
@lru_cache(maxsize=3500)
19291929
def remove_brackets(string):
19301930
# Avoid a string that is only a bracket
19311931
# Probably a series name
@@ -1981,7 +1981,7 @@ def remove_brackets(string):
19811981

19821982

19831983
# Checks if the passed string contains volume keywords
1984-
@lru_cache(maxsize=None)
1984+
@lru_cache(maxsize=3500)
19851985
def contains_volume_keywords(file):
19861986
# Replace _extra
19871987
file = file.replace("_extra", ".5")
@@ -2344,7 +2344,7 @@ def get_novel_cover(novel_path):
23442344

23452345

23462346
# Checks if the passed string is a volume one.
2347-
@lru_cache(maxsize=None)
2347+
@lru_cache(maxsize=3500)
23482348
def is_volume_one(volume_name):
23492349
keywords = volume_regex_keywords
23502350

@@ -2390,7 +2390,7 @@ def is_one_shot(file_name, root=None, skip_folder_check=False, test_mode=False):
23902390

23912391

23922392
# Checks similarity between two strings.
2393-
@lru_cache(maxsize=None)
2393+
@lru_cache(maxsize=3500)
23942394
def similar(a, b):
23952395
# convert to lowercase and strip
23962396
a = a.lower().strip()
@@ -2564,7 +2564,7 @@ def contains_keyword(file_string, chapter=False):
25642564

25652565
# Retrieves the series name through various regexes
25662566
# Removes the volume number and anything to the right of it, and strips it.
2567-
@lru_cache(maxsize=None)
2567+
@lru_cache(maxsize=3500)
25682568
def get_series_name_from_volume(name, root, test_mode=False, second=False):
25692569
# Remove starting brackets
25702570
# EX: "[WN] Series Name" -> "Series Name"
@@ -2654,7 +2654,7 @@ def get_series_name_from_volume(name, root, test_mode=False, second=False):
26542654

26552655

26562656
# Cleans the chapter file_name to retrieve the series_name
2657-
@lru_cache(maxsize=None)
2657+
@lru_cache(maxsize=3500)
26582658
def chapter_file_name_cleaning(
26592659
file_name, chapter_number="", skip=False, regex_matched=False
26602660
):
@@ -2833,7 +2833,7 @@ def get_folder_type(files, extensions=None, file_type=None):
28332833
# Determines if a volume file is a multi-volume file or not
28342834
# EX: TRUE == series_title v01-03.cbz
28352835
# EX: FALSE == series_title v01.cbz
2836-
@lru_cache(maxsize=None)
2836+
@lru_cache(maxsize=3500)
28372837
def check_for_multi_volume_file(file_name, chapter=False):
28382838
# Set the list of keywords to search for
28392839
keywords = volume_regex_keywords if not chapter else chapter_regex_keywords + "|"
@@ -2915,7 +2915,7 @@ def contains_non_numeric(input_string):
29152915

29162916

29172917
# Finds the volume/chapter number(s) in the file name.
2918-
@lru_cache(maxsize=None)
2918+
@lru_cache(maxsize=3500)
29192919
def get_release_number(file, chapter=False):
29202920

29212921
# Cleans up the chapter's series name
@@ -3196,7 +3196,7 @@ def get_extra_from_group(
31963196

31973197

31983198
# Retrieves and returns the file part from the file name
3199-
@lru_cache(maxsize=None)
3199+
@lru_cache(maxsize=3500)
32003200
def get_file_part(file, chapter=False, series_name=None, subtitle=None):
32013201
result = ""
32023202

@@ -4693,7 +4693,7 @@ def reorganize_and_rename(files, dir):
46934693

46944694

46954695
# Replaces any pesky double spaces
4696-
@lru_cache(maxsize=None)
4696+
@lru_cache(maxsize=3500)
46974697
def remove_dual_space(s):
46984698
if " " not in s:
46994699
return s
@@ -4704,7 +4704,7 @@ def remove_dual_space(s):
47044704
# Removes common words to improve string matching accuracy between a series_name
47054705
# from a file name, and a folder name, useful for when releasers sometimes include them,
47064706
# and sometimes don't.
4707-
@lru_cache(maxsize=None)
4707+
@lru_cache(maxsize=3500)
47084708
def normalize_str(
47094709
s,
47104710
skip_common_words=False,
@@ -4807,7 +4807,7 @@ def normalize_str(
48074807

48084808

48094809
# Removes the s from any words that end in s
4810-
@lru_cache(maxsize=None)
4810+
@lru_cache(maxsize=3500)
48114811
def remove_s(s):
48124812
return re.sub(r"\b(\w+)(s)\b", r"\1", s, flags=re.IGNORECASE).strip()
48134813

@@ -4822,14 +4822,14 @@ def contains_punctuation(s):
48224822

48234823

48244824
# Returns a string without punctuation.
4825-
@lru_cache(maxsize=None)
4825+
@lru_cache(maxsize=3500)
48264826
def remove_punctuation(s):
48274827
return re.sub(r"[^\w\s+]", " ", s).strip()
48284828

48294829

48304830
# Cleans the string by removing punctuation, bracketed info, and replacing underscores with periods.
48314831
# Converts the string to lowercase and removes leading/trailing whitespace.
4832-
@lru_cache(maxsize=None)
4832+
@lru_cache(maxsize=3500)
48334833
def clean_str(
48344834
string,
48354835
skip_lowercase_convert=False,
@@ -5041,7 +5041,7 @@ def create_folders_for_items_in_download_folder():
50415041

50425042

50435043
# convert string to acsii
5044-
@lru_cache(maxsize=None)
5044+
@lru_cache(maxsize=3500)
50455045
def convert_to_ascii(s):
50465046
return "".join(i for i in s if ord(i) < 128)
50475047

@@ -5475,7 +5475,7 @@ def remove_duplicates(items):
54755475

54765476
# Return the zip comment for the passed zip file (cached)
54775477
# Used on existing library files.
5478-
@lru_cache(maxsize=None)
5478+
@lru_cache(maxsize=3500)
54795479
def get_zip_comment_cache(zip_file):
54805480
comment = ""
54815481
try:
@@ -5780,7 +5780,7 @@ def check_for_duplicate_volumes(paths_to_search=[]):
57805780

57815781

57825782
# Regex out underscore from passed string and return it
5783-
@lru_cache(maxsize=None)
5783+
@lru_cache(maxsize=3500)
57845784
def replace_underscores(name):
57855785
# Replace underscores that are preceded and followed by a number with a period
57865786
name = re.sub(r"(?<=\d)_(?=\d)", ".", name)
@@ -5849,7 +5849,7 @@ def get_identifiers(zip_comment):
58495849

58505850
# Parses the individual words from the passed string and returns them as an array
58515851
# without punctuation, unidecoded, and in lowercase.
5852-
@lru_cache(maxsize=None)
5852+
@lru_cache(maxsize=3500)
58535853
def parse_words(user_string):
58545854
words = []
58555855
if user_string:
@@ -5869,7 +5869,7 @@ def parse_words(user_string):
58695869

58705870

58715871
# Finds a number of consecutive items in both arrays, or returns False if none are found.
5872-
@lru_cache(maxsize=None)
5872+
@lru_cache(maxsize=3500)
58735873
def find_consecutive_items(arr1, arr2, count=3):
58745874
if len(arr1) < count or len(arr2) < count:
58755875
return False
@@ -7415,7 +7415,7 @@ def isint(x):
74157415

74167416

74177417
# check if zip file contains ComicInfo.xml
7418-
@lru_cache(maxsize=None)
7418+
@lru_cache(maxsize=3500)
74197419
def contains_comic_info(zip_file):
74207420
result = False
74217421
try:
@@ -8436,7 +8436,7 @@ def is_blank_image(image_data):
84368436

84378437

84388438
# Returns the highest volume number and volume part number of a release in a list of volume releases
8439-
@lru_cache(maxsize=None)
8439+
@lru_cache(maxsize=3500)
84408440
def get_highest_release(releases, is_chapter_directory=False):
84418441
highest_num = ""
84428442

@@ -9450,7 +9450,7 @@ def get_subtitle_from_dash(title, replace=False):
94509450
# Extracts the subtitle from a file.name
94519451
# (year required in brackets at the end of the subtitle)
94529452
# EX: Sword Art Online v13 - Alicization Dividing [2018].epub -> Alicization Dividing
9453-
@lru_cache(maxsize=None)
9453+
@lru_cache(maxsize=3500)
94549454
def get_subtitle_from_title(file, publisher=None):
94559455
subtitle = ""
94569456

@@ -10853,7 +10853,7 @@ def has_one_set_of_numbers(string, chapter=False, file=None, subtitle=None):
1085310853

1085410854

1085510855
# Check if there is more than one set of numbers in the string
10856-
@lru_cache(maxsize=None)
10856+
@lru_cache(maxsize=3500)
1085710857
def has_multiple_numbers(file_name):
1085810858
return len(re.findall(r"\d+\.0+[1-9]+|\d+\.[1-9]+|\d+", file_name)) > 1
1085910859

@@ -10952,7 +10952,7 @@ def prep_images_for_similarity(
1095210952
blank_image_path, internal_cover_data, both_cover_data=False, silent=False
1095310953
):
1095410954

10955-
def resize_images(img1, img2, desired_width=600, desired_height=400):
10955+
def resize_images(img1, img2, desired_width=400, desired_height=600):
1095610956
img1_resized = cv2.resize(
1095710957
img1, (desired_width, desired_height), interpolation=cv2.INTER_AREA
1095810958
)
@@ -11414,7 +11414,7 @@ def correct_file_extensions():
1141411414
print("\t\t\tSkipped")
1141511415

1141611416

11417-
# Checks existing series within existing libraries to see if their type matche sthe library they're in
11417+
# Checks existing series within existing libraries to see if their type matches the library they're in
1141811418
# If not, it moves the series to the appropriate library
1141911419
def move_series_to_correct_library(paths_to_search=paths_with_types):
1142011420
global grouped_notifications
@@ -11435,6 +11435,7 @@ def move_series_to_correct_library(paths_to_search=paths_with_types):
1143511435
print(f"\nSearching {p.path} for incorrectly matching series types...")
1143611436
for root, dirs, files in scandir.walk(p.path):
1143711437
print(f"\t{root}")
11438+
1143811439
files, dirs = process_files_and_folders(
1143911440
root,
1144011441
files,

0 commit comments

Comments
 (0)