fixed major issues, rename func fixed?

This commit is contained in:
faroukbmiled 2023-09-24 19:33:49 +01:00
parent 9b7560fb14
commit 31c7d4a151
4 changed files with 29 additions and 44 deletions

View File

@ -1,31 +0,0 @@
<div class="rightDetailsBlock">
<div class="detailsStatsContainerLeft">
<div class="detailsStatLeft">File Size </div>
<div class="detailsStatLeft">Posted </div>
<div class="detailsStatLeft">Updated </div>
</div>
<div class="detailsStatsContainerRight">
<div class="detailsStatRight">0.041 MB</div>
<div class="detailsStatRight">30 Sep, 2016 @ 1:03pm</div>
<div class="detailsStatRight">1 Oct, 2016 @ 12:19pm</div>
</div>
<div style="clear:left"></div>
<div class="detailsStatNumChangeNotes">
3 Change Notes <span class="change_note_link"><a
href="https://steamcommunity.com/sharedfiles/filedetails/changelog/772261373">( view )</a></span>
</div>
</div>
<div class="rightDetailsBlock">
<a
href="https://steamcommunity.com/workshop/browse/?appid=311210&amp;browsesort=toprated&amp;section=readytouseitems&amp;requiredtags%5B%5D=Map">Map</a>,
<a
href="https://steamcommunity.com/workshop/browse/?appid=311210&amp;browsesort=toprated&amp;section=readytouseitems&amp;requiredtags%5B%5D=Mod">Mod</a>,
<a
href="https://steamcommunity.com/workshop/browse/?appid=311210&amp;browsesort=toprated&amp;section=readytouseitems&amp;requiredtags%5B%5D=Zombies">Zombies</a>
</div>

View File

@ -98,6 +98,9 @@ class LibraryTab(ctk.CTkScrollableFrame):
with open(items_file, "r") as f: with open(items_file, "r") as f:
items_data = json.load(f) items_data = json.load(f)
for item_info in items_data: for item_info in items_data:
if not folder_name and "id" in item_info and item_info["id"] == workshop_id:
return True, False
if "id" in item_info and "folder_name" in item_info and "json_folder_name" in item_info: if "id" in item_info and "folder_name" in item_info and "json_folder_name" in item_info:
if item_info["id"] == workshop_id and item_info["folder_name"] == folder_name: if item_info["id"] == workshop_id and item_info["folder_name"] == folder_name:
if item_info["folder_name"] in self.added_folders: if item_info["folder_name"] in self.added_folders:
@ -178,7 +181,8 @@ class LibraryTab(ctk.CTkScrollableFrame):
items_data = json.load(f) items_data = json.load(f)
cleaned_items = [item for item in items_data if 'folder_name' in item and 'json_folder_name' cleaned_items = [item for item in items_data if 'folder_name' in item and 'json_folder_name'
in item and item['folder_name'] not in self.item_block_list and item['folder_name'] in self.added_folders] in item and item['folder_name'] not in self.item_block_list and item['folder_name']
in self.added_folders and item['id'] in self.ids_added]
with open(file, 'w') as file: with open(file, 'w') as file:
json.dump(cleaned_items, file, indent=4) json.dump(cleaned_items, file, indent=4)
@ -221,6 +225,7 @@ class LibraryTab(ctk.CTkScrollableFrame):
if self.refresh_next_time and not dont_add: if self.refresh_next_time and not dont_add:
self.refresh_next_time = False self.refresh_next_time = False
self.refresh_items() self.refresh_items()
return
if dont_add: if dont_add:
self.label_list.clear() self.label_list.clear()

View File

@ -1247,9 +1247,9 @@ class BOIIIWD(ctk.CTk):
self.label_speed.configure(text="Installing...") self.label_speed.configure(text="Installing...")
mod_type = extract_json_data(json_file_path, "Type") mod_type = extract_json_data(json_file_path, "Type")
items_file = os.path.join(application_path, LIBRARY_FILE) items_file = os.path.join(application_path, LIBRARY_FILE)
item_exixsts = self.library_tab.item_exists_in_file(items_file, workshop_id) item_exists,_ = self.library_tab.item_exists_in_file(items_file, workshop_id)
if item_exixsts: if item_exists:
get_folder_name = self.library_tab.get_item_by_id(items_file, workshop_id, return_option="folder_name") get_folder_name = self.library_tab.get_item_by_id(items_file, workshop_id, return_option="folder_name")
if get_folder_name: if get_folder_name:
folder_name = get_folder_name folder_name = get_folder_name
@ -1274,7 +1274,7 @@ class BOIIIWD(ctk.CTk):
show_message("Error", f"Invalid workshop type in workshop.json, are you sure this is a map or a mod?., skipping {workshop_id}...", icon="cancel") show_message("Error", f"Invalid workshop type in workshop.json, are you sure this is a map or a mod?., skipping {workshop_id}...", icon="cancel")
return return
if not item_exixsts: if not item_exists:
while os.path.exists(os.path.join(path_folder, folder_name)): while os.path.exists(os.path.join(path_folder, folder_name)):
folder_name += f"_{workshop_id}" folder_name += f"_{workshop_id}"
folder_name_path = os.path.join(path_folder, folder_name, "zone") folder_name_path = os.path.join(path_folder, folder_name, "zone")
@ -1513,9 +1513,9 @@ class BOIIIWD(ctk.CTk):
self.label_speed.configure(text="Installing...") self.label_speed.configure(text="Installing...")
mod_type = extract_json_data(json_file_path, "Type") mod_type = extract_json_data(json_file_path, "Type")
items_file = os.path.join(application_path, LIBRARY_FILE) items_file = os.path.join(application_path, LIBRARY_FILE)
item_exixsts = self.library_tab.item_exists_in_file(items_file, workshop_id) item_exists,_ = self.library_tab.item_exists_in_file(items_file, workshop_id)
if item_exixsts: if item_exists:
get_folder_name = self.library_tab.get_item_by_id(items_file, workshop_id, return_option="folder_name") get_folder_name = self.library_tab.get_item_by_id(items_file, workshop_id, return_option="folder_name")
if get_folder_name: if get_folder_name:
folder_name = get_folder_name folder_name = get_folder_name
@ -1541,7 +1541,7 @@ class BOIIIWD(ctk.CTk):
self.stop_download() self.stop_download()
return return
if not item_exixsts: if not item_exists:
while os.path.exists(os.path.join(path_folder, folder_name)): while os.path.exists(os.path.join(path_folder, folder_name)):
folder_name += f"_{workshop_id}" folder_name += f"_{workshop_id}"
folder_name_path = os.path.join(path_folder, folder_name, "zone") folder_name_path = os.path.join(path_folder, folder_name, "zone")

