Change function parameter names. Updated dictionary keys to match backend return value
This commit is contained in:
parent
2b77c1360a
commit
068937803e
@ -19,7 +19,6 @@
|
|||||||
import os
|
import os
|
||||||
import datetime
|
import datetime
|
||||||
import contextlib
|
import contextlib
|
||||||
import fnmatch
|
|
||||||
import math
|
import math
|
||||||
import shutil
|
import shutil
|
||||||
import importlib
|
import importlib
|
||||||
@ -122,14 +121,14 @@ class YandereBot:
|
|||||||
|
|
||||||
# Maybe I should remove this from the backend?
|
# Maybe I should remove this from the backend?
|
||||||
def print_header_stats(self, picked, date_selection, date_next_selection):
|
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_url = picked["file_url"] if picked else None
|
||||||
picked_path = picked["full_path"] if picked else None
|
picked_path = picked["full_path"] if picked else None
|
||||||
picked_nsfw = picked["nsfw"] 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)))
|
next_selection_seconds = max(0, int(time_diff_seconds(date_next_selection, date_selection)))
|
||||||
|
|
||||||
print("[Profile]", picked_name)
|
print("[Profile]", picked_name, "[Index]", picked_index)
|
||||||
print(picked_path)
|
|
||||||
print(picked_url)
|
print(picked_url)
|
||||||
print("Explicit:", picked_nsfw)
|
print("Explicit:", picked_nsfw)
|
||||||
print("Selection time: {}".format(
|
print("Selection time: {}".format(
|
||||||
@ -142,23 +141,23 @@ class YandereBot:
|
|||||||
|
|
||||||
|
|
||||||
# Returns a list of media paths (without the hashes)
|
# Returns a list of media paths (without the hashes)
|
||||||
def download_media(self, picked):
|
def download_media(self, picked_profile):
|
||||||
try:
|
try:
|
||||||
backend_s = picked["backend"]
|
backend_s = picked_profile["backend"]
|
||||||
backend = importlib.import_module(backend_s)
|
backend = importlib.import_module(backend_s)
|
||||||
username = self.settings_credentials[backend_s]["username"]
|
username = self.settings_credentials[backend_s]["username"]
|
||||||
password = self.settings_credentials[backend_s]["password"]
|
password = self.settings_credentials[backend_s]["password"]
|
||||||
img = None
|
img = None
|
||||||
downloader = backend.downloader(username, password, tmp=self.settings_behavior["tmp_dir"])
|
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:
|
if img is None:
|
||||||
raise InvalidPost("Img could not be downloaded")
|
raise InvalidPost("Img could not be downloaded")
|
||||||
|
|
||||||
return downloader.download_post(img)
|
return downloader.download_post(img)
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("Invalid Backend:", picked["backend"])
|
print("Invalid Backend:", picked_profile["backend"])
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# Returns a list of tuples that contain the media list path and media mastodon dictionary
|
# 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_type = self.settings_behavior["content_type"]
|
||||||
content_newline = self.settings_behavior["content_newline"]
|
content_newline = self.settings_behavior["content_newline"]
|
||||||
nsfw = picked["nsfw"]
|
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)
|
static_message = content_newline.join(message)
|
||||||
string_post = ""
|
string_post = ""
|
||||||
string_imglinks = []
|
string_imglinks = []
|
||||||
|
Reference in New Issue
Block a user