#!/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 "群晖6.2.* Emby 套件版在线一键**脚本，适配4.6.7版本"
echo "即将弃用,请使用DSM6/7通用脚本 https://crackemby.mb6.top"
echo "即将弃用,请使用DSM6/7通用脚本 https://crackemby.mb6.top"
echo "即将弃用,请使用DSM6/7通用脚本 https://crackemby.mb6.top"
echo "即将弃用,请使用DSM6/7通用脚本 https://crackemby.mb6.top"
echo "即将弃用,请使用DSM6/7通用脚本 https://crackemby.mb6.top"
echo "即将弃用,请使用DSM6/7通用脚本 https://crackemby.mb6.top"
echo "即将弃用,请使用DSM6/7通用脚本 https://crackemby.mb6.top"
echo "即将弃用,请使用DSM6/7通用脚本 https://crackemby.mb6.top"
echo "即将弃用,请使用DSM6/7通用脚本 https://crackemby.mb6.top"
echo "即将弃用,请使用DSM6/7通用脚本 https://crackemby.mb6.top"
echo "即将弃用,请使用DSM6/7通用脚本 https://crackemby.mb6.top"
echo "即将弃用,请使用DSM6/7通用脚本 https://crackemby.mb6.top"
echo "即将弃用,请使用DSM6/7通用脚本 https://crackemby.mb6.top"
echo "-------------------web端**-------------------"
rm -f /var/packages/EmbyServer/target/system/Emby.Web.dll
wget -P /var/packages/EmbyServer/target/system/ "$main_domain/4.6.7.0/debian64-4.6.7/Emby.Web.dll"
rm -f /var/packages/EmbyServer/target/system/MediaBrowser.Model.dll
wget -P /var/packages/EmbyServer/target/system/ "$main_domain/4.6.7.0/debian64-4.6.7/MediaBrowser.Model.dll"
echo "web核心**完成..."
rm -f /var/packages/EmbyServer/target/system/dashboard-ui/bower_components/emby-apiclient/connectionmanager.js
wget -P /var/packages/EmbyServer/target/system/dashboard-ui/bower_components/emby-apiclient/ "$main_domain/4.6.7.0/debian64-4.6.7/connectionmanager.js"
rm -f /var/packages/EmbyServer/target/system/dashboard-ui/embypremiere/embypremiere.js
wget -P /var/packages/EmbyServer/target/system/dashboard-ui/embypremiere/ "$main_domain/4.6.7.0/debian64-4.6.7/embypremiere.js"
echo "web**完成..."
rm -f /var/packages/EmbyServer/target/system/Emby.Server.Implementations.dll
wget -P /var/packages/EmbyServer/target/system/ "$main_domain/4.6.7.0/debian64-4.6.7/Emby.Server.Implementations.dll"
echo "Implementations替换认证..."
echo "完成..."
