refactor get script from python to shell

This commit is contained in:
wcbing 2024-11-18 19:05:51 +08:00
parent 77e38cbf4b
commit d163c3a2c4
31 changed files with 138 additions and 207 deletions

1
.gitignore vendored
View File

@ -1,5 +1,4 @@
data/github-local.json data/github-local.json
*/module/__pycache__/
deb/* deb/*
!deb/index.html !deb/index.html
!deb/add.sh !deb/add.sh

12
get/module/check.py → check_downloader.py Normal file → Executable file
View File

@ -1,3 +1,4 @@
#!/usr/bin/env python3
import subprocess import subprocess
import os import os
import sqlite3 import sqlite3
@ -51,3 +52,14 @@ def check_download(name, version, url, arch, file_type):
def deb(name, version, url, arch="x86_64"): def deb(name, version, url, arch="x86_64"):
check_download(name, version, url, arch=arch, file_type="deb") check_download(name, version, url, arch=arch, file_type="deb")
if __name__ == "__main__":
args = os.sys.argv
if len(args) == 5:
deb(args[1], args[2], args[3], args[4])
elif len(args) == 4:
deb(args[1], args[2], args[3])
else:
print("Usage: check.py <name> <version> <url> [arch]\n")
print("arch: x86_64, arm64. default is x86_64")

View File

@ -1,14 +0,0 @@
import requests
import json
from module.check import deb
res = requests.get("https://pan.baidu.com/disk/cmsdata?do=client")
res.encoding = "utf-8"
download_list = json.loads(res.text)
version = download_list["linux"]["version"].split("V")[1]
x64_deb_url = download_list["linux"]["url_1"]
# print(version, x64_deb_url)
deb("baidunetdisk", version, x64_deb_url)

6
get/baidunetdisk.sh Normal file
View File

@ -0,0 +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")
./check_downloader.py baidunetdisk $VERSION $X64_URL

View File

@ -1,10 +0,0 @@
import requests
import json
from module.check import deb
version_json = json.loads(requests.get("https://active.browser.360.net/api/v1/web-version").text)
version = version_json["data"]["web_version"]
x64_deb_url = f"https://gedown.360safe.com/gc/browser360-cn-stable_{version}-1_amd64.deb"
deb("browser360-cn-stable", version, x64_deb_url)

View File

@ -0,0 +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"
./check_downloader.py browser360-cn-stable $VERSION $X64_URL

View File

@ -1,12 +0,0 @@
import requests
import json
from module.check import deb
x64_deb_res = requests.get("https://www.feishu.cn/api/package_info?platform=10")
x64_deb_json = json.loads(x64_deb_res.text)
# "version_number": "Linux-x64-deb@V7.22.9"
version = x64_deb_json["data"]["version_number"].split("@V")[1]
x64_deb_url = x64_deb_json["data"]["download_link"]
deb("bytedance-feishu-stable", version, x64_deb_url)

View File

@ -0,0 +1,8 @@
X64_JSON=$(curl -s "https://www.feishu.cn/api/package_info?platform=10")
# arm64 https://www.feishu.cn/api/package_info?platform=12
# "version_number": "Linux-x64-deb@V7.22.9"
VERSION=$(echo $X64_JSON | jq -r ".data.version_number" | cut -d '@' -f 2)
X64_URL=$(echo $X64_JSON | jq -r ".data.download_link")
./check_downloader.py bytedance-feishu-stable $VERSION $X64_URL

View File

@ -1,9 +0,0 @@
import requests
from module.check import deb
req = requests.get("https://www.dingtalk.com/win/d/qd=linux_amd64", allow_redirects=False)
x64_deb_url = req.headers['Location']
version = x64_deb_url.split("/")[-1].split("_")[1]
deb("com.alibabainc.dingtalk", version, x64_deb_url)

View File

@ -0,0 +1,4 @@
X64_URL=$(curl -sw %{redirect_url} https://www.dingtalk.com/win/d/qd=linux_amd64)
VERSION=$(echo $X64_URL | cut -d '/' -f 8| cut -d '_' -f 2)
./check_downloader.py com.alibabainc.dingtalk $VERSION $X64_URL

View File

@ -1,11 +0,0 @@
import requests
from module.check import deb
x64_deb_req = requests.head("https://dida365.com/static/getApp/download?type=linux_deb_x64", headers={"User-Agent": "curl/8.10.1"})
# arm64_deb_req = requests.head("https://dida365.com/static/getApp/download?type=linux_deb_arm64", headers={"User-Agent": "curl/8.10.1"})
x64_deb_url = x64_deb_req.headers["location"]
# https://cdn.dida365.cn/download/linux/linux_deb_x64/dida-6.0.0-amd64.deb
version = x64_deb_url.split("-")[-2]
deb("dida", version, x64_deb_url)

7
get/dida.sh Normal file
View File

@ -0,0 +1,7 @@
X64_URL=$(curl -sI "https://dida365.com/static/getApp/download?type=linux_deb_x64" | grep location | cut -d ' ' -f 2)
# arm64 https://dida365.com/static/getApp/download?type=linux_deb_arm64
# 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

View File

@ -1,18 +0,0 @@
import requests
import re
import json
from module.check import deb
res = requests.get("https://im.qq.com/rainbow/linuxQQDownload")
res.encoding = "utf-8"
download_list_json = re.search(
r"var params\s*=\s*(\{.*?\});", res.text, re.DOTALL
).group(1)
download_list = json.loads(download_list_json)
version = download_list["version"] + "_" + download_list["updateDate"]
x64_deb_url = download_list["x64DownloadUrl"]["deb"]
# print(version, x64_deb_url)
deb("linuxqq", version, x64_deb_url)

6
get/linuxqq.sh Normal file
View File

@ -0,0 +1,6 @@
JSON=$(curl -s https://im.qq.com/rainbow/linuxQQDownload | sed -nE 's/.*var params\s*=\s*(\{.*?\});.*/\1/p')
VERSION=$(echo $JSON | jq -r '.version + "_" + .updateDate')
X64_URL=$(echo $JSON | jq -r '.x64DownloadUrl.deb')
./check_downloader.py linuxqq $VERSION $X64_URL

