diff --git a/README.md b/README.md index ae0ed6d..ee59d03 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ echo "deb [signed-by=/etc/apt/keyrings/wcbing.gpg] https://packages.wcbing.top/d 1. clone 本仓库,进入仓库目录。 2. 确认系统安装有 `Requests` Python 库,Debian 系应该自带。 -2. 运行 `init.py` 初始化。 +2. 运行 `init_deb.py` 初始化。 默认只新建 x86_64,需要其他架构请修改其中的SQL语句。 3. 创建一个**无密码**的 GPG 密钥对,导出 GPG 公钥文件待用。 4. 创建定时任务,定时运行 `update_gen.sh` diff --git a/get/clash-verge.py b/get/clash-verge.py index 3d01185..e0632ac 100644 --- a/get/clash-verge.py +++ b/get/clash-verge.py @@ -1,5 +1,5 @@ import requests -from module.check import check_download +from module.check import deb name = "clash-verge" @@ -15,4 +15,4 @@ x64_deb_url = ( release_url + "/download/" + vversion + "/" + name + "_" + version + "_amd64.deb" ) -check_download(name, version, x64_deb_url) +deb(name, version, x64_deb_url) diff --git a/get/code.py b/get/code.py index c353f5b..eaa6651 100644 --- a/get/code.py +++ b/get/code.py @@ -1,6 +1,6 @@ import requests import re -from module.check import check_download +from module.check import deb x64_deb_req = "https://code.visualstudio.com/sha/download?build=stable&os=linux-deb-x64" @@ -9,4 +9,4 @@ version = re.findall("_(.*)-", res.headers["Location"])[0] x64_deb_url = res.headers["Location"] # print(version, x64_deb_url) -check_download("code", version, x64_deb_url) +deb("code", version, x64_deb_url) diff --git a/get/google-chrome-stable.py b/get/google-chrome-stable.py index b78cfe8..89fc475 100644 --- a/get/google-chrome-stable.py +++ b/get/google-chrome-stable.py @@ -1,6 +1,6 @@ import requests import json -from module.check import check_download +from module.check import deb version_url = "https://versionhistory.googleapis.com/v1/chrome/platforms/linux/channels/stable/versions" res = requests.get(version_url) @@ -9,4 +9,4 @@ version = json.loads(res.text)["versions"][0]["version"] x64_deb_url = "https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb" -check_download("google-chrome-stable", version, x64_deb_url) +deb("google-chrome-stable", version, x64_deb_url) diff --git a/get/hugo.py b/get/hugo.py index 6a857e3..62a2fd7 100644 --- a/get/hugo.py +++ b/get/hugo.py @@ -1,5 +1,5 @@ import requests -from module.check import check_download +from module.check import deb name = "hugo" @@ -16,4 +16,4 @@ x64_deb_url = ( + name + "_" + version + "_linux-amd64.deb" ) -check_download(name, version, x64_deb_url) +deb(name, version, x64_deb_url) diff --git a/get/linuxqq.py b/get/linuxqq.py index 1f315dd..a2670d0 100644 --- a/get/linuxqq.py +++ b/get/linuxqq.py @@ -1,7 +1,7 @@ import requests import re import json -from module.check import check_download +from module.check import deb res = requests.get("https://im.qq.com/rainbow/linuxQQDownload") res.encoding = "utf-8" @@ -15,4 +15,4 @@ version = download_list["version"] x64_deb_url = download_list["x64DownloadUrl"]["deb"] # print(version, x64_deb_url) -check_download("linuxqq", version, x64_deb_url) +deb("linuxqq", version, x64_deb_url) diff --git a/get/microsoft-edge-stable.py b/get/microsoft-edge-stable.py index 233c020..f7b87ac 100644 --- a/get/microsoft-edge-stable.py +++ b/get/microsoft-edge-stable.py @@ -1,6 +1,6 @@ import requests import re -from module.check import check_download +from module.check import deb x64_deb_url = "https://go.microsoft.com/fwlink?linkid=2149051" @@ -9,4 +9,4 @@ version = re.findall("_(.*)_", res.headers["Location"])[0] x64_deb_url = res.headers["Location"] # print(version, x64_deb_url) -check_download("microsoft-edge-stable", version, x64_deb_url) +deb("microsoft-edge-stable", version, x64_deb_url) diff --git a/get/mihomo.py b/get/mihomo.py index c04caea..dadcfef 100644 --- a/get/mihomo.py +++ b/get/mihomo.py @@ -1,5 +1,5 @@ import requests -from module.check import check_download +from module.check import deb name = "mihomo" @@ -16,4 +16,4 @@ x64_deb_url = ( + name + "-linux-amd64-compatible-" + vversion + ".deb" ) -check_download(name, version, x64_deb_url) +deb(name, version, x64_deb_url) diff --git a/get/module/check.py b/get/module/check.py index fc3979f..dd10b3d 100644 --- a/get/module/check.py +++ b/get/module/check.py @@ -3,8 +3,8 @@ import os import sqlite3 -def check_download(name, version, url, arch="x86_64"): - conn = sqlite3.connect("deb.db") +def check_download(name, version, url, arch, file_type): + conn = sqlite3.connect(file_type + ".db") cur = conn.cursor() res = cur.execute( @@ -17,11 +17,11 @@ def check_download(name, version, url, arch="x86_64"): if db_version != version: print("└ Update: " + db_version + " -> " + version) # remove old version - old_file_path = os.path.join("deb", str(db_url.split("/")[-1])) + old_file_path = os.path.join(file_type, str(db_url.split("/")[-1])) if os.path.exists(old_file_path): os.remove(old_file_path) # download - file_path = os.path.join("deb", str(url.split("/")[-1])) + file_path = os.path.join(file_type, str(url.split("/")[-1])) with open(file_path, "wb") as fw: fw.write(requests.get(url).content) # wirte to db @@ -32,7 +32,7 @@ def check_download(name, version, url, arch="x86_64"): else: print(name + "\n└ Add: " + version) # download - file_path = os.path.join("deb", str(url.split("/")[-1])) + file_path = os.path.join(file_type, str(url.split("/")[-1])) with open(file_path, "wb") as fw: fw.write(requests.get(url).content) # wirte to db @@ -44,3 +44,7 @@ def check_download(name, version, url, arch="x86_64"): cur.close() conn.commit() conn.close() + + +def deb(name, version, url, arch="x86_64"): + check_download(name, version, url, arch=arch, file_type="deb") diff --git a/get/obsidian.py b/get/obsidian.py index e8cbd8f..c3f0e19 100644 --- a/get/obsidian.py +++ b/get/obsidian.py @@ -1,5 +1,5 @@ import requests -from module.check import check_download +from module.check import deb name = "obsidian" @@ -15,4 +15,4 @@ x64_deb_url = ( release_url + "/download/" + vversion + "/" + name + "_" + version + "_amd64.deb" ) -check_download(name, version, x64_deb_url) +deb(name, version, x64_deb_url) diff --git a/get/qqmusic.py b/get/qqmusic.py index 44d8968..5b18ec5 100644 --- a/get/qqmusic.py +++ b/get/qqmusic.py @@ -1,6 +1,6 @@ import requests import re -from module.check import check_download +from module.check import deb res = requests.get("https://y.qq.com/download/download.html") res.encoding = "utf-8" @@ -12,4 +12,4 @@ version = re.findall( x64_deb_url = re.findall(r"https://dl\S+\.deb", res.text)[0] # print(version, x64_deb_url) -check_download("qqmusic", version, x64_deb_url) +deb("qqmusic", version, x64_deb_url) diff --git a/get/rustdesk.py b/get/rustdesk.py index 882e3b3..2ba48a4 100644 --- a/get/rustdesk.py +++ b/get/rustdesk.py @@ -1,5 +1,5 @@ import requests -from module.check import check_download +from module.check import deb name = "rustdesk" @@ -14,4 +14,4 @@ x64_deb_url = ( release_url + "/download/" + version + "/" + name + "-" + version + "-x86_64.deb" ) -check_download(name, version, x64_deb_url) +deb(name, version, x64_deb_url) diff --git a/get/wemeet.py b/get/wemeet.py index 3399592..595f7d3 100644 --- a/get/wemeet.py +++ b/get/wemeet.py @@ -1,6 +1,6 @@ import requests import json -from module.check import check_download +from module.check import deb """ https://meeting.tencent.com/web-service/query-download-info?q=[\ @@ -25,4 +25,4 @@ version = download_list["info-list"][0]["version"] x64_deb_url = download_list["info-list"][0]["url"] # print(version, x64_deb_url) -check_download("wemeet", version, x64_deb_url) +deb("wemeet", version, x64_deb_url) diff --git a/init.py b/init_deb.py similarity index 100% rename from init.py rename to init_deb.py