View File

@ -1,3 +1,4 @@
from src import library_tab
from src.update_window import check_for_updates_func from src.update_window import check_for_updates_func
from src.imports import * from src.imports import *
from src.helpers import * from src.helpers import *
@ -410,6 +411,7 @@ class SettingsTab(ctk.CTkFrame):
return 0 return 0
processed_names = set() processed_names = set()
for folder_path in folders_to_process: for folder_path in folders_to_process:
for folder_name in os.listdir(folder_path): for folder_name in os.listdir(folder_path):
zone_path = os.path.join(folder_path, folder_name, "zone") zone_path = os.path.join(folder_path, folder_name, "zone")
@ -419,22 +421,31 @@ class SettingsTab(ctk.CTkFrame):
continue continue
json_path = os.path.join(zone_path, "workshop.json") json_path = os.path.join(zone_path, "workshop.json")
publisher_id = extract_json_data(json_path, 'PublisherID')
new_name = extract_json_data(json_path, option) new_name = extract_json_data(json_path, option)
if folder_name == new_name: if folder_name == new_name:
continue continue
rename_flag = True
if os.path.exists(json_path): if os.path.exists(json_path):
publisher_id = extract_json_data(json_path, 'PublisherID')
folder_to_rename = os.path.join(folder_path, folder_name) folder_to_rename = os.path.join(folder_path, folder_name)
new_folder_name = new_name new_folder_name = new_name
while new_folder_name in processed_names: while new_folder_name in processed_names:
new_folder_name += f"_{publisher_id}" new_folder_name += f"_{publisher_id}"
if folder_name == new_folder_name:
rename_flag = False
break
new_path = os.path.join(folder_path, new_folder_name) new_path = os.path.join(folder_path, new_folder_name)
while os.path.exists(new_path): while os.path.exists(new_path):
new_folder_name += f"_{publisher_id}" new_folder_name += f"_{publisher_id}"
if folder_name == new_folder_name:
rename_flag = False
break
new_path = os.path.join(folder_path, new_folder_name) new_path = os.path.join(folder_path, new_folder_name)
if rename_flag:
os.rename(folder_to_rename, new_path) os.rename(folder_to_rename, new_path)
processed_names.add(new_folder_name) processed_names.add(new_folder_name)
@ -619,9 +630,9 @@ class SettingsTab(ctk.CTkFrame):
workshop_id = extract_json_data(json_file_path, "PublisherID") workshop_id = extract_json_data(json_file_path, "PublisherID")
mod_type = extract_json_data(json_file_path, "Type") mod_type = extract_json_data(json_file_path, "Type")
items_file = os.path.join(application_path, LIBRARY_FILE) items_file = os.path.join(application_path, LIBRARY_FILE)
item_exixsts = main_app.app.library_tab.item_exists_in_file(items_file, workshop_id) item_exists,_ = main_app.app.library_tab.item_exists_in_file(items_file, workshop_id)
if item_exixsts: if item_exists:
get_folder_name = main_app.app.library_tab.get_item_by_id(items_file, workshop_id, return_option="folder_name") get_folder_name = main_app.app.library_tab.get_item_by_id(items_file, workshop_id, return_option="folder_name")
if get_folder_name: if get_folder_name:
folder_name = get_folder_name folder_name = get_folder_name
@ -646,7 +657,7 @@ class SettingsTab(ctk.CTkFrame):
show_message("Error", "Invalid workshop type in workshop.json, are you sure this is a map or a mod?.", icon="cancel") show_message("Error", "Invalid workshop type in workshop.json, are you sure this is a map or a mod?.", icon="cancel")
continue continue
if not item_exixsts: if not item_exists:
while os.path.exists(os.path.join(path_folder, folder_name)): while os.path.exists(os.path.join(path_folder, folder_name)):
folder_name += f"_{workshop_id}" folder_name += f"_{workshop_id}"
folder_name_path = os.path.join(path_folder, folder_name, "zone") folder_name_path = os.path.join(path_folder, folder_name, "zone")