From 068937803e471a71caf0963466d3b8c22f775453 Mon Sep 17 00:00:00 2001 From: Anon Date: Tue, 30 Aug 2022 22:31:41 -0700 Subject: [PATCH] Change function parameter names. Updated dictionary keys to match backend return value --- src/yandere_bot.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/yandere_bot.py b/src/yandere_bot.py index dd13e29..83db957 100644 --- a/src/yandere_bot.py +++ b/src/yandere_bot.py @@ -19,7 +19,6 @@ import os import datetime import contextlib -import fnmatch import math import shutil import importlib @@ -122,14 +121,14 @@ class YandereBot: # Maybe I should remove this from the backend? def print_header_stats(self, picked, date_selection, date_next_selection): - picked_name = picked["name"] if picked else None + picked_name = picked["profile"]["name"] if picked else None picked_url = picked["file_url"] if picked else None picked_path = picked["full_path"] if picked else None picked_nsfw = picked["nsfw"] if picked else None + picked_index = (self.currentIndexCount % len(self.settings_post)) - 1 next_selection_seconds = max(0, int(time_diff_seconds(date_next_selection, date_selection))) - print("[Profile]", picked_name) - print(picked_path) + print("[Profile]", picked_name, "[Index]", picked_index) print(picked_url) print("Explicit:", picked_nsfw) print("Selection time: {}".format( @@ -142,23 +141,23 @@ class YandereBot: # Returns a list of media paths (without the hashes) - def download_media(self, picked): + def download_media(self, picked_profile): try: - backend_s = picked["backend"] + backend_s = picked_profile["backend"] backend = importlib.import_module(backend_s) username = self.settings_credentials[backend_s]["username"] password = self.settings_credentials[backend_s]["password"] img = None downloader = backend.downloader(username, password, tmp=self.settings_behavior["tmp_dir"]) - img = downloader.fetch_post(picked) + img = downloader.fetch_post(picked_profile) if img is None: raise InvalidPost("Img could not be downloaded") return downloader.download_post(img) except ImportError: - print("Invalid Backend:", picked["backend"]) + print("Invalid Backend:", picked_profile["backend"]) return None # Returns a list of tuples that contain the media list path and media mastodon dictionary @@ -172,7 +171,7 @@ class YandereBot: content_type = self.settings_behavior["content_type"] content_newline = self.settings_behavior["content_newline"] nsfw = picked["nsfw"] - message = picked["message_nsfw"] if nsfw else picked["message"] + message = picked["profile"]["message_nsfw"] if nsfw else picked["profile"]["message"] static_message = content_newline.join(message) string_post = "" string_imglinks = []