From 7600a803dca62d14b7e7b82d768cb5cdac122634 Mon Sep 17 00:00:00 2001 From: CRIMINAL Date: Mon, 23 Nov 2020 15:28:59 +0000 Subject: [PATCH] Metadata Fix cba to explain lmao --- extras/OFRenamer/start.py | 5 ++++ helpers/main_helper.py | 4 ++-- modules/onlyfans.py | 48 ++++++++++++--------------------------- 3 files changed, 22 insertions(+), 35 deletions(-) diff --git a/extras/OFRenamer/start.py b/extras/OFRenamer/start.py index ecd5873bd..5ddd86cb6 100644 --- a/extras/OFRenamer/start.py +++ b/extras/OFRenamer/start.py @@ -68,10 +68,15 @@ def fix_metadata(post_item): for posts in post_item: for media in posts: def update(old_filepath, new_filepath): + # if os.path.exists(old_filepath): + # if not media.session: + # media.downloaded = True if old_filepath != new_filepath: if os.path.exists(new_filepath): os.remove(new_filepath) if os.path.exists(old_filepath): + if not media.session: + media.downloaded = True shutil.move(old_filepath, new_filepath) return old_filepath, new_filepath old_filepath = media.old_filepath diff --git a/helpers/main_helper.py b/helpers/main_helper.py index d19ea1f64..2faacfdf4 100644 --- a/helpers/main_helper.py +++ b/helpers/main_helper.py @@ -431,7 +431,7 @@ def choose_option(subscription_list, auto_scrape_names): seperator = " | " print(f"Names: Username = username {seperator} {subscription_list[1]}") if not auto_scrape_names: - value = "1" + value = "andreatv" value = input().strip() if value.isdigit(): if value == "0": @@ -566,7 +566,7 @@ def start(directory): shutil.rmtree(full_path, ignore_errors=True) else: content_count = len(contents) - if content_count ==1 and "desktop.ini" in contents: + if content_count == 1 and "desktop.ini" in contents: shutil.rmtree(full_path, ignore_errors=True) x = start(directory) if os.path.exists(directory): diff --git a/modules/onlyfans.py b/modules/onlyfans.py index 7cd3b318f..7669b7c1c 100644 --- a/modules/onlyfans.py +++ b/modules/onlyfans.py @@ -471,20 +471,19 @@ def compare_message(queue_id, remote_messages): def process_metadata(api, new_metadata, formatted_directories, subscription, api_type, api_path, archive_path, site_name): + legacy_metadata_object = legacy_metadata_fixer( + formatted_directories, api) new_metadata_object = prepare_metadata( new_metadata, api=api).metadata + new_metadata_object = compare_metadata( + new_metadata_object, legacy_metadata_object) old_metadata_set = import_archive(archive_path) old_metadata_object = prepare_metadata( old_metadata_set, api=api).metadata new_metadata_object = compare_metadata( new_metadata_object, old_metadata_object) - legacy_metadata_object = legacy_metadata_fixer( - formatted_directories, api) - if legacy_metadata_object: - new_metadata_object = compare_metadata( - new_metadata_object, legacy_metadata_object) - if not subscription.download_info: - subscription.download_info["metadata_locations"] = {} + if not subscription.download_info: + subscription.download_info["metadata_locations"] = {} subscription.download_info["directory"] = j_directory subscription.download_info["webhook"] = webhook subscription.download_info["metadata_locations"][api_type] = archive_path @@ -651,11 +650,11 @@ def legacy_metadata_fixer(formatted_directories: dict, api: object) -> media_typ new_metadata_set = import_archive( import_path) if new_metadata_set: - new_metadata_object = prepare_metadata( + new_metadata_object2 = prepare_metadata( new_metadata_set, api=api).metadata print old_metadata_object = compare_metadata( - new_metadata_object, old_metadata_object) + new_metadata_object2, old_metadata_object) print q.append(old_metadata_object) print @@ -704,42 +703,25 @@ def compare_metadata(new_metadata: media_types, old_metadata: media_types) -> me new_value2 = getattr(new_value, key2) old_status = list(chain.from_iterable(value2)) new_status = list(chain.from_iterable(new_value2)) + l = False for old_item in old_status: + # if old_item.post_id == 9606680: + # l = True new_found = None new_items = [ x for x in new_status if old_item.post_id == x.post_id] if new_items: for new_item in (x for x in new_items if not new_found): new_found = test(new_item, old_item) - print - print - else: - print if new_found: for key3, v in new_found: if key3 in ["directory", "downloaded", "size", "filename"]: continue setattr(old_item, key3, v) - print - print - else: - print - print - for new_item in new_status: - new_found = None - old_items = [x for x in old_status if x.media_id == - new_item.media_id and x.media_id != None] - if not old_items: - for a in old_status: - new_found = test(new_item, a) - if new_found: - break - if not new_found: - old_status.append(new_item) - print - print - print - print + setattr(new_found, "found", True) + not_found = [ + x for x in new_status if not getattr(x, "found", None)] + old_status += not_found old_status.sort(key=lambda x: x.post_id, reverse=False) lmao = [list(g) for k, g in groupby( old_status, key=lambda x: x.post_id)]