From f84d28dcfc828979c7adee2a8959561f6596f2fa Mon Sep 17 00:00:00 2001 From: Thanos <111999343+Sachaa-Thanasius@users.noreply.github.com> Date: Fri, 3 Nov 2023 23:45:59 -0400 Subject: [PATCH] Account for updated fichub-api package. --- exts/ff_metadata/utils.py | 16 +++++----------- requirements.txt | 2 +- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/exts/ff_metadata/utils.py b/exts/ff_metadata/utils.py index 51eec08..2b9a534 100644 --- a/exts/ff_metadata/utils.py +++ b/exts/ff_metadata/utils.py @@ -180,7 +180,7 @@ def create_fichub_embed(story: fichub_api.Story) -> discord.Embed: # Format the relevant information. updated = story.updated.strftime("%B %d, %Y") fandoms = textwrap.shorten(", ".join(story.fandoms), 100, placeholder="...") - categories_list = story.more_meta.get("category", []) + categories_list = story.tags.category if isinstance(story, fichub_api.AO3Story) else () categories = textwrap.shorten(", ".join(categories_list), 100, placeholder="...") characters = textwrap.shorten(", ".join(story.characters), 100, placeholder="...") details = " • ".join((fandoms, categories, characters)) @@ -191,18 +191,12 @@ def create_fichub_embed(story: fichub_api.Story) -> discord.Embed: None, ) - if "fanfiction.net" in story.url: + if isinstance(story, fichub_api.FFNStory): stats_names = ("reviews", "favorites", "follows") - stats_str = " • ".join(f"**{name.capitalize()}:** {story.stats[name]:,d}" for name in stats_names) - elif "archiveofourown.org" in story.url: + stats_str = " • ".join(f"**{name.capitalize()}:** {getattr(story.stats, name):,d}" for name in stats_names) + elif isinstance(story, fichub_api.AO3Story): stats_names = ("comments", "kudos", "bookmarks", "hits") - # Account for absent extended metadata. - stats = ( - f"**{stat_name.capitalize()}:** {ind_stat:,d}" - for stat_name in stats_names - if (ind_stat := story.stats.get(stat_name)) is not None - ) - stats_str = " • ".join(stats) + stats_str = " • ".join(f"**{name.capitalize()}:** {getattr(story.stats, name):,d}" for name in stats_names) else: stats_str = "No stats available at this time." diff --git a/requirements.txt b/requirements.txt index 886fd86..3dd39d0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,7 +6,7 @@ asyncpg-stubs==0.28.0 atlas-api @ git+https://github.com/Sachaa-Thanasius/atlas-api-wrapper.git beautifulsoup4>=4.12.2 discord.py[speed,voice]>=2.3.2 -fichub-api @ git+https://github.com/Sachaa-Thanasius/fichub-api-wrapper.git +fichub-api jishaku @ git+https://github.com/Gorialis/jishaku@bf26bea3c1f86993fd75744de48bf52d4925521a lxml>=4.9.3 matplotlib