From f53d019c043cff366c11bde5dafe265c328abcc1 Mon Sep 17 00:00:00 2001 From: Ing Date: Sat, 18 Jan 2025 11:52:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20getmodels=20=E5=87=BD?= =?UTF-8?q?=E6=95=B0=E4=BD=BF=E7=94=A8=E7=9A=84=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/func.py | 57 +++++++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 25 deletions(-) diff --git a/scripts/func.py b/scripts/func.py index 0858b4fd..c4911822 100644 --- a/scripts/func.py +++ b/scripts/func.py @@ -6,7 +6,7 @@ # See /LICENSE for more information. # -import os, sys, glob, json, yaml, click, shutil, tarfile, kmodule, requests, urllib3 +import os, re, sys, glob, json, yaml, click, shutil, tarfile, kmodule, requests, urllib3 from requests.adapters import HTTPAdapter from requests.packages.urllib3.util.retry import Retry # type: ignore from openpyxl import Workbook @@ -44,24 +44,28 @@ def getmodels(workpath, jsonpath, xlsxpath): urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) try: - req = session.get("https://autoupdate.synology.com/os/v2", timeout=10, verify=False) + url = "http://update7.synology.com/autoupdate/genRSS.php?include_beta=1" + #url = "https://update7.synology.com/autoupdate/genRSS.php?include_beta=1" + + req = session.get(url, timeout=10, verify=False) req.encoding = "utf-8" - data = json.loads(req.text) + p = re.compile(r"(.*?).*?(.*?)", re.MULTILINE | re.DOTALL) + + data = p.findall(req.text) except Exception as e: click.echo(f"Error: {e}") return - for item in data["channel"]["item"]: - if not item["title"].startswith("DSM"): + for item in data: + if not "DSM" in item[1]: continue - for model in item["model"]: - arch = model["mUnique"].split("_")[1].lower() - name = model["mLink"].split("/")[-1].split("_")[1].replace("%2B", "+") - if arch not in models: - continue - if name in (A for B in models for A in models[B]["models"]): - continue - models[arch]["models"].append(name) + arch = item[0].split("_")[1] + name = item[1].split("/")[-1].split("_")[1].replace("%2B", "+") + if arch not in models: + continue + if name in (A for B in models for A in models[B]["models"]): + continue + models[arch]["models"].append(name) if jsonpath: with open(jsonpath, "w") as f: @@ -99,25 +103,28 @@ def getpats(workpath, jsonpath, xlsxpath): urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) try: - req = session.get("https://autoupdate.synology.com/os/v2", timeout=10, verify=False) + url = "http://update7.synology.com/autoupdate/genRSS.php?include_beta=1" + #url = "https://update7.synology.com/autoupdate/genRSS.php?include_beta=1" + + req = session.get(url, timeout=10, verify=False) req.encoding = "utf-8" - data = json.loads(req.text) + p = re.compile(r"(.*?).*?(.*?)", re.MULTILINE | re.DOTALL) + data = p.findall(req.text) except Exception as e: click.echo(f"Error: {e}") return models = [] - for item in data["channel"]["item"]: - if not item["title"].startswith("DSM"): + for item in data: + if not "DSM" in item[1]: continue - for model in item["model"]: - arch = model["mUnique"].split("_")[1].lower() - name = model["mLink"].split("/")[-1].split("_")[1].replace("%2B", "+") - if arch not in platforms: - continue - if name in models: - continue - models.append(name) + arch = item[0].split("_")[1] + name = item[1].split("/")[-1].split("_")[1].replace("%2B", "+") + if arch not in platforms: + continue + if name in models: + continue + models.append(name) pats = {} for M in models: