#!/bin/bash
export LANG=C.UTF-8


echo "----------------下载节点优选------------"
# 定义要测试的域名列表
domains=("https://cf.mb6.top" "http://xinjiawei.6655.la" "https://act.jiawei.xin:10086")
# 初始化 domain 变量
domain=""
# 遍历域名列表并测试可访问性
for url in "${domains[@]}"; do
  response=$(curl --write-out "%{http_code}" --silent --output /dev/null "$url")
  if [ "$response" -eq 200 ]; then
    domain="$url"
    echo "可访问的下载节点是: $url"
    break
  else
    echo "下载节点: $url 不可用,继续测试"
  fi
done
# 检查是否找到可访问的域名
if [ -z "$domain" ]; then
  echo "没有可访问的域名"
  exit 1
fi
main_domain=$domain"/tmp/emby"
echo "ubuntu一键**脚本，适4.7.0.60版本"
echo "-------------------web端**-------------------"
rm -f /opt/emby-server/system/Emby.Web.dll
wget -P /opt/emby-server/system/ "$main_domain/4.7.1.0/linux64_docker_4.7.1/Emby.Web.dll"
rm -f /opt/emby-server/system/MediaBrowser.Model.dll
wget -P /opt/emby-server/system/ "$main_domain/4.7.1.0/linux64_docker_4.7.1/MediaBrowser.Model.dll"
echo "核心**完成..."
rm -f /opt/emby-server/system/dashboard-ui/modules/emby-apiclient/connectionmanager.js
wget -P /opt/emby-server/system/dashboard-ui/modules/emby-apiclient/ "$main_domain/4.7.1.0/linux64_docker_4.7.1/dashboard-ui/modules/emby-apiclient/connectionmanager.js"
rm -f /opt/emby-server/system/dashboard-ui/embypremiere/embypremiere.js
wget -P /opt/emby-server/system/dashboard-ui/embypremiere/ "$main_domain/4.7.1.0/linux64_docker_4.7.1/dashboard-ui/embypremiere/embypremiere.js"
echo "web**完成..."
rm -f /opt/emby-server/system/Emby.Server.Implementations.dll
wget -P /opt/emby-server/system/ "$main_domain/4.7.1.0/linux64_docker_4.7.1/Emby.Server.Implementations.dll"
echo "Implementations替换认证..."
# "$main_domain/4.7.1.0/linux64_docker_4.7.1/dashboard-ui/devices/cameraupload.js
# "$main_domain/4.7.1.0/linux64_docker_4.7.1/dashboard-ui/livetvsetup/livetvstatus.js
# "$main_domain/4.7.1.0/linux64_docker_4.7.1/dashboard-ui/network/network.js
# "$main_domain/4.7.1.0/linux64_docker_4.7.1/dashboard-ui/settings/display.js
# "$main_domain/4.7.1.0/linux64_docker_4.7.1/dashboard-ui/transcoding/transcoding.js
echo "美化包替换"
rm -f /opt/emby-server/system/dashboard-ui/devices/cameraupload.js
wget -P /opt/emby-server/system/dashboard-ui/devices/ "$main_domain/4.7.1.0/linux64_docker_4.7.1/dashboard-ui/devices/cameraupload.js"
rm -f /opt/emby-server/system/dashboard-ui/livetvsetup/livetvstatus.js
wget -P /opt/emby-server/system/dashboard-ui/livetvsetup/ "$main_domain/4.7.1.0/linux64_docker_4.7.1/dashboard-ui/livetvsetup/livetvstatus.js"
rm -f /opt/emby-server/system/dashboard-ui/network/network.js
wget -P /opt/emby-server/system/dashboard-ui/network/ "$main_domain/4.7.1.0/linux64_docker_4.7.1/dashboard-ui/network/network.js"
rm -f /opt/emby-server/system/dashboard-ui/settings/display.js
wget -P /opt/emby-server/system/dashboard-ui/settings/ "$main_domain/4.7.1.0/linux64_docker_4.7.1/dashboard-ui/settings/display.js"
rm -f /opt/emby-server/system/dashboard-ui/transcoding/transcoding.js
wget -P /opt/emby-server/system/dashboard-ui/transcoding/ "$main_domain/4.7.1.0/linux64_docker_4.7.1/dashboard-ui/transcoding/transcoding.js"
echo "完成..."
rm -rf synology6-7crack_4.7.0.60.sh
echo "-------------------删除脚本，预防重运行出错-------------------"