GUI-STUDIO commited on
Commit Β·
a63bb15
1
Parent(s): 61e8af9
Enhance video streaming and metadata handling
Browse filesAdd support for aniwatch portal, optimize stream concurrency and
probesize, update TMDB metadata shape fields, and fix premiere date
logic across frontend and backend services.
- src/lib/dl-showtime-helper.ts +41 -22
- src/lib/ffmpeg-v2.ts +3 -2
- src/sub-router/showtime.ts +6 -0
- src/sub-router/stream.ts +51 -37
src/lib/dl-showtime-helper.ts
CHANGED
|
@@ -40,6 +40,7 @@ async function find_seed_file(arg0: {
|
|
| 40 |
sbe_s_e?: string;
|
| 41 |
ideal_runtime?: T_playback["ideal_runtime"];
|
| 42 |
has_subs?: boolean;
|
|
|
|
| 43 |
}) {
|
| 44 |
const {
|
| 45 |
sbe_id,
|
|
@@ -54,7 +55,8 @@ async function find_seed_file(arg0: {
|
|
| 54 |
qLevel,
|
| 55 |
sbe_s_e,
|
| 56 |
ideal_runtime,
|
| 57 |
-
has_subs
|
|
|
|
| 58 |
} = arg0;
|
| 59 |
|
| 60 |
let { picture_quality } = arg0;
|
|
@@ -114,16 +116,19 @@ async function find_seed_file(arg0: {
|
|
| 114 |
return;
|
| 115 |
}
|
| 116 |
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
|
|
|
|
|
|
| 125 |
|
| 126 |
-
|
|
|
|
| 127 |
|
| 128 |
const data = {
|
| 129 |
stream_link,
|
|
@@ -172,17 +177,29 @@ async function find_seed_file(arg0: {
|
|
| 172 |
|
| 173 |
const stream_link = bucket_file_info!.url;
|
| 174 |
|
| 175 |
-
const
|
| 176 |
-
|
| 177 |
-
ideal_runtime,
|
| 178 |
-
video_path: {
|
| 179 |
-
h: stream_link,
|
| 180 |
-
protocol: "http",
|
| 181 |
-
bucket: true
|
| 182 |
-
}
|
| 183 |
-
});
|
| 184 |
|
| 185 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 186 |
|
| 187 |
const document_metadata = await (async () => {
|
| 188 |
if (document !== true || db_?.in_db) return;
|
|
@@ -442,13 +459,14 @@ async function document_seed_file(arg0: {
|
|
| 442 |
export async function match_runtime(arg0: {
|
| 443 |
ideal_runtime?: number;
|
| 444 |
picture_quality?: string;
|
|
|
|
| 445 |
video_path: {
|
| 446 |
h: string;
|
| 447 |
protocol: "http" | "local";
|
| 448 |
bucket?: boolean;
|
| 449 |
};
|
| 450 |
}) {
|
| 451 |
-
const { ideal_runtime, picture_quality, video_path } = arg0;
|
| 452 |
|
| 453 |
// call ffprobe
|
| 454 |
const [E_, R_] = await NS_promise.F_catch_promise({
|
|
@@ -457,7 +475,8 @@ export async function match_runtime(arg0: {
|
|
| 457 |
url: video_path.h,
|
| 458 |
type: "video",
|
| 459 |
protocol: video_path.protocol
|
| 460 |
-
}
|
|
|
|
| 461 |
})
|
| 462 |
});
|
| 463 |
|
|
|
|
| 40 |
sbe_s_e?: string;
|
| 41 |
ideal_runtime?: T_playback["ideal_runtime"];
|
| 42 |
has_subs?: boolean;
|
| 43 |
+
is_pipe_stream?: boolean;
|
| 44 |
}) {
|
| 45 |
const {
|
| 46 |
sbe_id,
|
|
|
|
| 55 |
qLevel,
|
| 56 |
sbe_s_e,
|
| 57 |
ideal_runtime,
|
| 58 |
+
has_subs,
|
| 59 |
+
is_pipe_stream
|
| 60 |
} = arg0;
|
| 61 |
|
| 62 |
let { picture_quality } = arg0;
|
|
|
|
| 116 |
return;
|
| 117 |
}
|
| 118 |
|
| 119 |
+
if (!is_pipe_stream) {
|
| 120 |
+
const _m = await match_runtime({
|
| 121 |
+
picture_quality,
|
| 122 |
+
ideal_runtime,
|
| 123 |
+
probe_timeout: 0,
|
| 124 |
+
video_path: {
|
| 125 |
+
h: upstream.url,
|
| 126 |
+
protocol: "http"
|
| 127 |
+
}
|
| 128 |
+
});
|
| 129 |
|
| 130 |
+
if (!_m) return;
|
| 131 |
+
}
|
| 132 |
|
| 133 |
const data = {
|
| 134 |
stream_link,
|
|
|
|
| 177 |
|
| 178 |
const stream_link = bucket_file_info!.url;
|
| 179 |
|
| 180 |
+
const _u = new URL(stream_link);
|
| 181 |
+
_u.searchParams.set("download", "true");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
|
| 183 |
+
const upstream = await fetch(_u.toString());
|
| 184 |
+
|
| 185 |
+
if (!upstream.ok) {
|
| 186 |
+
return;
|
| 187 |
+
}
|
| 188 |
+
|
| 189 |
+
if (!is_pipe_stream) {
|
| 190 |
+
const _m = await match_runtime({
|
| 191 |
+
picture_quality,
|
| 192 |
+
ideal_runtime,
|
| 193 |
+
probe_timeout: 0,
|
| 194 |
+
video_path: {
|
| 195 |
+
h: upstream.url,
|
| 196 |
+
protocol: "http",
|
| 197 |
+
bucket: true
|
| 198 |
+
}
|
| 199 |
+
});
|
| 200 |
+
|
| 201 |
+
if (!_m) return;
|
| 202 |
+
}
|
| 203 |
|
| 204 |
const document_metadata = await (async () => {
|
| 205 |
if (document !== true || db_?.in_db) return;
|
|
|
|
| 459 |
export async function match_runtime(arg0: {
|
| 460 |
ideal_runtime?: number;
|
| 461 |
picture_quality?: string;
|
| 462 |
+
probe_timeout?: number;
|
| 463 |
video_path: {
|
| 464 |
h: string;
|
| 465 |
protocol: "http" | "local";
|
| 466 |
bucket?: boolean;
|
| 467 |
};
|
| 468 |
}) {
|
| 469 |
+
const { ideal_runtime, picture_quality, video_path, probe_timeout } = arg0;
|
| 470 |
|
| 471 |
// call ffprobe
|
| 472 |
const [E_, R_] = await NS_promise.F_catch_promise({
|
|
|
|
| 475 |
url: video_path.h,
|
| 476 |
type: "video",
|
| 477 |
protocol: video_path.protocol
|
| 478 |
+
},
|
| 479 |
+
timeout: probe_timeout
|
| 480 |
})
|
| 481 |
});
|
| 482 |
|
src/lib/ffmpeg-v2.ts
CHANGED
|
@@ -148,9 +148,10 @@ async function F_probe_t1(arg0: {
|
|
| 148 |
|
| 149 |
flags.push("-protocol_whitelist", "file,http,https,tcp,tls,crypto");
|
| 150 |
|
| 151 |
-
flags.push("-probesize", `${1_000_000 *
|
| 152 |
-
flags.push("-analyzeduration", `${1_000_000 *
|
| 153 |
|
|
|
|
| 154 |
// flags.push("-count_packets");
|
| 155 |
|
| 156 |
if (read_intervals?.duration) {
|
|
|
|
| 148 |
|
| 149 |
flags.push("-protocol_whitelist", "file,http,https,tcp,tls,crypto");
|
| 150 |
|
| 151 |
+
flags.push("-probesize", `${1_000_000 * 5}`); // Limit probe size (default is 5MB)
|
| 152 |
+
flags.push("-analyzeduration", `${1_000_000 * 5}`); // Analyze only seconds (default is 5s)
|
| 153 |
|
| 154 |
+
// flags.push("-nobuffer");
|
| 155 |
// flags.push("-count_packets");
|
| 156 |
|
| 157 |
if (read_intervals?.duration) {
|
src/sub-router/showtime.ts
CHANGED
|
@@ -291,6 +291,12 @@ async function handle_data(arg0: {
|
|
| 291 |
|
| 292 |
let phase: Phase = two_step ? "ts" : "single";
|
| 293 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 294 |
const xc = REQ0.searchParams.has("xc");
|
| 295 |
|
| 296 |
(() => {
|
|
|
|
| 291 |
|
| 292 |
let phase: Phase = two_step ? "ts" : "single";
|
| 293 |
|
| 294 |
+
if (fMP4) {
|
| 295 |
+
phase = "single";
|
| 296 |
+
two_step = false;
|
| 297 |
+
use_s3_pipe = false;
|
| 298 |
+
}
|
| 299 |
+
|
| 300 |
const xc = REQ0.searchParams.has("xc");
|
| 301 |
|
| 302 |
(() => {
|
src/sub-router/stream.ts
CHANGED
|
@@ -439,11 +439,14 @@ async function handle_data(arg0: {
|
|
| 439 |
}
|
| 440 |
|
| 441 |
const __ = await wide_search_runner({
|
| 442 |
-
document: true,
|
| 443 |
-
|
| 444 |
-
skip: { local: true }
|
| 445 |
});
|
| 446 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 447 |
return __;
|
| 448 |
})();
|
| 449 |
|
|
@@ -636,7 +639,7 @@ async function handle_data(arg0: {
|
|
| 636 |
segments: current_segments,
|
| 637 |
init,
|
| 638 |
headers: _playback.headers || {},
|
| 639 |
-
concurrency: IS_HF() ?
|
| 640 |
ac: controller,
|
| 641 |
onError: (arg0) => {
|
| 642 |
if (is_dev) console.error("π ", JSON.stringify(arg0), "\n");
|
|
@@ -698,7 +701,7 @@ async function handle_data(arg0: {
|
|
| 698 |
i_x: two_step ? true : false,
|
| 699 |
skip: {
|
| 700 |
local: true,
|
| 701 |
-
db: true
|
| 702 |
}
|
| 703 |
});
|
| 704 |
})();
|
|
@@ -1080,6 +1083,46 @@ async function handle_data(arg0: {
|
|
| 1080 |
console.log("[CONTROLLER] Request aborted");
|
| 1081 |
}
|
| 1082 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1083 |
async function wide_search_runner(arg0: {
|
| 1084 |
skip?: {
|
| 1085 |
local?: boolean;
|
|
@@ -1108,7 +1151,8 @@ async function handle_data(arg0: {
|
|
| 1108 |
document,
|
| 1109 |
ideal_runtime: playback.ideal_runtime,
|
| 1110 |
skip,
|
| 1111 |
-
has_subs: false
|
|
|
|
| 1112 |
})
|
| 1113 |
});
|
| 1114 |
|
|
@@ -1118,37 +1162,7 @@ async function handle_data(arg0: {
|
|
| 1118 |
}
|
| 1119 |
|
| 1120 |
if (i_x) {
|
| 1121 |
-
|
| 1122 |
-
|
| 1123 |
-
_.searchParams.set("i_x", R_.stream_link);
|
| 1124 |
-
_.searchParams.set("xc", "");
|
| 1125 |
-
|
| 1126 |
-
phase = "mp4";
|
| 1127 |
-
|
| 1128 |
-
NS_Misc.console.log({
|
| 1129 |
-
ENV: "all",
|
| 1130 |
-
_browser: false,
|
| 1131 |
-
_log: [`π PHRASE [${phase}]: INIT`, "\n"]
|
| 1132 |
-
});
|
| 1133 |
-
|
| 1134 |
-
NS_Misc.console.log({
|
| 1135 |
-
ENV: "all",
|
| 1136 |
-
_browser: false,
|
| 1137 |
-
_log: [`SENT TO FFMPEG PIPE HANDLER`, "\n"]
|
| 1138 |
-
});
|
| 1139 |
-
|
| 1140 |
-
// fetch(_);
|
| 1141 |
-
|
| 1142 |
-
NS_promise.F_catch_promise({
|
| 1143 |
-
promise: ShowtimeV2RouterHandlePayload({
|
| 1144 |
-
data_key,
|
| 1145 |
-
metadata,
|
| 1146 |
-
REQ0: _,
|
| 1147 |
-
REQ_ORIGIN,
|
| 1148 |
-
ctx: ctx as any,
|
| 1149 |
-
throw_error: true
|
| 1150 |
-
})
|
| 1151 |
-
});
|
| 1152 |
}
|
| 1153 |
}
|
| 1154 |
|
|
|
|
| 439 |
}
|
| 440 |
|
| 441 |
const __ = await wide_search_runner({
|
| 442 |
+
document: two_step ? false : true,
|
| 443 |
+
skip: { local: true, db: two_step ? true : false }
|
|
|
|
| 444 |
});
|
| 445 |
|
| 446 |
+
if (two_step && __ && "stream_link" in __ && __.stream_link) {
|
| 447 |
+
pipe_i_x({ link: __.stream_link });
|
| 448 |
+
}
|
| 449 |
+
|
| 450 |
return __;
|
| 451 |
})();
|
| 452 |
|
|
|
|
| 639 |
segments: current_segments,
|
| 640 |
init,
|
| 641 |
headers: _playback.headers || {},
|
| 642 |
+
concurrency: IS_HF() ? 20 : 6,
|
| 643 |
ac: controller,
|
| 644 |
onError: (arg0) => {
|
| 645 |
if (is_dev) console.error("π ", JSON.stringify(arg0), "\n");
|
|
|
|
| 701 |
i_x: two_step ? true : false,
|
| 702 |
skip: {
|
| 703 |
local: true,
|
| 704 |
+
db: two_step ? true : false
|
| 705 |
}
|
| 706 |
});
|
| 707 |
})();
|
|
|
|
| 1083 |
console.log("[CONTROLLER] Request aborted");
|
| 1084 |
}
|
| 1085 |
|
| 1086 |
+
async function pipe_i_x(arg0: { link: string }) {
|
| 1087 |
+
const { link } = arg0;
|
| 1088 |
+
|
| 1089 |
+
if (typeof link !== "string" || !NS_routes_c.F_is_url(link)) {
|
| 1090 |
+
return;
|
| 1091 |
+
}
|
| 1092 |
+
|
| 1093 |
+
const _ = new URL(`/showtimeV2/delivery/${data_key}`, REQ_ORIGIN);
|
| 1094 |
+
|
| 1095 |
+
_.searchParams.set("i_x", link);
|
| 1096 |
+
_.searchParams.set("xc", "");
|
| 1097 |
+
|
| 1098 |
+
phase = "mp4";
|
| 1099 |
+
|
| 1100 |
+
NS_Misc.console.log({
|
| 1101 |
+
ENV: "all",
|
| 1102 |
+
_browser: false,
|
| 1103 |
+
_log: [`π PHRASE [${phase}]: INIT`, "\n"]
|
| 1104 |
+
});
|
| 1105 |
+
|
| 1106 |
+
NS_Misc.console.log({
|
| 1107 |
+
ENV: "all",
|
| 1108 |
+
_browser: false,
|
| 1109 |
+
_log: [`SENT TO FFMPEG PIPE HANDLER`, "\n"]
|
| 1110 |
+
});
|
| 1111 |
+
|
| 1112 |
+
// fetch(_);
|
| 1113 |
+
|
| 1114 |
+
NS_promise.F_catch_promise({
|
| 1115 |
+
promise: ShowtimeV2RouterHandlePayload({
|
| 1116 |
+
data_key,
|
| 1117 |
+
metadata,
|
| 1118 |
+
REQ0: _,
|
| 1119 |
+
REQ_ORIGIN,
|
| 1120 |
+
ctx: ctx as any,
|
| 1121 |
+
throw_error: true
|
| 1122 |
+
})
|
| 1123 |
+
});
|
| 1124 |
+
}
|
| 1125 |
+
|
| 1126 |
async function wide_search_runner(arg0: {
|
| 1127 |
skip?: {
|
| 1128 |
local?: boolean;
|
|
|
|
| 1151 |
document,
|
| 1152 |
ideal_runtime: playback.ideal_runtime,
|
| 1153 |
skip,
|
| 1154 |
+
has_subs: false,
|
| 1155 |
+
is_pipe_stream: true
|
| 1156 |
})
|
| 1157 |
});
|
| 1158 |
|
|
|
|
| 1162 |
}
|
| 1163 |
|
| 1164 |
if (i_x) {
|
| 1165 |
+
pipe_i_x({ link: R_.stream_link });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1166 |
}
|
| 1167 |
}
|
| 1168 |
|