Skip to content

Commit

Permalink
Metadata Fix
Browse files Browse the repository at this point in the history
cba to explain lmao
  • Loading branch information
UltimaHoarder committed Nov 23, 2020
1 parent f24c063 commit 7600a80
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 35 deletions.
5 changes: 5 additions & 0 deletions extras/OFRenamer/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions helpers/main_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down Expand Up @@ -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):
Expand Down
48 changes: 15 additions & 33 deletions modules/onlyfans.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)]
Expand Down

0 comments on commit 7600a80

Please sign in to comment.