From 995af058f98c182c28ad9d1fadd03efbdd38e58e Mon Sep 17 00:00:00 2001 From: kurokobo <2920259+kurokobo@users.noreply.github.com> Date: Thu, 8 Jul 2021 15:07:27 +0000 Subject: [PATCH] fix: use package id instead --- README.md | 16 ++++++++-------- helper/app_finder.py | 14 +++----------- modules/msstore.py | 16 ++++------------ 3 files changed, 15 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 456b6b6..62cc5c8 100644 --- a/README.md +++ b/README.md @@ -129,14 +129,14 @@ Get **Platform Name** of the product to track. You can use the helper script in ```bash $ docker-compose run --rm notifier helper/app_finder.py -p msstore -m JP -i 9nblggh2jhxj -KEY App Id Market Name Platform Package Name ------------------------------- ------------ -------- ------------------------ ----------------- ------------------------------------------------------- -9nblggh2jhxj:Windows.Xbox 9nblggh2jhxj JP Minecraft for Windows 10 Windows.Xbox Microsoft.MinecraftUWP_1.16.22101.70_x86__8wekyb3d8bbwe -9nblggh2jhxj:Windows.Universal 9nblggh2jhxj JP Minecraft for Windows 10 Windows.Universal Microsoft.MinecraftUWP_1.16.22101.0_x86__8wekyb3d8bbwe -9nblggh2jhxj:Windows.Universal 9nblggh2jhxj JP Minecraft for Windows 10 Windows.Universal Microsoft.MinecraftUWP_1.16.22101.0_arm__8wekyb3d8bbwe -9nblggh2jhxj:Windows.Xbox 9nblggh2jhxj JP Minecraft for Windows 10 Windows.Xbox Microsoft.MinecraftUWP_1.16.22101.70_arm__8wekyb3d8bbwe -9nblggh2jhxj:Windows.Universal 9nblggh2jhxj JP Minecraft for Windows 10 Windows.Universal Microsoft.MinecraftUWP_1.16.22101.0_x64__8wekyb3d8bbwe -9nblggh2jhxj:Windows.Xbox 9nblggh2jhxj JP Minecraft for Windows 10 Windows.Xbox Microsoft.MinecraftUWP_1.16.22101.70_x64__8wekyb3d8bbwe +KEY App Id Market Name Platform Package Id +------------------------------ ------------ -------- ------------------------ ----------------- ---------------------------------------- +9nblggh2jhxj:Windows.Xbox 9nblggh2jhxj JP Minecraft for Windows 10 Windows.Xbox 845277e2-565d-741e-3c91-a883a873d4be-Arm +9nblggh2jhxj:Windows.Universal 9nblggh2jhxj JP Minecraft for Windows 10 Windows.Universal 6c489be8-f48d-a78b-a405-44633558c5f7-Arm +9nblggh2jhxj:Windows.Xbox 9nblggh2jhxj JP Minecraft for Windows 10 Windows.Xbox 426ccf1b-9364-fc9a-3a9d-f24ab7b493a6-X86 +9nblggh2jhxj:Windows.Universal 9nblggh2jhxj JP Minecraft for Windows 10 Windows.Universal 7ac62c84-44fc-8c53-3f64-549fcbe9c471-X86 +9nblggh2jhxj:Windows.Universal 9nblggh2jhxj JP Minecraft for Windows 10 Windows.Universal 78c121c0-7dc6-29ca-7a71-3298afb37686-X64 +9nblggh2jhxj:Windows.Xbox 9nblggh2jhxj JP Minecraft for Windows 10 Windows.Xbox b0d37c82-091c-c4c5-e702-d7e12aff541d-X64 ``` Keep the value of the `KEY` column (`:`) of the row of the platform you want to track. This value can be used to prepare `.env` file in later steps. diff --git a/helper/app_finder.py b/helper/app_finder.py index c1ceca9..61564a7 100644 --- a/helper/app_finder.py +++ b/helper/app_finder.py @@ -1,5 +1,4 @@ import argparse -import re from gevent import monkey @@ -53,7 +52,7 @@ def gather_msstore(id, market): } _product_info = requests.get(url=_endpoint, headers=_headers, params=_params).json() - _header = ["KEY", "App Id", "Market", "Name", "Platform", "Package Name"] + _header = ["KEY", "App Id", "Market", "Name", "Platform", "Package Id"] _table = [] for _package in _product_info["Products"][0]["DisplaySkuAvailabilities"][0]["Sku"][ "Properties" @@ -62,21 +61,14 @@ def gather_msstore(id, market): "LocalizedProperties" ][0]["SkuTitle"] _platform_dependencies = _package["PlatformDependencies"][0]["PlatformName"] - _package_fullname = "" - if _package["PackageFullName"]: - _package_fullname = _package["PackageFullName"] - elif _package["PackageDownloadUris"]: - _package_fullname = re.sub( - "^.*/", "", _package["PackageDownloadUris"][0]["Uri"] - ) - + _package_id = _package["PackageId"] _row = [ "{}:{}".format(id, _platform_dependencies), id, market, _name, _platform_dependencies, - _package_fullname, + _package_id, ] _table.append(_row) diff --git a/modules/msstore.py b/modules/msstore.py index 58926cf..7fdf7f9 100644 --- a/modules/msstore.py +++ b/modules/msstore.py @@ -1,6 +1,5 @@ import copy import logging -import re from datetime import datetime import ms_cv @@ -82,22 +81,15 @@ def gather_app_info(self): "LocalizedProperties" ][0]["SkuTitle"] - _package_fullname = [] + _package_ids = [] for _package in _current_product["DisplaySkuAvailabilities"][0]["Sku"][ "Properties" ]["Packages"]: if _package["PlatformDependencies"][0]["PlatformName"] == _app.filter: - _fullname = "" - if _package["PackageFullName"]: - _fullname = _package["PackageFullName"] - elif _package["PackageDownloadUris"]: - _fullname = re.sub( - "^.*/", "", _package["PackageDownloadUris"][0]["Uri"] - ) - _package_fullname.append(_fullname) + _package_ids.append(_package["PackageId"]) - _package_fullname.sort() + _package_ids.sort() _last_updated = None if self.old_result and _app.id in self.old_result: @@ -108,7 +100,7 @@ def gather_app_info(self): id=_app.id, name=_name, ), - data=",".join(_package_fullname), + data=",".join(_package_ids), last_checked=self.timestamp, last_updated=_last_updated, )