From 6c0818f71928d69fc00af1b034d7a8970c701721 Mon Sep 17 00:00:00 2001 From: Ing Date: Fri, 17 Jan 2025 17:21:12 +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 --- files/initrd/opt/rr/include/functions.py | 29 +++++++++++++----------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/files/initrd/opt/rr/include/functions.py b/files/initrd/opt/rr/include/functions.py index 38f8fb4f..d3ddb00e 100644 --- a/files/initrd/opt/rr/include/functions.py +++ b/files/initrd/opt/rr/include/functions.py @@ -113,7 +113,7 @@ def getmodels(platforms=None): """ Get Syno Models. """ - import json, requests, urllib3 + import re, json, requests, urllib3 from requests.adapters import HTTPAdapter from requests.packages.urllib3.util.retry import Retry # type: ignore @@ -127,20 +127,23 @@ def getmodels(platforms=None): models = [] try: - req = session.get("https://autoupdate.synology.com/os/v2", timeout=10, verify=False) - req.encoding = "utf-8" - data = json.loads(req.text) + url = "http://update7.synology.com/autoupdate/genRSS.php?include_beta=1" + #url = "https://update7.synology.com/autoupdate/genRSS.php?include_beta=1" - for item in data["channel"]["item"]: - if not item["title"].startswith("DSM"): + req = session.get(url, timeout=10, verify=False) + req.encoding = "utf-8" + p = re.compile(r"(.*?).*?(.*?)", re.MULTILINE | re.DOTALL) + + data = p.findall(req.text) + for item in data: + if not "DSM" in item[1]: continue - for model in item["model"]: - arch = model["mUnique"].split("_")[1] - name = model["mLink"].split("/")[-1].split("_")[1].replace("%2B", "+") - if PS and arch.lower() not in PS: - continue - if not any(m["name"] == name for m in models): - models.append({"name": name, "arch": arch}) + arch = item[0].split("_")[1] + name = item[1].split("/")[-1].split("_")[1].replace("%2B", "+") + if PS and arch.lower() not in PS: + continue + if not any(m["name"] == name for m in models): + models.append({"name": name, "arch": arch}) models.sort(key=lambda k: (k["arch"], k["name"]))