Skip to content

Commit

Permalink
Account for updated fichub-api package.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sachaa-Thanasius committed Nov 4, 2023
1 parent bb24f71 commit f84d28d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
16 changes: 5 additions & 11 deletions exts/ff_metadata/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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."

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f84d28d

Please sign in to comment.