mirror of https://github.com/stijndcl/didier
Compare commits
No commits in common. "f181a7a8331d909a656b4d40849309f1d6e1d282" and "17b6ebac898aee0d6fbe1deed2a07deb5e36ada0" have entirely different histories.
f181a7a833
...
17b6ebac89
|
@ -1 +0,0 @@
|
||||||
python 3.9.5
|
|
|
@ -15,7 +15,7 @@ from didier.utils.types.string import abbreviate
|
||||||
|
|
||||||
__all__ = ["SEPARATOR", "FreeGameEmbed"]
|
__all__ = ["SEPARATOR", "FreeGameEmbed"]
|
||||||
|
|
||||||
SEPARATOR = " is free to claim at "
|
SEPARATOR = " • Free • "
|
||||||
|
|
||||||
|
|
||||||
def _get_store_info(store: str) -> tuple[Optional[str], discord.Colour]:
|
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):
|
class FreeGameEmbed(EmbedPydantic):
|
||||||
"""Embed for free games"""
|
"""Embed for free games"""
|
||||||
|
|
||||||
id: int
|
dc_identifier: int
|
||||||
link: str
|
link: str
|
||||||
title: str
|
title: str
|
||||||
|
|
||||||
|
@ -103,13 +103,15 @@ class FreeGameEmbed(EmbedPydantic):
|
||||||
inline=False,
|
inline=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
embed.add_field(name="Open in browser", value=self.link)
|
embed.add_field(name="Open in browser", value=f"[{self.link}]({self.link})")
|
||||||
|
|
||||||
if self.store_page.xdg_open_url is not None:
|
if self.store_page.xdg_open_url is not None:
|
||||||
embed.add_field(name="Open in app", value=self.store_page.xdg_open_url)
|
embed.add_field(
|
||||||
|
name="Open in app", value=f"[{self.store_page.xdg_open_url}]({self.store_page.xdg_open_url})"
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
embed.title = self.name
|
embed.title = self.name
|
||||||
embed.add_field(name="Open in browser", value=self.link)
|
embed.add_field(name="Open in browser", value=f"[{self.link}]({self.link})")
|
||||||
|
|
||||||
embed.url = self.link
|
embed.url = self.link
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ __all__ = ["fetch_free_games"]
|
||||||
|
|
||||||
async def fetch_free_games(http_session: ClientSession, database_session: AsyncSession) -> list[FreeGameEmbed]:
|
async def fetch_free_games(http_session: ClientSession, database_session: AsyncSession) -> list[FreeGameEmbed]:
|
||||||
"""Get a fresh list of free games"""
|
"""Get a fresh list of free games"""
|
||||||
url = "https://pepeizqdeals.com/rss-en.xml"
|
url = "https://pepeizqdeals.com/?call_custom_simple_rss=1&csrp_cat=12"
|
||||||
async with http_session.get(url) as response:
|
async with http_session.get(url) as response:
|
||||||
if response.status != HTTPStatus.OK:
|
if response.status != HTTPStatus.OK:
|
||||||
logger.error("Free games GET-request failed with status code %d." % response.status)
|
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)
|
game = FreeGameEmbed.model_validate(entry)
|
||||||
games.append(game)
|
games.append(game)
|
||||||
game_ids.append(game.id)
|
game_ids.append(game.dc_identifier)
|
||||||
|
|
||||||
# Filter out games that we already know
|
# Filter out games that we already know
|
||||||
filtered_ids = await filter_present_games(database_session, game_ids)
|
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
|
# Insert new games into the database
|
||||||
await add_free_games(database_session, filtered_ids)
|
await add_free_games(database_session, filtered_ids)
|
||||||
|
|
||||||
games = list(filter(lambda x: x.id in filtered_ids, games))
|
games = list(filter(lambda x: x.dc_identifier in filtered_ids, games))
|
||||||
|
|
||||||
# Look up additional info
|
# Look up additional info
|
||||||
for game in games:
|
for game in games:
|
||||||
|
|
Loading…
Reference in New Issue