Compare commits

..

5 Commits

Author SHA1 Message Date
a2aebfdd12 update splayer 2025-09-27 09:54:04 +08:00
dc23057d73 update qqmusic 2025-09-26 10:56:03 +08:00
d0056f8fe1 refactor: save packages info to file 2025-09-26 10:56:03 +08:00
c293d186c9 fix: limit the number of parameters 2025-09-26 10:35:10 +08:00
e96e818041 add mqttx 2025-09-26 10:13:58 +08:00
17 changed files with 103 additions and 108 deletions

View File

@ -4,9 +4,11 @@ import os
import sqlite3
import sys
import logging
import re
from threading import Lock
BASE_DIR = "deb"
DEB_BASE_DIR = "deb"
PACKAGES_DIR = "packages"
DB_DIR = "data"
USER_AGENT = "Debian APT-HTTP/1.3 (2.6.1)" # from Debian 12
@ -19,28 +21,65 @@ logging.basicConfig(
)
def download(url):
def download(url, file_path) -> bool:
"""Download file using curl with APT User-Agent."""
file_path = os.path.join(BASE_DIR, url.split("?")[0])
os.makedirs(os.path.dirname(file_path), exist_ok=True)
subprocess.run(["curl", "-H", f"User-Agent: {USER_AGENT}", "-fsLo", file_path, url])
curl_process = subprocess.run(
["curl", "-H", f"User-Agent: {USER_AGENT}", "-fsLo", file_path, url]
)
if curl_process.returncode or not os.path.exists(file_path):
logging.error(f"Failed to download {url}")
return False
return True
def check_download(name, version, url, arch="amd64"):
def scan(name, arch, url, file_path) -> bool:
scan_process = subprocess.run(
["apt-ftparchive", "packages", file_path], capture_output=True
)
package = scan_process.stdout.decode()
package = re.sub(
r"^(Filename: ).*", f"\\1{url}", package, flags=re.MULTILINE
) # 替换 Filename 开头的行
package_file_path = os.path.join(PACKAGES_DIR, arch, f"{name}.package")
try:
with open(package_file_path, "w") as f:
f.write(package)
return True
except IOError as e:
logging.error(f"Failed to write package file for {name}: {e}")
return False
def check_download(name, version, url, arch):
"""Check and handle package download/update."""
logging.info("%s:%s = %s", name, arch, version)
db_path = os.path.join("data", f"{BASE_DIR}.db")
file_path = os.path.join(DEB_BASE_DIR, arch, f"{name}_{version}_{arch}.deb")
local_version = None
db_path = os.path.join("data", f"{DEB_BASE_DIR}.db")
# get local version
with version_lock, sqlite3.connect(db_path) as conn:
res = conn.execute(
f"SELECT version, url FROM '{arch}' WHERE name = ?", (name,)
f"SELECT version FROM '{arch}' WHERE name = ?", (name,)
).fetchone()
if res:
local_version, local_url = res
if local_version != version:
local_version = res[0]
if local_version == version:
return
# download and scan
logging.info(f"Downloading {name}:{arch} ({version})")
os.makedirs(os.path.join(DEB_BASE_DIR, arch), exist_ok=True)
if not download(url, file_path):
return
os.makedirs(os.path.join(PACKAGES_DIR, arch), exist_ok=True)
if not scan(name, arch, url, file_path):
return
if res:
print(f"Update: {name}:{arch} ({local_version} -> {version})")
download(url)
# update database
with version_lock, sqlite3.connect(db_path) as conn:
conn.execute(
@ -49,13 +88,11 @@ def check_download(name, version, url, arch="amd64"):
)
conn.commit()
# remove old version
if local_url != url: # 防止固定下载链接
old_file_path = os.path.join(BASE_DIR, local_url.split("?")[0])
old_file_path = os.path.join(DEB_BASE_DIR, f"{name}_{local_version}_{arch}.deb")
if os.path.exists(old_file_path):
os.remove(old_file_path)
else:
print(f"AddNew: {name}:{arch} ({version})")
download(url)
# update database
with version_lock, sqlite3.connect(db_path) as conn:
conn.execute(
@ -67,11 +104,11 @@ def check_download(name, version, url, arch="amd64"):
if __name__ == "__main__":
args = sys.argv
if len(args) in (4, 5):
if len(args) == 5:
check_download(*args[1:])
elif len(args) > 1:
logging.error(f"Unknown Args: {args[1:]}")
else:
print(f"Usage: {args[0]} <package_name> <version> <url> [arch]")
print(f"Usage: {args[0]} <package_name> <version> <url> <arch>")
print("options:")
print(" arch: amd64, arm64, all. default is amd64")
print(" arch: amd64, arm64, all.")

View File

@ -138,5 +138,11 @@
"amd64": "MQTTX_{version}_amd64.deb",
"arm64": "MQTTX_{version}_arm64.deb"
}
},
"splayer": {
"repo": "imsyy/SPlayer",
"file_list": {
"amd64": "splayer_{version}_amd64.deb"
}
}
}

