Bump version to 0.9.5; update localization files and refactor file upload logic in Core
All checks were successful
Gitea/kapitanbooru-uploader/pipeline/head This commit looks good
All checks were successful
Gitea/kapitanbooru-uploader/pipeline/head This commit looks good
This commit is contained in:
@@ -35,7 +35,7 @@ class Core:
|
||||
"""
|
||||
|
||||
def __init__(self, settings: Settings, gui_mode: bool = True):
|
||||
self.version = "0.9.4"
|
||||
self.version = "0.9.5"
|
||||
self.acknowledged_version = parse_version(self.version)
|
||||
self.settings = settings
|
||||
self.tags_repo = TagsRepo(settings)
|
||||
@@ -221,7 +221,9 @@ class Core:
|
||||
final_tags.add("meta:auto_upload")
|
||||
return " ".join(sorted(final_tags)), rating
|
||||
|
||||
def get_tagger_results(self, file_path, callback: Callable|None = None) -> wdt.Result:
|
||||
def get_tagger_results(
|
||||
self, file_path, callback: Callable | None = None
|
||||
) -> wdt.Result:
|
||||
md5 = self.image_files_md5[file_path]
|
||||
cached = self.tagger_cache[md5]
|
||||
if cached:
|
||||
@@ -424,24 +426,29 @@ class Core:
|
||||
"""
|
||||
Autotaguje pliki przy użyciu Taggera i wysyła je na serwer.
|
||||
"""
|
||||
for file_path in file_paths:
|
||||
if not os.path.isfile(file_path):
|
||||
print(_("Plik nie istnieje:"), file_path)
|
||||
continue
|
||||
try:
|
||||
tags, rating = self.compute_final_tags_and_rating_for_file(
|
||||
file_path, lambda: None
|
||||
)
|
||||
print(_("Tagi dla pliku"), file_path, ":", tags, "Rating:", rating)
|
||||
self.upload_file(
|
||||
file_path,
|
||||
final_tags=tags,
|
||||
final_rating=rating,
|
||||
progress_queue=None,
|
||||
cancel_event=None,
|
||||
)
|
||||
except Exception as e:
|
||||
print(_("Błąd podczas autotagowania pliku"), file_path, ":", e)
|
||||
self.image_files = file_paths
|
||||
self.total_files = len(self.image_files)
|
||||
self.image_files_md5 = {
|
||||
file: md5
|
||||
for file, md5 in zip(
|
||||
self.image_files, self.compute_md5_parallel(self.image_files)
|
||||
)
|
||||
}
|
||||
self.tagger_processed.clear()
|
||||
for md5 in self.image_files_md5.values():
|
||||
if self.tagger_cache[md5]:
|
||||
self.tagger_processed.add(md5)
|
||||
self.uploaded.clear()
|
||||
self.upload_verified = 0
|
||||
self.uploaded_count = 0
|
||||
for file in self.image_files:
|
||||
self.uploaded[file] = False
|
||||
if not self.image_files:
|
||||
return
|
||||
self.post_load_processing()
|
||||
self.check_uploaded_files_thread.join()
|
||||
self.process_tagger_queue_thread.join()
|
||||
self.upload_all_files()
|
||||
|
||||
def autotag_dir(self, dir):
|
||||
"""
|
||||
@@ -454,12 +461,8 @@ class Core:
|
||||
self.load_images()
|
||||
self.check_uploaded_files_thread.join()
|
||||
self.process_tagger_queue_thread.join()
|
||||
files_to_upload = [x for x in self.image_files if not self.uploaded[x]]
|
||||
if not files_to_upload:
|
||||
print(_("Brak obrazów do przetworzenia w katalogu:"), dir)
|
||||
return
|
||||
|
||||
self.autotag_files(files_to_upload)
|
||||
self.upload_all_files()
|
||||
|
||||
def upload_file(
|
||||
self,
|
||||
|
Reference in New Issue
Block a user