添加泰区 web subtitle 支持

pull/26/head
david082321 3 years ago
parent 6b221cdeaa
commit 6ffd53cf8a

@ -79,7 +79,8 @@ define('CUSTOM_HOST_TW_WEB_SEARCH', 'https://api.bilibili.com'); // TW 搜索api
// API相关(东南亚服务器)
define('CUSTOM_HOST_TH', 'https://app.biliintl.com'); // 泰区 解析api
define('CUSTOM_HOST_TH_SEARCH', 'https://app.biliintl.com'); // 泰区 搜索api
define('CUSTOM_HOST_TH_SUB', 'https://api.bilibili.tv'); // 泰区 字幕api
define('CUSTOM_HOST_TH_SUB', 'https://app.biliintl.com'); // 泰区 字幕api
define('CUSTOM_HOST_TH_WEBSUB', 'https://api.bilibili.tv'); // 泰区 字幕api
define('CUSTOM_HOST_TH_TOKEN', 'https://passport.biliintl.com'); // 泰区 刷新TOKEN api
// 自定义API,避免集中请求,降低风控几率

@ -0,0 +1,37 @@
<?php
// 分类
$type = 0;
$cache_type = "app";
// 加载配置
include ($_SERVER['DOCUMENT_ROOT']."/config.php");
// 加载版本
include(ROOT_PATH."utils/version.php");
// 加载functions
include (ROOT_PATH."utils/functions.php");
// 处理用户传入参数
include (ROOT_PATH."utils/process.php");
// 设置host
$host = CUSTOM_HOST_TH_SEARCH;
// 锁区、web接口、X-From-Biliroaming
include (ROOT_PATH."utils/lock_area.php");
// 鉴权、替换access_key、获取缓存
//// (无)
// 指定ip回源
if (IP_RESOLVE == 1) {
$host = $hosts[array_rand($hosts)];
$ip = $ips[array_rand($ips)];
}
// 转发到指定服务器
$url = $host.$path."?".$query;
if (IP_RESOLVE == 1) {
$output = get_webpage($url,$host,$ip);
} else {
$output = get_webpage($url);
}
// 替换内容
include (ROOT_PATH."utils/replace.php");
// 返回内容给用户
print($output);
// 写入缓存
//// (无)
?>

@ -0,0 +1,47 @@
<?php
// 分类
$type = 3;
$cache_type = "web";
// 加载配置
include ($_SERVER['DOCUMENT_ROOT']."/config.php");
// 加载版本
include(ROOT_PATH."utils/version.php");
// 加载functions
include (ROOT_PATH."utils/functions.php");
if (SAVE_CACHE == 1) {
include (ROOT_PATH."utils/functions_cache.php");
}
// 处理用户传入参数
include (ROOT_PATH."utils/process.php");
// 设置host
$host = CUSTOM_HOST_TH_WEBSUB;
// 锁区、web接口、X-From-Biliroaming
//// (无)
// 鉴权、替换access_key、获取缓存
if ($baned == 1) {
block();
}
if (SAVE_CACHE == 1) {
get_cache_subtitle(); // 获取缓存
}
// 指定ip回源
if (IP_RESOLVE == 1) {
$host = $hosts[array_rand($hosts)];
$ip = $ips[array_rand($ips)];
}
// 转发到指定服务器
$url = $host.$path."?".$query;
if (IP_RESOLVE == 1) {
$output = get_webpage($url,$host,$ip);
} else {
$output = get_webpage($url);
}
// 替换内容
include (ROOT_PATH."utils/replace.php");
// 返回内容给用户
print($output);
// 写入缓存
if (SAVE_CACHE == 1) {
write_cache_subtitle(); // 写入东南亚subtitle
}
?>