View File

@ -1,15 +0,0 @@
import requests
import re
from module.check import deb
res = requests.get("https://y.qq.com/download/download.html")
res.encoding = "utf-8"
version = re.findall(
r"Linux <span class=\"product_list__version\">最新版:(\d+\.\d+\.\d+)</span>",
res.text,
)[0]
x64_deb_url = re.findall(r"https://dl\S+\.deb", res.text)[0]
# print(version, x64_deb_url)
deb("qqmusic", version, x64_deb_url)

6
get/qqmusic.sh Normal file
View File

@ -0,0 +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)
./check_downloader.py qqmusic $VERSION $X64_URL

View File

@ -1,8 +0,0 @@
import requests
from module.check import deb
req = requests.get("https://client-webapi.oray.com/softwares/SUNLOGIN_X_LINUX?x64=1")
version = req.json()["versionno"]
x64_url = req.json()["downloadurl"]
deb("sunloginclient", version, x64_url)

6
get/sunlogin.sh Normal file
View File

@ -0,0 +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')
./check_downloader.py sunlogin $VERSION $X64_URL

View File

@ -1,12 +0,0 @@
import requests
import re
from module.check import deb
res = requests.get("https://www.todesk.com/linux.html")
x64_url = re.findall("https://[0-9a-zA-Z_/.-]*.deb", res.text)[0]
# https://dl.todesk.com/linux/todesk-v4.7.2.0-amd64.deb
version = x64_url.split("-")[1]
deb("todesk", version, x64_url)

6
get/todesk.sh Normal file
View File

@ -0,0 +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
VERSION=$(echo $X64_URL | cut -d '-' -f 2)
./check_downloader.py todesk $VERSION $X64_URL

View File

@ -1,11 +0,0 @@
import requests
import re
from module.check import deb
res = requests.get("https://u.tools/download/")
res.encoding = "utf-8"
x64_deb_url = re.findall(r"https:\/\/[^ ]+\.deb", res.text)[0]
version = re.findall(".*utools_(.+)_amd64.deb", x64_deb_url)[0]
deb("utools", version, x64_deb_url)

8
get/utools.sh Normal file
View File

