mirror of https://github.com/stijndcl/didier
Add a few TODO's and fix small bug
parent
855f60727b
commit
5c0ebb7eeb
|
@ -102,8 +102,9 @@ class FreeGameEmbed(EmbedPydantic):
|
||||||
inline=False,
|
inline=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
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 browser", value=f"[{self.link}]({self.link})")
|
|
||||||
|
|
||||||
embed.add_field(
|
embed.add_field(
|
||||||
name="Open in app", value=f"[{self.store_page.xdg_open_url}]({self.store_page.xdg_open_url})"
|
name="Open in app", value=f"[{self.store_page.xdg_open_url}]({self.store_page.xdg_open_url})"
|
||||||
|
|
|
@ -6,6 +6,7 @@ from bs4 import BeautifulSoup, Tag
|
||||||
__all__ = ["GameStorePage", "parse_open_graph_tags"]
|
__all__ = ["GameStorePage", "parse_open_graph_tags"]
|
||||||
|
|
||||||
|
|
||||||
|
# TODO make this an ABC that all other store pages implement instead
|
||||||
@dataclass
|
@dataclass
|
||||||
class GameStorePage:
|
class GameStorePage:
|
||||||
"""Dataclass for information on a game's store page"""
|
"""Dataclass for information on a game's store page"""
|
||||||
|
@ -15,7 +16,7 @@ class GameStorePage:
|
||||||
title: str
|
title: str
|
||||||
xdg_open_url: Optional[str] = None
|
xdg_open_url: Optional[str] = None
|
||||||
url: Optional[str] = None
|
url: Optional[str] = None
|
||||||
discount_expiry: Optional[int] = None
|
discount_expiry: Optional[int] = None # TODO
|
||||||
discounted_price: Optional[str] = None
|
discounted_price: Optional[str] = None
|
||||||
original_price: Optional[str] = None
|
original_price: Optional[str] = None
|
||||||
discount_percentage: Optional[str] = None
|
discount_percentage: Optional[str] = None
|
||||||
|
|
|
@ -32,15 +32,15 @@ def _shorten_url(url: str) -> str:
|
||||||
if match is None or not match.groups():
|
if match is None or not match.groups():
|
||||||
return url
|
return url
|
||||||
|
|
||||||
return f"https://s.team/a/{match.groups()[0]}/"
|
return f"https://s.team/a/{match.groups()[0]}"
|
||||||
|
|
||||||
|
|
||||||
def _parse_xdg_open_url(url: str) -> Optional[str]:
|
def _parse_xdg_open_url(url: str) -> Optional[str]:
|
||||||
match = re.search(r"/app/(\d+)/", url)
|
match = re.search(r"/app/(\d+)/", url)
|
||||||
if match is None or match.group() is None:
|
if match is None or not match.groups():
|
||||||
return None
|
return None
|
||||||
|
|
||||||
return f"steam://store/{match.group()}"
|
return f"steam://store/{match.groups()[0]}"
|
||||||
|
|
||||||
|
|
||||||
def _get_steam_discounts(soup: BeautifulSoup) -> Optional[_PriceInfo]:
|
def _get_steam_discounts(soup: BeautifulSoup) -> Optional[_PriceInfo]:
|
||||||
|
@ -110,8 +110,8 @@ async def get_steam_webpage_info(http_session: ClientSession, url: str) -> Optio
|
||||||
page_tags.url = url
|
page_tags.url = url
|
||||||
|
|
||||||
page_tags.title = _clean_title(page_tags.title)
|
page_tags.title = _clean_title(page_tags.title)
|
||||||
page_tags.url = _shorten_url(page_tags.url)
|
|
||||||
page_tags.xdg_open_url = _parse_xdg_open_url(page_tags.url)
|
page_tags.xdg_open_url = _parse_xdg_open_url(page_tags.url)
|
||||||
|
page_tags.url = _shorten_url(page_tags.url)
|
||||||
|
|
||||||
price_info = _get_steam_discounts(soup)
|
price_info = _get_steam_discounts(soup)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue