forked from DDS-Derek/xiaoya-alist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
xiaoya_data_downloader.sh
90 lines (83 loc) · 3.37 KB
/
xiaoya_data_downloader.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/bash
# shellcheck shell=bash
PATH=${PATH}:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin
export PATH
#
# ——————————————————————————————————————————————————————————————————————————————————
# __ ___ _ _ _
# \ \ / (_) /\ | (_) | |
# \ V / _ __ _ ___ _ _ __ _ / \ | |_ ___| |_
# > < | |/ _` |/ _ \| | | |/ _` | / /\ \ | | / __| __|
# / . \| | (_| | (_) | |_| | (_| | / ____ \| | \__ \ |_
# /_/ \_\_|\__,_|\___/ \__, |\__,_| /_/ \_\_|_|___/\__|
# __/ |
# |___/
#
# Copyright (c) 2024 DDSRem <https://blog.ddsrem.com>
#
# This is free software, licensed under the Mit License.
#
# ——————————————————————————————————————————————————————————————————————————————————
Green="\033[32m"
Red="\033[31m"
Font="\033[0m"
INFO="[${Green}INFO${Font}]"
ERROR="[${Red}ERROR${Font}]"
Time=$(date +"%Y-%m-%d %T")
function INFO() {
echo -e "${Time} ${INFO} ${1}"
}
function ERROR() {
echo -e "${Time} ${ERROR} ${1}"
}
# 弃用此脚本
if [ -n "$(date)" ]; then
ERROR "此脚本已弃用!"
exit 0
fi
files=(tvbox.zip update.zip index.zip)
base_urls=(
"https://gitlab.com/xiaoyaliu/data/-/raw/main/"
"https://raw.githubusercontent.com/xiaoyaliu00/data/main/"
"https://cdn.wygg.shop/https://raw.githubusercontent.com/xiaoyaliu00/data/main"
"https://fastly.jsdelivr.net/gh/xiaoyaliu00/data@latest/"
"https://521github.com/extdomains/github.com/xiaoyaliu00/data/raw/main/"
"https://cors.zme.ink/https://raw.githubusercontent.com/xiaoyaliu00/data/main/"
"https://git.jasonml.xyz/https://raw.githubusercontent.com/xiaoyaliu00/data/main/"
"https://cdn.wygg.shop/https://raw.githubusercontent.com/xiaoyaliu00/data/main/"
"https://gh.ddlc.top/https://raw.githubusercontent.com/xiaoyaliu00/data/main/"
"https://git.886.be/https://raw.githubusercontent.com/xiaoyaliu00/data/main/"
"https://gh.idayer.com/https://raw.githubusercontent.com/xiaoyaliu00/data/main/"
"https://slink.ltd/https://raw.githubusercontent.com/xiaoyaliu00/data/main/"
)
if [ -z "${1}" ]; then
ERROR "请配置小雅Alist配置文件目录后重试!"
exit 1
else
data_dir="${1}/data"
fi
if [ -f "${data_dir}/version.txt" ]; then
OLD_VERSION=$(cat "${data_dir}"/version.txt)
INFO "本地数据版本:${OLD_VERSION}"
else
OLD_VERSION=none
fi
for base_url in "${base_urls[@]}"; do
if curl --insecure -fsSL -o "${data_dir}/version.txt" "${base_url}version.txt"; then
available_url=${base_url}
NEW_VERSION=$(cat "${data_dir}"/version.txt)
INFO "远端数据版本:${NEW_VERSION}"
break
fi
done
if [ "${OLD_VERSION}" != "${NEW_VERSION}" ]; then
for file in "${files[@]}"; do
if curl --insecure -fsSL -o "${data_dir}/${file}" "${available_url}${file}"; then
INFO "$available_url$file 更新成功!"
else
ERROR "$available_url$file 更新失败!"
fi
done
else
INFO "无需更新,跳过下载!"
fi