#!/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 "docker一键**脚本，适4.8.8.0版本"
echo "-------------------web端**-------------------"
rm -f /system/Emby.Web.dll
wget -P /system/ "$main_domain/4.8.8.0/linux_32_64/Emby.Web.dll"
rm -f /system/MediaBrowser.Model.dll
wget -P /system/ "$main_domain/4.8.8.0/linux_32_64/MediaBrowser.Model.dll"
echo "核心**完成..."
rm -f /system/dashboard-ui/modules/emby-apiclient/connectionmanager.js
wget -P /system/dashboard-ui/modules/emby-apiclient/ "$main_domain/4.8.8.0/linux_32_64/dashboard-ui/modules/emby-apiclient/connectionmanager.js"
rm -f /system/dashboard-ui/embypremiere/embypremiere.js
wget -P /system/dashboard-ui/embypremiere/ "$main_domain/4.8.8.0/linux_32_64/dashboard-ui/embypremiere/embypremiere.js"
echo "web**完成..."
rm -f /system/Emby.Server.Implementations.dll
wget -P /system/ "$main_domain/4.8.8.0/linux_32_64/Emby.Server.Implementations.dll"
echo "Implementations替换认证..."
echo "全部完成"