Compare commits

..

2 Commits

Author SHA1 Message Date
Stijn De Clercq f181a7a833
Merge pull request #180 from stijndcl/fix/free-games
Fix free games
2023-12-25 23:04:30 +01:00
stijndcl dc4ee08b63 Fix free games 2023-12-25 23:00:48 +01:00
3 changed files with 9 additions and 10 deletions

1
.tool-versions 100644
View File

@ -0,0 +1 @@
python 3.9.5

View File

@ -15,7 +15,7 @@ from didier.utils.types.string import abbreviate
__all__ = ["SEPARATOR", "FreeGameEmbed"]
SEPARATOR = " • Free • "
SEPARATOR = " is free to claim at "
def _get_store_info(store: str) -> tuple[Optional[str], discord.Colour]:
@ -48,7 +48,7 @@ def _get_store_info(store: str) -> tuple[Optional[str], discord.Colour]:
class FreeGameEmbed(EmbedPydantic):
"""Embed for free games"""
dc_identifier: int
id: int
link: str
title: str
@ -103,15 +103,13 @@ class FreeGameEmbed(EmbedPydantic):
inline=False,
)
embed.add_field(name="Open in browser", value=f"[{self.link}]({self.link})")
embed.add_field(name="Open in browser", value=self.link)
if self.store_page.xdg_open_url is not None:
embed.add_field(
name="Open in app", value=f"[{self.store_page.xdg_open_url}]({self.store_page.xdg_open_url})"
)
embed.add_field(name="Open in app", value=self.store_page.xdg_open_url)
else:
embed.title = self.name
embed.add_field(name="Open in browser", value=f"[{self.link}]({self.link})")
embed.add_field(name="Open in browser", value=self.link)
embed.url = self.link

View File

@ -16,7 +16,7 @@ __all__ = ["fetch_free_games"]
async def fetch_free_games(http_session: ClientSession, database_session: AsyncSession) -> list[FreeGameEmbed]:
"""Get a fresh list of free games"""
url = "https://pepeizqdeals.com/?call_custom_simple_rss=1&csrp_cat=12"
url = "https://pepeizqdeals.com/rss-en.xml"
async with http_session.get(url) as response:
if response.status != HTTPStatus.OK:
logger.error("Free games GET-request failed with status code %d." % response.status)
@ -34,7 +34,7 @@ async def fetch_free_games(http_session: ClientSession, database_session: AsyncS
game = FreeGameEmbed.model_validate(entry)
games.append(game)
game_ids.append(game.dc_identifier)
game_ids.append(game.id)
# Filter out games that we already know
filtered_ids = await filter_present_games(database_session, game_ids)
@ -42,7 +42,7 @@ async def fetch_free_games(http_session: ClientSession, database_session: AsyncS
# Insert new games into the database
await add_free_games(database_session, filtered_ids)
games = list(filter(lambda x: x.dc_identifier in filtered_ids, games))
games = list(filter(lambda x: x.id in filtered_ids, games))
# Look up additional info
for game in games: