From b8c8983de8e77f4a428c8e28226fc3ea906c0713 Mon Sep 17 00:00:00 2001 From: Nikhil Badyal Date: Sun, 6 Aug 2023 21:04:14 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20use=20scripts=20to=20extract=20i?= =?UTF-8?q?cons?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- requirements.txt | 1 + scripts/status_check.py | 27 +++++++++++++++------------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/requirements.txt b/requirements.txt index 3b84c02..6bd9596 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,6 @@ beautifulsoup4==4.12.2 environs==9.5.0 +google-play-scraper==1.2.4 lastversion==3.0.1 loguru==0.7.0 pre-commit==3.3.3 diff --git a/scripts/status_check.py b/scripts/status_check.py index d77e198..25ae44b 100644 --- a/scripts/status_check.py +++ b/scripts/status_check.py @@ -2,7 +2,7 @@ from typing import List import requests -from bs4 import BeautifulSoup +from google_play_scraper import app as gplay_app from src.patches import Patches from src.utils import handle_response @@ -14,13 +14,12 @@ def gplay_icon_scrapper(package_name: str) -> str: """Scrap Icon from Gplay.""" # noinspection PyBroadException try: - app_url = ( - f"https://play.google.com/store/apps/details?id={package_name}&hl=en&gl=US" + result = gplay_app( + package_name, ) - response = requests.get(app_url) - soup = BeautifulSoup(response.text, "html.parser") - icon = soup.select_one("div.Il7kR > img") - return str(icon["srcset"].split(" ")[0]) + if not result["icon"]: + raise ValueError() + return str(result["icon"]) except Exception: return not_found_icon @@ -30,14 +29,16 @@ def generate_markdown_table(data: List[List[str]]) -> str: if len(data) == 0: return "No data to generate table." - table = "| Package Name | PlayStore link | APKMirror link| Supported ?|\n" - table += "|-------------|----------------|---------------|------------|\n" + table = "| Package Name | App Icon | PlayStore link | APKMirror link| Supported?|\n" + table += ( + "|-------------|----------|----------------|---------------|------------|\n" + ) for row in data: - if len(row) != 3: + if len(row) != 5: raise ValueError("Each row must contain 4 columns of data.") - table += f"| {row[0]} | {row[1]} | {row[2]} |
  • - [ ]
  • |\n" + table += f"| {row[0]} | {row[1]} | {row[2]} | {row[3]} |{row[4]} |\n" return table @@ -57,14 +58,16 @@ def main() -> None: supported_app = set(Patches.support_app().keys()) missing_support = possible_apps.difference(supported_app) - output = "New app found which aren't supported yet.\n\n" + output = "New app found which aren't supported or outdated.\n\n" data = [] for index, app in enumerate(missing_support): data.append( [ + app, f'', f"[PlayStore Link](https://play.google.com/store/apps/details?id={app})", f"[APKMirror Link](https://www.apkmirror.com/?s={app})", + "
  • - [ ]
  • ", ] ) table = generate_markdown_table(data)