Skip to content

Commit 1d4a3bc

Browse files
committed
fix: emby server address cannot be connected
1 parent 530a115 commit 1d4a3bc

File tree

1 file changed

+29
-19
lines changed

1 file changed

+29
-19
lines changed

all_in_one.sh

+29-19
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ GLOBAL_UA_2="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML
9999
QUARK_UA="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) quark-cloud-drive/2.5.20 Chrome/100.0.4896.160 Electron/18.3.5.4-b478491100 Safari/537.36 Channel/pckk_other_ch"
100100
UC_UA="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) uc-cloud-drive/2.5.20 Chrome/100.0.4896.160 Electron/18.3.5.4-b478491100 Safari/537.36 Channel/pckk_other_ch"
101101

102+
ALL_METADATA_FILES=("all.mp4" "config.mp4" "115.mp4")
103+
102104
function get_default_network() {
103105

104106
_default_network=$(cat "${DDSREM_CONFIG_DIR}/default_network.txt")
@@ -1875,18 +1877,28 @@ function get_emby_version() {
18751877

18761878
}
18771879

1878-
function set_emby_server_infuse_api_key() {
1880+
function set_emby_server() {
18791881

18801882
get_docker0_url
1883+
if [[ "${OSNAME}" = "macos" ]]; then
1884+
local_ip=$(ifconfig "$(route -n get default | grep interface | awk -F ':' '{print$2}' | awk '{$1=$1};1')" | grep 'inet ' | awk '{print$2}')
1885+
else
1886+
local_ip=$(ip address | grep inet | grep -v 172.17 | grep -v 127.0.0.1 | grep -v inet6 | awk '{print $2}' | sed 's/addr://' | head -n1 | cut -f1 -d"/")
1887+
fi
18811888

1882-
echo "http://$docker0:6908" > "${CONFIG_DIR}"/emby_server.txt
1883-
auto_chown "${CONFIG_DIR}/emby_server.txt"
1884-
1885-
if [ ! -f "${CONFIG_DIR}"/infuse_api_key.txt ]; then
1886-
echo "e825ed6f7f8f44ffa0563cddaddce14d" > "${CONFIG_DIR}"/infuse_api_key.txt
1887-
auto_chown "${CONFIG_DIR}/infuse_api_key.txt"
1889+
if docker exec -i "$(cat ${DDSREM_CONFIG_DIR}/container_name/xiaoya_alist_name.txt)" curl -I -s "http://127.0.0.1:6908" | grep -m1 "^HTTP/" | grep -q "302"; then
1890+
INFO "使用 127.0.0.1 IP 配置 emby_server.txt"
1891+
echo "http://127.0.0.1:6908" > "${CONFIG_DIR}"/emby_server.txt
1892+
elif docker exec -i "$(cat ${DDSREM_CONFIG_DIR}/container_name/xiaoya_alist_name.txt)" curl -I -s "http://$docker0:6908" | grep -m1 "^HTTP/" | grep -q "302"; then
1893+
INFO "使用 $docker0 IP 配置 emby_server.txt"
1894+
echo "http://$docker0:6908" > "${CONFIG_DIR}"/emby_server.txt
1895+
else
1896+
INFO "使用 $local_ip IP 配置 emby_server.txt"
1897+
echo "http://$local_ip:6908" > "${CONFIG_DIR}"/emby_server.txt
18881898
fi
18891899

1900+
auto_chown "${CONFIG_DIR}/emby_server.txt"
1901+
18901902
}
18911903

18921904
function check_metadata_size() {
@@ -2034,8 +2046,7 @@ function __unzip_metadata() {
20342046
start_time1=$(date +%s)
20352047

20362048
if [ "${1}" == "all_metadata" ]; then
2037-
local files=("all.mp4" "config.mp4" "115.mp4")
2038-
for file in "${files[@]}"; do
2049+
for file in "${ALL_METADATA_FILES[@]}"; do
20392050
metadata_unziper "${file}"
20402051
done
20412052
INFO "设置目录权限..."
@@ -2126,8 +2137,7 @@ function __download_metadata() {
21262137
}
21272138

21282139
if [ "${1}" == "all_metadata" ]; then
2129-
local files=("all.mp4" "config.mp4" "115.mp4")
2130-
for file in "${files[@]}"; do
2140+
for file in "${ALL_METADATA_FILES[@]}"; do
21312141
metadata_downloader "${file}"
21322142
done
21332143

@@ -2169,8 +2179,6 @@ function unzip_xiaoya_all_emby() {
21692179

21702180
__unzip_metadata "all_metadata"
21712181

2172-
set_emby_server_infuse_api_key
2173-
21742182
INFO "解压完成!"
21752183

21762184
}
@@ -2409,8 +2417,7 @@ function download_unzip_xiaoya_all_emby() {
24092417
auto_chown "${MEDIA_DIR}/temp"
24102418
chmod 777 "${MEDIA_DIR}"
24112419

2412-
local files=("all.mp4" "config.mp4" "115.mp4")
2413-
for file in "${files[@]}"; do
2420+
for file in "${ALL_METADATA_FILES[@]}"; do
24142421
if [ -f "${MEDIA_DIR}/temp/${file}.aria2" ]; then
24152422
rm -rf "${MEDIA_DIR}/temp/${file}.aria2"
24162423
fi
@@ -2422,8 +2429,6 @@ function download_unzip_xiaoya_all_emby() {
24222429

24232430
__unzip_metadata "all_metadata"
24242431

2425-
set_emby_server_infuse_api_key
2426-
24272432
INFO "刮削数据已经下载解压完成!"
24282433

24292434
}
@@ -3245,13 +3250,18 @@ function install_emby_xiaoya_all_emby() {
32453250

32463251
fi
32473252

3248-
set_emby_server_infuse_api_key
3253+
if [ ! -f "${CONFIG_DIR}"/infuse_api_key.txt ]; then
3254+
echo "e825ed6f7f8f44ffa0563cddaddce14d" > "${CONFIG_DIR}"/infuse_api_key.txt
3255+
auto_chown "${CONFIG_DIR}/infuse_api_key.txt"
3256+
fi
32493257

32503258
wait_emby_start
32513259

32523260
sleep 2
32533261

3254-
if ! curl -I -s http://$docker0:2345/ | grep -q "302"; then
3262+
set_emby_server
3263+
3264+
if ! docker exec -i "$(cat ${DDSREM_CONFIG_DIR}/container_name/xiaoya_alist_name.txt)" curl -I -s http://127.0.0.1:2345/ | grep -q "302"; then
32553265
INFO "重启小雅容器中..."
32563266
docker restart "$(cat ${DDSREM_CONFIG_DIR}/container_name/xiaoya_alist_name.txt)"
32573267
wait_xiaoya_start

0 commit comments

Comments
 (0)