@ -0,0 +1,8 @@
WEB_CONTENT=$(curl -s "https://u.tools/download/")
X64_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)
./check_downloader.py utools $VERSION $X64_URL

View File

@ -1,13 +0,0 @@
import requests
import re
from module.check import deb
html = requests.get("https://linux.weixin.qq.com/").text
x64_deb_url = re.findall(r'href="(https:.*x86_64\.deb)"', html)[0]
last_modified = requests.head(x64_deb_url).headers["Last-Modified"]
# Wed, 06 Nov 2024 02:08:50 GMT
version = "-".join(last_modified.split(" ")[1:5])
# 06-Nov-2024-02:08:50
deb("wechat", version, x64_deb_url)

9
get/wechat.sh Normal file
View File

@ -0,0 +1,9 @@
WEB_CONTENT=$(curl -s "https://linux.weixin.qq.com/")
X64_URL=$(echo $WEB_CONTENT | grep -o 'https:[0-9a-zA-Z/\._]*x86_64\.deb')
Last_Modified=$(curl -sI $X64_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

View File

@ -1,28 +0,0 @@
import requests
import json
from module.check import deb
"""
https://meeting.tencent.com/web-service/query-download-info?q=[\
{"package-type":"app","channel":"0300000000","platform":"linux","arch":"x86_64","decorators":["deb"]},\
{"package-type":"app","channel":"0300000000","platform":"linux","arch":"arm64","decorators":["deb"]},\
{"package-type":"app","channel":"0300000000","platform":"linux","arch":"loongarch64","decorators":["deb"]}\
]&nonce=D38mxpWk6TMTA44a
"""
download_list_url = "https://meeting.tencent.com/web-service/query-download-info?q=%5B\
%7B%22package-type%22%3A%22app%22%2C%22channel%22%3A%220300000000%22%2C%22platform%22%3A%22linux%22%2C%22arch%22%3A%22x86_64%22%2C%22decorators%22%3A%5B%22deb%22%5D%7D%2C\
%7B%22package-type%22%3A%22app%22%2C%22channel%22%3A%220300000000%22%2C%22platform%22%3A%22linux%22%2C%22arch%22%3A%22arm64%22%2C%22decorators%22%3A%5B%22deb%22%5D%7D%2C\
%7B%22package-type%22%3A%22app%22%2C%22channel%22%3A%220300000000%22%2C%22platform%22%3A%22linux%22%2C%22arch%22%3A%22loongarch64%22%2C%22decorators%22%3A%5B%22deb%22%5D%7D\
%5D&nonce=D38mxpWk6TMTA44a"
res = requests.get(download_list_url)
res.encoding = "utf-8"
download_list = json.loads(res.text)
version = download_list["info-list"][0]["version"]
x64_deb_url = download_list["info-list"][0]["url"]
# print(version, x64_deb_url)
deb("wemeet", version, x64_deb_url)

18
get/wemeet.sh Normal file
View File

@ -0,0 +1,18 @@
# https://meeting.tencent.com/web-service/query-download-info?q=[\
# {"package-type":"app","channel":"0300000000","platform":"linux","arch":"x86_64","decorators":["deb"]},\
# {"package-type":"app","channel":"0300000000","platform":"linux","arch":"arm64","decorators":["deb"]},\
# {"package-type":"app","channel":"0300000000","platform":"linux","arch":"loongarch64","decorators":["deb"]}\
# ]&nonce=D38mxpWk6TMTA44a
download_list_url="https://meeting.tencent.com/web-service/query-download-info?q=%5B\
%7B%22package-type%22%3A%22app%22%2C%22channel%22%3A%220300000000%22%2C%22platform%22%3A%22linux%22%2C%22arch%22%3A%22x86_64%22%2C%22decorators%22%3A%5B%22deb%22%5D%7D%2C\
%7B%22package-type%22%3A%22app%22%2C%22channel%22%3A%220300000000%22%2C%22platform%22%3A%22linux%22%2C%22arch%22%3A%22arm64%22%2C%22decorators%22%3A%5B%22deb%22%5D%7D%2C\
%7B%22package-type%22%3A%22app%22%2C%22channel%22%3A%220300000000%22%2C%22platform%22%3A%22linux%22%2C%22arch%22%3A%22loongarch64%22%2C%22decorators%22%3A%5B%22deb%22%5D%7D\
%5D&nonce=D38mxpWk6TMTA44a"
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

27
get/wps-office.sh Normal file
View File

@ -0,0 +1,27 @@
decrypt() {
url=$1
pathname="/$(echo $url | cut -d '/' -f 4-)"
secrity_key="7f8faaaa468174dc1c9cd62e5f218a5b"
timestamp10=$(date '+%s')
md5hash=$(echo -n "${secrity_key}${pathname}${timestamp10}" | md5sum | cut -d " " -f 1 )
url="$url?t=${timestamp10}&k=${md5hash}"
echo $url
# # js
# function downLoad(url) {
# var urlObj=new URL(url);
# var uri=urlObj.pathname;
# var secrityKey="7f8faaaa468174dc1c9cd62e5f218a5b";
# var timestamp10=Math.floor(new Date().getTime() / 1000);
# var md5hash=CryptoJS.MD5(secrityKey + uri + timestamp10);
# url += '?t=' + timestamp10 + '&k=' + md5hash
# console.log(url);
# }
}
WEB_CONTENT=$(curl -fs https://linux.wps.cn/)
VERSION=$(echo $WEB_CONTENT | grep -o "<p class=\"banner_txt\">[0-9.]*</p>" | sed 's/<p class=\"banner_txt\">\(.*\)<\/p>/\1/')
X64_ORI_URL=$(echo $WEB_CONTENT | grep -o "https://[0-9a-zA-Z_\/\.\-]*amd64\.deb" | head -n 1)
X64_URL=$(decrypt $X64_ORI_URL)
./check_downloader.py wps-office $VERSION $X64_URL

View File

@ -1,34 +0,0 @@
import requests
import re
import time
import hashlib
from module.check import deb
res = requests.get("https://linux.wps.cn/")
res.encoding = "utf-8"
version = re.findall(r"<p class=\"banner_txt\">(.*)</p>", res.text)[0]
"""js
function downLoad(url) {
var urlObj = new URL(url);
var uri = urlObj.pathname;
var secrityKey = "7f8faaaa468174dc1c9cd62e5f218a5b";
var timestamp10 = Math.floor(new Date().getTime() / 1000);
var md5hash = CryptoJS.MD5(secrityKey + uri + timestamp10);
url += '?t=' + timestamp10 + '&k=' + md5hash
console.log(url);
}
"""
secrityKey = "7f8faaaa468174dc1c9cd62e5f218a5b"
timestamp10 = str(int(time.time()))
x64_deb_url = re.findall(r"https://.*/wps/download/.*_amd64.deb", res.text)[0]
x64_deb_pathname = "/" + "/".join(x64_deb_url.split("/")[3:])
x64_deb_md5hash = hashlib.md5(str.encode(secrityKey + x64_deb_pathname + timestamp10))
x64_deb_url += '?t=' + timestamp10 + '&k=' + x64_deb_md5hash.hexdigest()
# print(version, x64_deb_url)
deb("wps-office", version, x64_deb_url)

View File

@ -1,10 +0,0 @@
import requests
from module.check import deb
x64_deb_req = requests.head("https://xmind.cn/zen/download/linux_deb/")
x64_deb_url = x64_deb_req.headers["Location"]
# https://dl3.xmind.cn/Xmind-for-Linux-amd64bit-24.04.10311-202405240010.deb
version = x64_deb_url.split("-")[-2]
deb("xmind-vana", version, x64_deb_url)

6
get/xmind-vana.sh Normal file
View File

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

View File

@ -1,13 +1,15 @@
#!/bin/sh #!/bin/sh
date date
# import go tools
export PATH="$PATH:$HOME/go/bin/"
# merge the Packages files of third-party repositories # merge the Packages files of third-party repositories
rm deb/Packages rm deb/Packages
merge-apt-repo merge-apt-repo
# check for updates # check for updates
github-downloader -r github-downloader -r
find get -maxdepth 1 -type f -name "*.py" -exec python3 {} \; find get -maxdepth 1 -type f -name "*.sh" -exec sh {} \;
# generate the files # generate the files
cd deb cd deb