View File

@ -1,6 +1,6 @@
JSON=$(curl -s "https://pan.baidu.com/disk/cmsdata?do=client")
VERSION=$(echo $JSON | jq -r ".linux.version" | cut -d "V" -f 2)
X64_URL=$(echo $JSON | jq -r ".linux.url_1")
AMD64_URL=$(echo $JSON | jq -r ".linux.url_1")
./check_downloader.py baidunetdisk $VERSION $X64_URL
./check_downloader.py baidunetdisk $VERSION $AMD64_URL amd64

View File

@ -1,6 +1,6 @@
JSON=$(curl -s https://active.browser.360.net/api/v1/web-version)
VERSION=$(echo $JSON | jq -r ".data.web_version")
X64_URL="https://gedown.360safe.com/gc/browser360-cn-stable_"$VERSION"-1_amd64.deb"
AMD64_URL="https://gedown.360safe.com/gc/browser360-cn-stable_"$VERSION"-1_amd64.deb"
./check_downloader.py browser360-cn-stable $VERSION $X64_URL
./check_downloader.py browser360-cn-stable $VERSION $AMD64_URL amd64

View File

@ -4,7 +4,7 @@ VERSIONS_JSON=$(curl -fs "https://www.feishu.cn/api/downloads")
# "version_number": "Linux-x64-deb@V7.22.9"
AMD64_VERSION=$(echo $VERSIONS_JSON | jq -r ".versions.Linux_deb_x64.version_number" | cut -d 'V' -f 2)
AMD64_URL=$(echo $VERSIONS_JSON | jq -r ".versions.Linux_deb_x64.download_link")
./check_downloader.py bytedance-feishu-stable $AMD64_VERSION $AMD64_URL
./check_downloader.py bytedance-feishu-stable $AMD64_VERSION $AMD64_URL amd64
# ARM64
ARM64_VERSION=$(echo $VERSIONS_JSON | jq -r ".versions.Linux_deb_arm.version_number" | cut -d 'V' -f 2)

View File

@ -1,6 +1,6 @@
X64_URL=$(curl -sw %{redirect_url} https://www.dingtalk.com/win/d/qd=linux_amd64)
VERSION=$(echo $X64_URL | sed 's#.*/##g' | cut -d '_' -f 2)
./check_downloader.py com.alibabainc.dingtalk $VERSION $X64_URL
AMD64_URL=$(curl -sw %{redirect_url} https://www.dingtalk.com/win/d/qd=linux_amd64)
VERSION=$(echo $AMD64_URL | sed 's#.*/##g' | cut -d '_' -f 2)
./check_downloader.py com.alibabainc.dingtalk $VERSION $AMD64_URL amd64
ARM64_URL=$(curl -sw %{redirect_url} https://www.dingtalk.com/win/d/qd=linux_arm64)
VERSION=$(echo $ARM64_URL | sed 's#.*/##g' | cut -d '_' -f 2)

View File

@ -1,7 +1,7 @@
X64_URL=$(curl -sI "https://dida365.com/static/getApp/download?type=linux_deb_x64" | grep location | cut -d ' ' -f 2 | tr -d '\r')
AMD64_URL=$(curl -sI "https://dida365.com/static/getApp/download?type=linux_deb_x64" | grep location | cut -d ' ' -f 2 | tr -d '\r')
# https://cdn.dida365.cn/download/linux/linux_deb_x64/dida-6.0.0-amd64.deb
VERSION=$(echo $X64_URL | cut -d "-" -f 2)
./check_downloader.py dida $VERSION $X64_URL
VERSION=$(echo $AMD64_URL | cut -d "-" -f 2)
./check_downloader.py dida $VERSION $AMD64_URL amd64
# ARM64
ARM64_URL=$(curl -sI "https://dida365.com/static/getApp/download?type=linux_deb_arm64" | grep location | cut -d ' ' -f 2 | tr -d '\r')

View File

@ -1,6 +1,6 @@
WEB_CONTENT=$(curl -s "https://y.qq.com/download/download.html")
VERSION=$(echo $WEB_CONTENT | grep -o "Linux <span class=\"product_list__version\">最新版:[0-9\.]*" | cut -d ':' -f 2)
X64_URL=$(echo $WEB_CONTENT | grep -o "https://[0-9a-z/\._]*amd64\.deb" | head -n 1)
AMD64_URL=$(echo $WEB_CONTENT | grep -o "https://[^\"]*amd64\.deb[^\"]*" | head -n 1)
./check_downloader.py qqmusic $VERSION $X64_URL
./check_downloader.py qqmusic $VERSION $AMD64_URL amd64

View File

@ -1,6 +1,6 @@
JSON=$(curl -fs "https://client-webapi.oray.com/softwares/SUNLOGIN_X_LINUX?x64=1")
VERSION=$(echo "$JSON" | jq -r '.versionno')
X64_URL=$(echo $JSON | jq -r '.downloadurl')
AMD64_URL=$(echo $JSON | jq -r '.downloadurl')
./check_downloader.py sunloginclient $VERSION $X64_URL
./check_downloader.py sunloginclient $VERSION $AMD64_URL amd64

View File

@ -1,6 +1,6 @@
X64_URL=$(curl -s https://www.todesk.com/linux.html | grep -o "https://[0-9a-zA-Z_\/\.\-]*.deb" | head -n 1)
# X64_URL=https:/ /dl.todesk.com/linux/todesk-v4.7.2.0-amd64.deb
AMD64_URL=$(curl -s https://www.todesk.com/linux.html | grep -o "https://[0-9a-zA-Z_\/\.\-]*.deb" | head -n 1)
# AMD64_URL=https:/ /dl.todesk.com/linux/todesk-v4.7.2.0-amd64.deb
VERSION=$(echo $X64_URL | cut -d '-' -f 2)
VERSION=$(echo $AMD64_URL | cut -d '-' -f 2)
./check_downloader.py todesk $VERSION $X64_URL
./check_downloader.py todesk $VERSION $AMD64_URL amd64

View File

@ -1,8 +1,8 @@
WEB_CONTENT=$(curl -s "https://www.u-tools.cn/download/")
X64_URL=$(echo $WEB_CONTENT | grep -o "https://[^ ]*amd64\.deb")
AMD64_URL=$(echo $WEB_CONTENT | grep -o "https://[^ ]*amd64\.deb")
# https://open.u-tools.cn/download/utools_5.2.1_amd64.deb
VERSION=$(echo $X64_URL | cut -d '_' -f 2)
VERSION=$(echo $AMD64_URL | cut -d '_' -f 2)
./check_downloader.py utools $VERSION $X64_URL
./check_downloader.py utools $VERSION $AMD64_URL amd64

View File

@ -1,13 +1,13 @@
WEB_CONTENT=$(curl -s "https://linux.weixin.qq.com/")
# X64
X64_URL=$(echo $WEB_CONTENT | grep -o 'https:[0-9a-zA-Z/\._]*x86_64\.deb')
Last_Modified=$(curl -sI $X64_URL | grep "Last-Modified")
# AMD64
AMD64_URL=$(echo $WEB_CONTENT | grep -o 'https:[0-9a-zA-Z/\._]*x86_64\.deb')
Last_Modified=$(curl -sI $AMD64_URL | grep "Last-Modified")
# Last-Modified: Wed, 06 Nov 2024 02:08:50 GMT
VERSION=$(echo $Last_Modified | cut -d ' ' -f 3-6 | sed 's/ /-/g')
# 06-Nov-2024-02:08:50
./check_downloader.py wechat $VERSION $X64_URL
./check_downloader.py wechat $VERSION $AMD64_URL amd64
# ARM64
ARM64_URL=$(echo $WEB_CONTENT | grep -o 'https:[0-9a-zA-Z/\._]*arm64\.deb')

View File

@ -13,8 +13,8 @@ download_list_url="https://meeting.tencent.com/web-service/query-download-info?q
JSON=$(curl -s $download_list_url)
VERSION=$(echo $JSON | jq -r '."info-list"[0].version')
X64_URL=$(echo $JSON | jq -r '."info-list"[0].url')
./check_downloader.py wemeet $VERSION $X64_URL
AMD64_URL=$(echo $JSON | jq -r '."info-list"[0].url')
./check_downloader.py wemeet $VERSION $AMD64_URL amd64
# ARM64
VERSION=$(echo $JSON | jq -r '."info-list"[1].version')

View File

@ -1,6 +1,6 @@
X64_URL=$(curl -sI "https://xmind.cn/zen/download/linux_deb/" | grep location | cut -d ' ' -f 2 | tr -d '\r')
AMD64_URL=$(curl -sI "https://xmind.cn/zen/download/linux_deb/" | grep location | cut -d ' ' -f 2 | tr -d '\r')
# https://dl3.xmind.cn/Xmind-for-Linux-amd64bit-24.04.10311-202405240010.deb
VERSION=$(echo $X64_URL | cut -d '-' -f 5)
VERSION=$(echo $AMD64_URL | cut -d '-' -f 5)
./check_downloader.py xmind-vana $VERSION $X64_URL
./check_downloader.py xmind-vana $VERSION $AMD64_URL amd64

View File

@ -1,20 +0,0 @@
Package: qqmusic
Architecture: amd64
Version: 1.1.8
Priority: extra
Section: default
Maintainer: TME <TencentQQMusic@tencent.com>
Installed-Size: 226890
Depends: libgtk-3-0, libnotify4, libnss3, libxss1, libxtst6, xdg-utils, libatspi2.0-0, libuuid1, libappindicator3-1, libsecret-1-0
Filename: https://c.y.qq.com/cgi-bin/file_redirect.fcg?bid=dldir&file=ecosfile_plink%2Fmusic_clntupate%2Flinux%2Fother%2Fqqmusic_1.1.8_amd64.deb&sign=1-d1ca4d5c5a8369b26af88e881ba3ac544066a899dcaea29778b35c9f648e6fee-68cb7c1c
Size: 75662164
MD5sum: c80f1330c6cff0c3be8c767f94f83a1f
SHA1: 2fa7f4ae6ff83ced9d15304d22b094a77dab1874
SHA256: 42d18d6a8c3c17414e5b6dbc0c3ac893bb2540c1c5c09ce90d241843cc593788
SHA512: 0da75cddd70340dfb3551af39200b6c90a3b506db539a0276d4a4f50d593f3559dcfa16819a68634ef0b85247d1add1737f699fd24942f1da8915ee867f4b2ee
Homepage: http://y.qq.com
Description: qqmusic for linux
Tencent QQMusic
License: CC0-1.0
Vendor: TME <TencentQQMusic@tencent.com>

View File

@ -1,21 +0,0 @@
Package: splayer
Architecture: amd64
Version: 3.0.0~beta.1
Priority: optional
Section: default
Maintainer: imsyy.top
Installed-Size: 387552
Depends: libgtk-3-0, libnotify4, libnss3, libxss1, libxtst6, xdg-utils, libatspi2.0-0, libuuid1, libsecret-1-0
Recommends: libappindicator3-1
Filename: https://github.com/imsyy/SPlayer/releases/download/v3.0.0-beta.1/splayer_3.0.0-beta.1_amd64.deb
Size: 98165414
MD5sum: 36a196fea2751680f03b7a3dad1045fd
SHA1: bed49a7ee405b1af3383e1096e38c9626e9040d6
SHA256: 2c58224c7630a6f31b577e9109be7a4e5c092984d76642d4928b88e28cbce6f6
SHA512: 8bb9334f00eb07a410c4ab0b543cfd31d94953696bfe43bdc9795ff0391dc44418a0db5d9e9f837f26ccef0f2b19ac987c67196d55435336e02138ee7a55225b
Homepage: https://github.com/imsyy/SPlayer#readme
Description:
A minimalist music player
License: AGPL-3.0
Vendor: imsyy.top

9
run.sh
View File

@ -7,15 +7,8 @@ find get -type f -name "*.sh" -exec sh {} \;
# generate the html
./gen-list-html.py
# generate the Packages file
## generate the local Packages file
cd deb
apt-ftparchive packages . > tmpPackages
sed -i "s|\./\(https\?\):/|\1://|g" tmpPackages
cd ..
## merge the Packages file from local package
cat $(find packages -name "*.package") >> deb/tmpPackages
cat $(find packages -name "*.package") > deb/tmpPackages
## merge the Packages files from third-party repositories
./merge-apt-repo.py --local deb/tmpPackages