@ -313,6 +313,7 @@ function write_cache_season() {
// 获取subtitle缓存
function get_cache_subtitle() {
global $dbh;
global $cache_type;
global $refresh_cache_subtitle;
if (AREA == "th") {
@ -321,7 +322,7 @@ function get_cache_subtitle() {
$area = "main"; //主站
}
if (EP_ID != "") {
$sqlco = "SELECT `expired_time`,`cid`,`cache` FROM `cache` WHERE `area` = '".$area."' AND `cache_type` = 'subtitle' AND `ep_id` = '".EP_ID."'";
$sqlco = "SELECT `expired_time`,`cid`,`cache` FROM `cache` WHERE `area` = '".$area."' AND `cache_type` = 'subtitle_".$cache_type."' AND `ep_id` = '".EP_ID."'";
} else {
return "";
}
@ -357,6 +358,7 @@ function get_cache_subtitle() {
function write_cache_subtitle() {
global $dbh;
global $output;
global $cache_type;
global $refresh_cache_subtitle;
if (EP_ID == "") {
@ -367,7 +369,7 @@ function write_cache_subtitle() {
} else {
$area = "main"; //主站
}
$sqlco = "SELECT `cid` FROM `cache` WHERE `area` = '".$area."' AND `cache_type` = 'subtitle' AND `ep_id` = '".EP_ID."'";
$sqlco = "SELECT `cid` FROM `cache` WHERE `area` = '".$area."' AND `cache_type` = 'subtitle_".$cache_type."' AND `ep_id` = '".EP_ID."'";
$cres = $dbh -> query($sqlco);
$vnum = $cres -> fetch();
if (!$vnum) {
@ -397,10 +399,10 @@ function write_cache_subtitle() {
default:
$ts = $ts + CACHE_TIME_OTHER;
}
$sql = "INSERT INTO `cache` (`expired_time`,`area`,`type`,`cache_type`,`cid`,`ep_id`,`cache`) VALUES ('".$ts."','".AREA."','0','subtitle','0','".EP_ID."','".$output."')";
$sql = "INSERT INTO `cache` (`expired_time`,`area`,`type`,`cache_type_".$cache_type."`,`cid`,`ep_id`,`cache`) VALUES ('".$ts."','".AREA."','0','subtitle','0','".EP_ID."','".$output."')";
// 刷新缓存
if ($refresh_cache_subtitle == 1) {
$sql = "UPDATE `cache` SET `expired_time` = '".$ts."', `cache` = '".$output."' WHERE `area` = '".AREA."' AND `cache_type` = 'subtitle' AND `ep_id` = '".EP_ID."';";
$sql = "UPDATE `cache` SET `expired_time` = '".$ts."', `cache` = '".$output."' WHERE `area` = '".AREA."' AND `cache_type` = 'subtitle_".$cache_type."' AND `ep_id` = '".EP_ID."';";
}
$dbh -> exec($sql);
}

@ -13,13 +13,14 @@ define('SS_ID', @$_GET['season_id']);
define('QN', @$_GET['qn']);
define('BILIROAMING_VERSION', @$_SERVER['HTTP_X_FROM_BILIROAMING']);
$baned = 0;
$th_paths = array("/intl/gateway/v2/app/search/type","/intl/gateway/v2/app/search/v2","/intl/gateway/v2/app/subtitle","/intl/gateway/web/v2/subtitle","/intl/gateway/v2/ogv/view/app/season","/intl/gateway/v2/ogv/view/app/season2","/intl/gateway/v2/ogv/playurl");
if (BILIROAMING_VERSION == '') {
if (BILIROAMING == 1 && WEB_ON == 0) { //仅限漫游用户且未开放web脚本
$baned = 10;
block($baned);
}
if (@$_GET['area'] == '' || @$_GET['area'] == 'false') { //web脚本,兼容泰区无area情况
if ($path == "/intl/gateway/v2/app/search/type" || $path == "/intl/gateway/v2/app/subtitle" || $path == "/intl/gateway/v2/ogv/view/app/season") {
if (in_array($path, $th_paths)) {
define('AREA', 'th');
} else {
define('AREA', 'noarea');
@ -28,7 +29,8 @@ if (BILIROAMING_VERSION == '') {
define('AREA', @$_GET['area']);
}
} else if (@$_GET['area'] == '') { //适配老漫游版本兼容泰区无area情况
if ($path == "/intl/gateway/v2/app/search/type" || $path == "/intl/gateway/v2/app/subtitle" || $path == "/intl/gateway/v2/ogv/view/app/season") {
if (in_array($path, $th_paths)) {
define('AREA', 'th');
} else {
define('AREA', 'oldversion');

Loading…
Cancel
Save