Skip to content

Commit

Permalink
fix: database
Browse files Browse the repository at this point in the history
Update arguments-builder.config.ts
Update boxjs.settings.json
Update CHANGELOG.md
Update request.dev.js
Update database.mjs
Update request.js
  • Loading branch information
VirgilClyne committed Dec 27, 2024
1 parent 2719f2e commit 3f6f2a6
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 65 deletions.
13 changes: 3 additions & 10 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
### 🛠️ Bug Fixes
* 修复 `$argument``$persistentStore` 载入顺序颠倒的问题
* 正确顺序为先读取 `$argument` 再读取 `$persistentStore (BoxJs)`
* 即,有相同键名时,`$persistentStore (BoxJs)` 的值会覆盖 `$argument` 的值
* 修复`体育节目`分区页面加载问题
* 修复`儿童`分区页面加载问题
* 更新`商店`分区页面标签页

### 🔣 Dependencies
* 升级了 `@nsnanocat/util`
* `util``submodule` 更改为 `package`
* `$platform` 改为 `$app`
* 使用了全新的 `Console` polyfill
* 升级了 `@nsnanocat/url`
* 使用了全新的 `URL``URLSearchParams` polyfill

### 🔄 Other Changes
* 打包器由 `rollup` 更改为 `rspack`
2 changes: 1 addition & 1 deletion arguments-builder.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export default defineConfig({
defaultValue: "WARN",
description: "选择脚本日志的输出等级,低于所选等级的日志将全部输出。",
options: [
{ key: "OFF", label: "关闭" },
{ key: "OFF", label: "🔴 关闭" },
{ key: "ERROR", label: "❌ 错误" },
{ key: "WARN", label: "⚠️ 警告" },
{ key: "INFO", label: "ℹ️ 信息" },
Expand Down
59 changes: 31 additions & 28 deletions src/function/database.mjs

Large diffs are not rendered by default.

34 changes: 20 additions & 14 deletions src/request.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Console.info(`FORMAT: ${FORMAT}`);
// 解析参数
const StoreFront = url.searchParams.get("sf");
const Locale = ($request.headers?.["X-Apple-I-Locale"] ?? $request.headers?.["x-apple-i-locale"])?.split("_")?.[0] ?? "zh";
Console.debug(`StoreFront = ${StoreFront}`, `Locale = ${Locale}`);
Console.info(`StoreFront: ${StoreFront}`, `Locale: ${Locale}`);
// 创建空数据
let body = {};
// 设置默认类型
Expand Down Expand Up @@ -139,18 +139,18 @@ Console.info(`FORMAT: ${FORMAT}`);
// 主机判断
switch (url.hostname) {
case "uts-api.itunes.apple.com": {
const Version = Number.parseInt(url.searchParams.get("v"), 10),
const Caller = url.searchParams.get("caller"),
Platform = url.searchParams.get("pfm"),
Caller = url.searchParams.get("caller");
Console.debug(`Version = ${Version}`, `Platform = ${Platform}`, `Caller = ${Caller}`);
Version = Number.parseInt(url.searchParams.get("v"), 10);
Console.info(`Caller: ${Caller}`, `Platform: ${Platform}`, `Version: ${Version}`);
// 路径判断
switch (url.pathname) {
case "/uts/v3/configurations": {
Type = "Configs";
const Region = url.searchParams.get("region"),
Country = url.searchParams.get("country"),
StoreFrontH = url.searchParams.get("sfh");
Console.debug(`Region = ${Region}`, `Country = ${Country}`, `StoreFrontH = ${StoreFrontH}`);
Console.info(`Region: ${Region}`, `Country: ${Country}`, `StoreFrontH: ${StoreFrontH}`);
if (Settings.CountryCode[Type] !== "AUTO") {
if (Region) url.searchParams.set("region", Settings.CountryCode[Type] ?? Region);
if (Country) url.searchParams.set("country", Settings.CountryCode[Type] ?? Country);
Expand All @@ -165,7 +165,7 @@ Console.info(`FORMAT: ${FORMAT}`);
case "/uts/v3/canvases/roots/tahoma_watchnow":
case "/uts/v3/shelves/uts.col.UpNext":
Type = "WatchNow";
if (Settings.ThirdParty) url.searchParams.set("pfm", Platform === "desktop" ? "appletv" : Platform);
if (Settings.ThirdParty) if (Platform === "desktop") url.searchParams.set("pfm", "appletv");
break;
case "/uts/v3/canvases/Channels/tvs.sbd.4000":
case "/uts/v3/shelves/uts.col.ChannelUpNext.tvs.sbd.4000":
Expand All @@ -182,6 +182,7 @@ Console.info(`FORMAT: ${FORMAT}`);
Type = "Channels";
break;
case "/uts/v3/canvases/Roots/sports":
case "/uts/v3/canvases/Roots/tahoma_sports":
case "/uts/v3/shelves/uts.col.PersonalizedLiveSports":
case "/uts/v3/clock-scores":
case "/uts/v3/leagues":
Expand All @@ -195,23 +196,28 @@ Console.info(`FORMAT: ${FORMAT}`);
case "/uts/v3/canvases/Rooms/edt.item.635968ac-89d7-4619-8f5d-8c7890aef813": // NFL THANKSGIVING 2022
case "/uts/v3/canvases/Rooms/edt.item.62327df1-6874-470e-98b2-a5bbeac509a2": // Friday Night Baseball - MLB - Apple TV+
Type = "Sports";
//if (Settings["ThirdParty"])
url.searchParams.set("pfm", Platform === "desktop" ? "ipad" : Platform);
if (Platform === "desktop") url.searchParams.set("pfm", "ipad");
break;
case "/uts/v3/canvases/Roots/kids":
case "/uts/v3/canvases/Roots/tahoma_kids":
Type = "Kids";
//if (Platform === "desktop") url.searchParams.set("caller", "js");
break;
case "/uts/v3/canvases/Roots/kids/tahoma_kids":
Type = "Kids";
url.pathname = "/uts/v3/canvases/Roots/tahoma_kids";
break;
case "/uts/v3/canvases/Roots/store":
case "/uts/v3/canvases/Roots/tahoma_store":
Type = "Store";
break;
case "/uts/v3/canvases/Roots/movies":
Type = "Movies";
if (Settings.ThirdParty) url.searchParams.set("pfm", Platform === "desktop" ? "ipad" : Platform);
if (Settings.ThirdParty) if (Platform === "desktop") url.searchParams.set("pfm", "ipad");
break;
case "/uts/v3/canvases/Roots/tv":
Type = "TV";
if (Settings.ThirdParty) url.searchParams.set("pfm", Platform === "desktop" ? "ipad" : Platform);
if (Settings.ThirdParty) if (Platform === "desktop") url.searchParams.set("pfm", "ipad");
break;
case "/uts/v3/favorite-people":
case "/uts/v3/favorite-teams":
Expand All @@ -230,7 +236,7 @@ Console.info(`FORMAT: ${FORMAT}`);
case "/uts/v3/watchlist":
case "/uts/v2/watchlist/contains":
case "/uts/v2/watchlist/search":
if (Settings.ThirdParty) url.searchParams.set("pfm", Platform === "desktop" ? "ipad" : Platform);
if (Settings.ThirdParty) if (Platform === "desktop") url.searchParams.set("pfm", "ipad");
break;
default:
//if (Settings["ThirdParty"]) url.searchParams.set("pfm", (Platform === "desktop") ? "ipad" : Platform);
Expand All @@ -242,11 +248,11 @@ Console.info(`FORMAT: ${FORMAT}`);
else if (url.pathname.includes("/uts/v3/sporting-events/")) {
Type = "Sports";
//if (Settings["ThirdParty"])
url.searchParams.set("pfm", Platform === "desktop" ? "ipad" : Platform);
if (Platform === "desktop") url.searchParams.set("pfm", "ipad");
} else if (url.pathname.includes("/uts/v3/canvases/Sports/")) {
Type = "Sports";
//if (Settings["ThirdParty"])
url.searchParams.set("pfm", Platform === "desktop" ? "ipad" : Platform);
if (Platform === "desktop") url.searchParams.set("pfm", "ipad");
} else if (url.pathname.includes("/uts/v3/canvases/Persons/")) Type = "Persons";
else if (url.pathname.includes("/uts/v3/canvases/Rooms/")) Type = "Others";
//else if (url.pathname.includes("/uts/v3/playables/")) Type = "Others";
Expand Down Expand Up @@ -297,7 +303,7 @@ Console.info(`FORMAT: ${FORMAT}`);
if ($request.headers?.["x-apple-store-front"]) $request.headers["x-apple-store-front"] = Configs.Storefront[Settings.CountryCode[Type]] ? $request.headers["x-apple-store-front"].replace(/\d{6}/, Configs.Storefront[Settings.CountryCode[Type]]) : $request.headers["x-apple-store-front"];
if (StoreFront) url.searchParams.set("sf", Configs.Storefront[Settings.CountryCode[Type]] ?? StoreFront);
if (Locale) url.searchParams.set("locale", Configs.Locale.get(Settings.CountryCode[Type]) ?? Locale);
Console.debug(`StoreFront = ${url.searchParams.get("sf")}`, `Locale = ${url.searchParams.get("locale")}`);
Console.info(`StoreFront: ${url.searchParams.get("sf")}`, `Locale = ${url.searchParams.get("locale")}`);
$request.url = url.toString();
Console.debug(`$request.url: ${$request.url}`);
})()
Expand Down
34 changes: 23 additions & 11 deletions src/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Console.info(`FORMAT: ${FORMAT}`);
// 解析参数
const StoreFront = url.searchParams.get("sf");
const Locale = ($request.headers?.["X-Apple-I-Locale"] ?? $request.headers?.["x-apple-i-locale"])?.split("_")?.[0] ?? "zh";
Console.debug(`StoreFront = ${StoreFront}`, `Locale = ${Locale}`);
Console.info(`StoreFront: ${StoreFront}`, `Locale: ${Locale}`);
// 创建空数据
let body = {};
// 设置默认类型
Expand Down Expand Up @@ -96,6 +96,7 @@ Console.info(`FORMAT: ${FORMAT}`);
switch (url.pathname) {
case "/uts/v3/user/settings":
Type = "Settings";
Console.debug(JSON.stringify(body));
break;
}
break;
Expand All @@ -105,6 +106,7 @@ Console.info(`FORMAT: ${FORMAT}`);
case "/v3/channels/scoreboard":
case "/v3/channels/scoreboard/":
Type = "Sports";
Console.debug(JSON.stringify(body));
break;
}
break;
Expand All @@ -128,16 +130,18 @@ Console.info(`FORMAT: ${FORMAT}`);
// 主机判断
switch (url.hostname) {
case "uts-api.itunes.apple.com": {
const Version = Number.parseInt(url.searchParams.get("v"), 10),
const Caller = url.searchParams.get("caller"),
Platform = url.searchParams.get("pfm"),
Caller = url.searchParams.get("caller");
Version = Number.parseInt(url.searchParams.get("v"), 10);
Console.info(`Caller: ${Caller}`, `Platform: ${Platform}`, `Version: ${Version}`);
// 路径判断
switch (url.pathname) {
case "/uts/v3/configurations": {
Type = "Configs";
const Region = url.searchParams.get("region"),
Country = url.searchParams.get("country"),
StoreFrontH = url.searchParams.get("sfh");
Console.info(`Region: ${Region}`, `Country: ${Country}`, `StoreFrontH: ${StoreFrontH}`);
if (Settings.CountryCode[Type] !== "AUTO") {
if (Region) url.searchParams.set("region", Settings.CountryCode[Type] ?? Region);
if (Country) url.searchParams.set("country", Settings.CountryCode[Type] ?? Country);
Expand All @@ -152,7 +156,7 @@ Console.info(`FORMAT: ${FORMAT}`);
case "/uts/v3/canvases/roots/tahoma_watchnow":
case "/uts/v3/shelves/uts.col.UpNext":
Type = "WatchNow";
if (Settings.ThirdParty) url.searchParams.set("pfm", Platform === "desktop" ? "appletv" : Platform);
if (Settings.ThirdParty) if (Platform === "desktop") url.searchParams.set("pfm", "appletv");
break;
case "/uts/v3/canvases/Channels/tvs.sbd.4000":
case "/uts/v3/shelves/uts.col.ChannelUpNext.tvs.sbd.4000":
Expand All @@ -169,6 +173,7 @@ Console.info(`FORMAT: ${FORMAT}`);
Type = "Channels";
break;
case "/uts/v3/canvases/Roots/sports":
case "/uts/v3/canvases/Roots/tahoma_sports":
case "/uts/v3/shelves/uts.col.PersonalizedLiveSports":
case "/uts/v3/clock-scores":
case "/uts/v3/leagues":
Expand All @@ -182,23 +187,28 @@ Console.info(`FORMAT: ${FORMAT}`);
case "/uts/v3/canvases/Rooms/edt.item.635968ac-89d7-4619-8f5d-8c7890aef813": // NFL THANKSGIVING 2022
case "/uts/v3/canvases/Rooms/edt.item.62327df1-6874-470e-98b2-a5bbeac509a2": // Friday Night Baseball - MLB - Apple TV+
Type = "Sports";
//if (Settings["ThirdParty"])
url.searchParams.set("pfm", Platform === "desktop" ? "ipad" : Platform);
if (Platform === "desktop") url.searchParams.set("pfm", "ipad");
break;
case "/uts/v3/canvases/Roots/kids":
case "/uts/v3/canvases/Roots/tahoma_kids":
Type = "Kids";
//if (Platform === "desktop") url.searchParams.set("caller", "js");
break;
case "/uts/v3/canvases/Roots/kids/tahoma_kids":
Type = "Kids";
url.pathname = "/uts/v3/canvases/Roots/tahoma_kids";
break;
case "/uts/v3/canvases/Roots/store":
case "/uts/v3/canvases/Roots/tahoma_store":
Type = "Store";
break;
case "/uts/v3/canvases/Roots/movies":
Type = "Movies";
if (Settings.ThirdParty) url.searchParams.set("pfm", Platform === "desktop" ? "ipad" : Platform);
if (Settings.ThirdParty) if (Platform === "desktop") url.searchParams.set("pfm", "ipad");
break;
case "/uts/v3/canvases/Roots/tv":
Type = "TV";
if (Settings.ThirdParty) url.searchParams.set("pfm", Platform === "desktop" ? "ipad" : Platform);
if (Settings.ThirdParty) if (Platform === "desktop") url.searchParams.set("pfm", "ipad");
break;
case "/uts/v3/favorite-people":
case "/uts/v3/favorite-teams":
Expand All @@ -217,7 +227,7 @@ Console.info(`FORMAT: ${FORMAT}`);
case "/uts/v3/watchlist":
case "/uts/v2/watchlist/contains":
case "/uts/v2/watchlist/search":
if (Settings.ThirdParty) url.searchParams.set("pfm", Platform === "desktop" ? "ipad" : Platform);
if (Settings.ThirdParty) if (Platform === "desktop") url.searchParams.set("pfm", "ipad");
break;
default:
//if (Settings["ThirdParty"]) url.searchParams.set("pfm", (Platform === "desktop") ? "ipad" : Platform);
Expand All @@ -229,11 +239,11 @@ Console.info(`FORMAT: ${FORMAT}`);
else if (url.pathname.includes("/uts/v3/sporting-events/")) {
Type = "Sports";
//if (Settings["ThirdParty"])
url.searchParams.set("pfm", Platform === "desktop" ? "ipad" : Platform);
if (Platform === "desktop") url.searchParams.set("pfm", "ipad");
} else if (url.pathname.includes("/uts/v3/canvases/Sports/")) {
Type = "Sports";
//if (Settings["ThirdParty"])
url.searchParams.set("pfm", Platform === "desktop" ? "ipad" : Platform);
if (Platform === "desktop") url.searchParams.set("pfm", "ipad");
} else if (url.pathname.includes("/uts/v3/canvases/Persons/")) Type = "Persons";
else if (url.pathname.includes("/uts/v3/canvases/Rooms/")) Type = "Others";
//else if (url.pathname.includes("/uts/v3/playables/")) Type = "Others";
Expand Down Expand Up @@ -284,7 +294,9 @@ Console.info(`FORMAT: ${FORMAT}`);
if ($request.headers?.["x-apple-store-front"]) $request.headers["x-apple-store-front"] = Configs.Storefront[Settings.CountryCode[Type]] ? $request.headers["x-apple-store-front"].replace(/\d{6}/, Configs.Storefront[Settings.CountryCode[Type]]) : $request.headers["x-apple-store-front"];
if (StoreFront) url.searchParams.set("sf", Configs.Storefront[Settings.CountryCode[Type]] ?? StoreFront);
if (Locale) url.searchParams.set("locale", Configs.Locale.get(Settings.CountryCode[Type]) ?? Locale);
Console.info(`StoreFront: ${url.searchParams.get("sf")}`, `Locale = ${url.searchParams.get("locale")}`);
$request.url = url.toString();
Console.debug(`$request.url: ${$request.url}`);
})()
.catch(e => Console.error(e))
.finally(() => {
Expand Down
2 changes: 1 addition & 1 deletion template/boxjs.settings.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"id":"@iRingo.TV.Settings.ThirdParty","name":"启用第三方 App 与 TV app 关联功能","type":"boolean","val":false,"desc":"是否将桌面版/macOS版/app版等平台的 TV app 转换至 iPad 版,以启用第三方 App 与 TV app 关联功能(如: Disney+, Prime Video 等)。"},{"id":"@iRingo.TV.Settings.HLSUrl","name":"[主机名] HTTP实时流(HLS)地址","type":"selects","val":"play-edge.itunes.apple.com","items":[{"key":"","label":"OFF(不修改)"},{"key":"play.itunes.apple.com","label":"play.itunes.apple.com (不推荐,与播放服务域名重叠)"},{"key":"play-edge.itunes.apple.com","label":"play-edge.itunes.apple.com (默认)"}],"desc":"因为FPS服务域名禁止MitM,修改此地址可以分离HLS与FPS的域名,从而恢复对DualSubs的双语字幕支持。"},{"id":"@iRingo.TV.Settings.FPSUrl","name":"[主机名] FairPlay流(FPS)地址","type":"selects","val":"play.itunes.apple.com","items":[{"key":"","label":"OFF(不修改)"},{"key":"play.itunes.apple.com","label":"play.itunes.apple.com (默认)"},{"key":"play-edge.itunes.apple.com","label":"play-edge.itunes.apple.com (不推荐,与播放服务域名重叠)"}],"desc":"因为FPS服务域名禁止MitM,修改此地址可以分离HLS与FPS的域名,从而恢复对DualSubs的双语字幕支持。"},{"id":"@iRingo.TV.Settings.LogLevel","name":"[调试] 日志等级","type":"selects","val":"WARN","items":[{"key":"OFF","label":"关闭"},{"key":"ERROR","label":"❌ 错误"},{"key":"WARN","label":"⚠️ 警告"},{"key":"INFO","label":"ℹ️ 信息"},{"key":"DEBUG","label":"🅱️ 调试"},{"key":"ALL","label":"全部"}],"desc":"选择脚本日志的输出等级,低于所选等级的日志将全部输出。"}]
[{"id":"@iRingo.TV.Settings.ThirdParty","name":"启用第三方 App 与 TV app 关联功能","type":"boolean","val":false,"desc":"是否将桌面版/macOS版/app版等平台的 TV app 转换至 iPad 版,以启用第三方 App 与 TV app 关联功能(如: Disney+, Prime Video 等)。"},{"id":"@iRingo.TV.Settings.HLSUrl","name":"[主机名] HTTP实时流(HLS)地址","type":"selects","val":"play-edge.itunes.apple.com","items":[{"key":"","label":"OFF(不修改)"},{"key":"play.itunes.apple.com","label":"play.itunes.apple.com (不推荐,与播放服务域名重叠)"},{"key":"play-edge.itunes.apple.com","label":"play-edge.itunes.apple.com (默认)"}],"desc":"因为FPS服务域名禁止MitM,修改此地址可以分离HLS与FPS的域名,从而恢复对DualSubs的双语字幕支持。"},{"id":"@iRingo.TV.Settings.FPSUrl","name":"[主机名] FairPlay流(FPS)地址","type":"selects","val":"play.itunes.apple.com","items":[{"key":"","label":"OFF(不修改)"},{"key":"play.itunes.apple.com","label":"play.itunes.apple.com (默认)"},{"key":"play-edge.itunes.apple.com","label":"play-edge.itunes.apple.com (不推荐,与播放服务域名重叠)"}],"desc":"因为FPS服务域名禁止MitM,修改此地址可以分离HLS与FPS的域名,从而恢复对DualSubs的双语字幕支持。"},{"id":"@iRingo.TV.Settings.LogLevel","name":"[调试] 日志等级","type":"selects","val":"WARN","items":[{"key":"OFF","label":"🔴 关闭"},{"key":"ERROR","label":"❌ 错误"},{"key":"WARN","label":"⚠️ 警告"},{"key":"INFO","label":"ℹ️ 信息"},{"key":"DEBUG","label":"🅱️ 调试"},{"key":"ALL","label":"全部"}],"desc":"选择脚本日志的输出等级,低于所选等级的日志将全部输出。"}]

0 comments on commit 3f6f2a6

Please sign in to comment.