GUI-STUDIO commited on
Commit
c0cd901
·
1 Parent(s): 9fd26ad

Add Telegram bot app and xpass scraper support

Browse files

Add new Telegram bot application with webhook support and MongoDB integration for storing bot users. Implement xpass scraper with BQL and Puppeteer engines. Fix URL path construction bugs in multiple video source routers by correcting conditional path building. Remove unused imports and console logs for cleanup. Add iframe autoplay permissions for player frontend. Update backend to track still-camera quality detection and include additional metadata in responses.

src/index.ts CHANGED
@@ -12,6 +12,7 @@ import { VideasyRouter } from "./sub-router/videasy";
12
  import { vidupRouter } from "./sub-router/vidup";
13
  import { VidcoreRouter } from "./sub-router/vidcore";
14
  import { vidnestRouter } from "./sub-router/vidnest";
 
15
 
16
  const PORT = process.env.PORT;
17
 
@@ -48,6 +49,7 @@ app.route("/", VideasyRouter);
48
  app.route("/", vidupRouter);
49
  app.route("/", VidcoreRouter);
50
  app.route("/", vidnestRouter);
 
51
 
52
  app.onError((error, c) => {
53
  const { status, message } = NS_error.F_collect_error_status_n_message({
 
12
  import { vidupRouter } from "./sub-router/vidup";
13
  import { VidcoreRouter } from "./sub-router/vidcore";
14
  import { vidnestRouter } from "./sub-router/vidnest";
15
+ import { XpassRouter } from "./sub-router/xpass";
16
 
17
  const PORT = process.env.PORT;
18
 
 
49
  app.route("/", vidupRouter);
50
  app.route("/", VidcoreRouter);
51
  app.route("/", vidnestRouter);
52
+ app.route("/", XpassRouter);
53
 
54
  app.onError((error, c) => {
55
  const { status, message } = NS_error.F_collect_error_status_n_message({
src/sub-router/111movies.ts CHANGED
@@ -41,7 +41,7 @@ subRouter.post(
41
  } = body;
42
 
43
  const movies_111_endpoint = new URL(
44
- `${film_type}/${id}/${film_type === "tv" ? `${body.season}/${body.episode}` : ""}`,
45
  "https://111movies.net"
46
  );
47
 
 
41
  } = body;
42
 
43
  const movies_111_endpoint = new URL(
44
+ `${film_type}/${id}${film_type === "tv" ? `/${body.season}/${body.episode}` : ""}`,
45
  "https://111movies.net"
46
  );
47
 
src/sub-router/vidcore.ts CHANGED
@@ -33,7 +33,7 @@ subRouter.post(
33
  const { film_type, id, id_type, headless, use, post_processing } = body;
34
 
35
  const vidcore_url = new URL(
36
- `${film_type}/${id}/${film_type === "tv" ? `${body.season}/${body.episode}` : ""}`,
37
  "https://vidcore.net"
38
  );
39
 
 
33
  const { film_type, id, id_type, headless, use, post_processing } = body;
34
 
35
  const vidcore_url = new URL(
36
+ `${film_type}/${id}${film_type === "tv" ? `/${body.season}/${body.episode}` : ""}`,
37
  "https://vidcore.net"
38
  );
39
 
src/sub-router/videasy.ts CHANGED
@@ -33,7 +33,7 @@ subRouter.post(
33
  const { film_type, id, id_type, headless, use, post_processing } = body;
34
 
35
  const videasy_url = new URL(
36
- `${film_type}/${id}/${film_type === "tv" ? `${body.season}/${body.episode}` : ""}`,
37
  "https://player.videasy.to"
38
  );
39
 
 
33
  const { film_type, id, id_type, headless, use, post_processing } = body;
34
 
35
  const videasy_url = new URL(
36
+ `${film_type}/${id}${film_type === "tv" ? `/${body.season}/${body.episode}` : ""}`,
37
  "https://player.videasy.to"
38
  );
39
 
src/sub-router/vidlinkpro.ts CHANGED
@@ -34,7 +34,7 @@ subRouter.post(
34
  const { film_type, id, id_type, headless, use, post_processing } = body;
35
 
36
  const vidlink_url = new URL(
37
- `${film_type}/${id}/${film_type === "tv" ? `${body.season}/${body.episode}` : ""}`,
38
  "https://vidlink.pro"
39
  );
40
 
 
34
  const { film_type, id, id_type, headless, use, post_processing } = body;
35
 
36
  const vidlink_url = new URL(
37
+ `${film_type}/${id}${film_type === "tv" ? `/${body.season}/${body.episode}` : ""}`,
38
  "https://vidlink.pro"
39
  );
40
 
src/sub-router/vidnest.ts CHANGED
@@ -33,7 +33,7 @@ subRouter.post(
33
  const { film_type, id, id_type, headless, use, post_processing } = body;
34
 
35
  const vidnest_url = new URL(
36
- `${film_type}/${id}/${film_type === "tv" ? `${body.season}/${body.episode}` : ""}`,
37
  "https://vidnest.fun"
38
  );
39
 
 
33
  const { film_type, id, id_type, headless, use, post_processing } = body;
34
 
35
  const vidnest_url = new URL(
36
+ `${film_type}/${id}${film_type === "tv" ? `/${body.season}/${body.episode}` : ""}`,
37
  "https://vidnest.fun"
38
  );
39
 
src/sub-router/vidup.ts CHANGED
@@ -33,7 +33,7 @@ subRouter.post(
33
  const { film_type, id, id_type, headless, use, post_processing } = body;
34
 
35
  const vidup_url = new URL(
36
- `${film_type}/${id}/${film_type === "tv" ? `${body.season}/${body.episode}` : ""}`,
37
  "https://vidup.to"
38
  );
39
 
 
33
  const { film_type, id, id_type, headless, use, post_processing } = body;
34
 
35
  const vidup_url = new URL(
36
+ `${film_type}/${id}${film_type === "tv" ? `/${body.season}/${body.episode}` : ""}`,
37
  "https://vidup.to"
38
  );
39
 
src/sub-router/vidvault.ts CHANGED
@@ -33,7 +33,7 @@ subRouter.post(
33
  const { film_type, id, id_type, headless, use, browserless } = body;
34
 
35
  const vidvault_endpoint = new URL(
36
- `${film_type}/${id}/${film_type === "tv" ? `${body.season}/${body.episode}` : ""}`,
37
  "https://vidvault.ru"
38
  );
39
 
 
33
  const { film_type, id, id_type, headless, use, browserless } = body;
34
 
35
  const vidvault_endpoint = new URL(
36
+ `${film_type}/${id}${film_type === "tv" ? `/${body.season}/${body.episode}` : ""}`,
37
  "https://vidvault.ru"
38
  );
39
 
src/sub-router/xpass.ts ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { Hono, type Context } from "hono";
2
+ import { NS_error } from "../../../../packages/lib/helpers/client/error";
3
+ import { sValidator } from "@hono/standard-validator";
4
+ import { NS_promise } from "../../../../packages/lib/helpers/client/promise";
5
+ import { NS_general_crawl } from "../../../../packages/lib/validator/general-crawl";
6
+ import { NS_routes_c } from "../../../../packages/lib/helpers/client/route";
7
+ import createError from "http-errors";
8
+ import { hono_validator_callback } from "../lib/misc";
9
+ import { NS_runtime } from "../../../../packages/lib/env.runtime";
10
+ import { NS_xpass_scraper } from "../../../../packages/lib/scraper/xpass/exe";
11
+ import { NS_scrape_post_processing } from "../../../../packages/lib/scraper/post-processing/generic";
12
+ import { T_prop_tmdb } from "../../../../packages/lib/helpers/server/streamify/lib-helper";
13
+
14
+ const APP_ENV = process.env.APP_ENV || NS_runtime.ENV_VAR_DB?.X_OFFLINE;
15
+ const X_OFFLINE = process.env.X_OFFLINE || NS_runtime.ENV_VAR_DB?.X_OFFLINE;
16
+ const APP_ORIGIN = process.env.APP_ORIGIN;
17
+ const REPO_ORIGIN = process.env.REPO_ORIGIN || NS_runtime.ENV_VAR_DB?.X_OFFLINE;
18
+
19
+ const subRouter = new Hono().basePath("/xpass");
20
+
21
+ subRouter.post(
22
+ "/scrape-playback",
23
+ sValidator("json", NS_general_crawl.route_schema.v, hono_validator_callback),
24
+ async (ctx) => {
25
+ const REQ0 = ctx.req.url;
26
+ const REQ_ORIGIN = APP_ORIGIN || new URL(REQ0).origin;
27
+ const REQ_headers = ctx.req.raw.headers;
28
+
29
+ const req_signal = ctx.req.raw.signal;
30
+
31
+ const body = ctx.req.valid("json");
32
+
33
+ const { film_type, id, id_type, headless, use, post_processing } = body;
34
+
35
+ const xpass_url = new URL(
36
+ `/e/${film_type}/${id}${film_type === "tv" ? `/${body.season}/${body.episode}` : ""}`,
37
+ "https://play.xpass.top"
38
+ );
39
+
40
+ xpass_url.searchParams.set("autostart", "false");
41
+
42
+ const tmdb: T_prop_tmdb = {
43
+ id,
44
+ type: film_type,
45
+ season: (body as any).season,
46
+ episode: (body as any).episode
47
+ };
48
+
49
+ const [E_, R_] = await NS_promise.F_catch_promise({
50
+ promise: NS_xpass_scraper.runner({
51
+ xpass_url,
52
+ tmdb,
53
+ use: {
54
+ tool: use,
55
+ browser: {
56
+ headless
57
+ }
58
+ },
59
+ thread_signal: req_signal
60
+ })
61
+ });
62
+
63
+ if (E_) {
64
+ const { status, message } = NS_error.F_collect_error_status_n_message({
65
+ ERR: E_
66
+ });
67
+
68
+ return ctx.json({ error: message }, status);
69
+ }
70
+
71
+ let metadata = R_;
72
+
73
+ if (metadata && post_processing && REPO_ORIGIN && id_type === "tmdb") {
74
+ const [E__, R__] = await NS_promise.F_catch_promise({
75
+ promise: NS_scrape_post_processing.construct({
76
+ portal: "xpass",
77
+ pre_metadata: metadata,
78
+ tmdb: {
79
+ id,
80
+ type: film_type,
81
+ season: (body as any).season,
82
+ episode: (body as any).episode
83
+ },
84
+ processing_payload: post_processing
85
+ })
86
+ });
87
+
88
+ if (R__?.metadata) {
89
+ metadata = R__.metadata as any;
90
+ }
91
+ }
92
+
93
+ return ctx.json({ data: metadata });
94
+ }
95
+ );
96
+
97
+ export const XpassRouter = subRouter;