Spaces:
Running
Running
Upload 61 files
Browse files- dist/addon/manifest.js +113 -0
- dist/addon/manifest.js.map +1 -0
- dist/addon/server.js +13 -0
- dist/addon/server.js.map +1 -0
- dist/addon/streams.js +160 -0
- dist/addon/streams.js.map +1 -0
- dist/index.js +14 -0
- dist/index.js.map +1 -0
- dist/router.js +86 -0
- dist/router.js.map +1 -0
- dist/torrent/eztv.js +79 -0
- dist/torrent/eztv.js.map +1 -0
- dist/torrent/insane.js +127 -0
- dist/torrent/insane.js.map +1 -0
- dist/torrent/itorrent.js +99 -0
- dist/torrent/itorrent.js.map +1 -0
- dist/torrent/jackett.js +30 -0
- dist/torrent/jackett.js.map +1 -0
- dist/torrent/ncore.js +122 -0
- dist/torrent/ncore.js.map +1 -0
- dist/torrent/search.js +87 -0
- dist/torrent/search.js.map +1 -0
- dist/torrent/webtorrent.js +145 -0
- dist/torrent/webtorrent.js.map +1 -0
- dist/torrent/yts.js +51 -0
- dist/torrent/yts.js.map +1 -0
- dist/utils/dotenv.js +3 -0
- dist/utils/dotenv.js.map +1 -0
- dist/utils/file.js +41 -0
- dist/utils/file.js.map +1 -0
- dist/utils/https.js +41 -0
- dist/utils/https.js.map +1 -0
- dist/utils/imdb.js +29 -0
- dist/utils/imdb.js.map +1 -0
- dist/utils/language.js +19 -0
- dist/utils/language.js.map +1 -0
- dist/utils/quality.js +76 -0
- dist/utils/quality.js.map +1 -0
- dist/utils/shows.js +56 -0
- dist/utils/shows.js.map +1 -0
dist/addon/manifest.js
ADDED
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
export const manifest = {
|
2 |
+
id: "community.torrent-stream",
|
3 |
+
version: "1.0.0",
|
4 |
+
catalogs: [],
|
5 |
+
resources: ["stream"],
|
6 |
+
types: ["movie", "series"],
|
7 |
+
name: "Torrent Stream",
|
8 |
+
logo: "https://upload.wikimedia.org/wikipedia/en/7/79/WebTorrent_logo.png",
|
9 |
+
background: "https://i.etsystatic.com/35367581/r/il/53bf97/4463935832/il_fullxfull.4463935832_3k3g.jpg",
|
10 |
+
description: "This addon enables Stremio to stream movies and shows from torrents",
|
11 |
+
idPrefixes: ["tt"],
|
12 |
+
behaviorHints: {
|
13 |
+
// @ts-ignore
|
14 |
+
configurable: true,
|
15 |
+
configurationRequired: true,
|
16 |
+
},
|
17 |
+
config: [
|
18 |
+
{
|
19 |
+
title: "Enable Jackett search",
|
20 |
+
key: "enableJackett",
|
21 |
+
type: "checkbox",
|
22 |
+
},
|
23 |
+
{
|
24 |
+
title: "Jackett API URL",
|
25 |
+
key: "jackettUrl",
|
26 |
+
type: "text",
|
27 |
+
},
|
28 |
+
{
|
29 |
+
title: "Jackett API Key",
|
30 |
+
key: "jackettKey",
|
31 |
+
type: "password",
|
32 |
+
},
|
33 |
+
{
|
34 |
+
title: "Enable nCore search",
|
35 |
+
key: "enableNcore",
|
36 |
+
type: "checkbox",
|
37 |
+
default: "checked",
|
38 |
+
},
|
39 |
+
{
|
40 |
+
title: "nCore username",
|
41 |
+
key: "nCoreUser",
|
42 |
+
type: "text",
|
43 |
+
},
|
44 |
+
{
|
45 |
+
title: "nCore password",
|
46 |
+
key: "nCorePassword",
|
47 |
+
type: "password",
|
48 |
+
},
|
49 |
+
{
|
50 |
+
title: "Enable iNSANE search",
|
51 |
+
key: "enableInsane",
|
52 |
+
type: "checkbox",
|
53 |
+
},
|
54 |
+
{
|
55 |
+
title: "iNSANE username",
|
56 |
+
key: "insaneUser",
|
57 |
+
type: "text",
|
58 |
+
},
|
59 |
+
{
|
60 |
+
title: "iNSANE password",
|
61 |
+
key: "insanePassword",
|
62 |
+
type: "password",
|
63 |
+
},
|
64 |
+
{
|
65 |
+
title: "Enable iTorrent search",
|
66 |
+
key: "enableItorrent",
|
67 |
+
type: "checkbox",
|
68 |
+
},
|
69 |
+
{
|
70 |
+
title: "Enable YTS search",
|
71 |
+
key: "enableYts",
|
72 |
+
type: "checkbox",
|
73 |
+
},
|
74 |
+
{
|
75 |
+
title: "Enable EZTV search",
|
76 |
+
key: "enableEztv",
|
77 |
+
type: "checkbox",
|
78 |
+
},
|
79 |
+
{
|
80 |
+
title: "Use titles for torrent search",
|
81 |
+
key: "searchByTitle",
|
82 |
+
type: "checkbox",
|
83 |
+
},
|
84 |
+
{
|
85 |
+
title: "Do not show HDR results",
|
86 |
+
key: "disableHdr",
|
87 |
+
type: "checkbox",
|
88 |
+
},
|
89 |
+
{
|
90 |
+
title: "Do not show HEVC results",
|
91 |
+
key: "disableHevc",
|
92 |
+
type: "checkbox",
|
93 |
+
},
|
94 |
+
{
|
95 |
+
title: "Do not show 4K results",
|
96 |
+
key: "disable4k",
|
97 |
+
type: "checkbox",
|
98 |
+
},
|
99 |
+
{
|
100 |
+
title: "Do not show CAM results",
|
101 |
+
key: "disableCam",
|
102 |
+
type: "checkbox",
|
103 |
+
default: "checked",
|
104 |
+
},
|
105 |
+
{
|
106 |
+
title: "Do not show 3D results",
|
107 |
+
key: "disable3d",
|
108 |
+
type: "checkbox",
|
109 |
+
default: "checked",
|
110 |
+
},
|
111 |
+
],
|
112 |
+
};
|
113 |
+
//# sourceMappingURL=manifest.js.map
|
dist/addon/manifest.js.map
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../../src/addon/manifest.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,QAAQ,GAAa;IAChC,EAAE,EAAE,0BAA0B;IAC9B,OAAO,EAAE,OAAO;IAChB,QAAQ,EAAE,EAAE;IACZ,SAAS,EAAE,CAAC,QAAQ,CAAC;IACrB,KAAK,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC;IAC1B,IAAI,EAAE,gBAAgB;IACtB,IAAI,EAAE,oEAAoE;IAC1E,UAAU,EACR,2FAA2F;IAC7F,WAAW,EACT,qEAAqE;IACvE,UAAU,EAAE,CAAC,IAAI,CAAC;IAClB,aAAa,EAAE;QACb,aAAa;QACb,YAAY,EAAE,IAAI;QAClB,qBAAqB,EAAE,IAAI;KAC5B;IACD,MAAM,EAAE;QACN;YACE,KAAK,EAAE,uBAAuB;YAC9B,GAAG,EAAE,eAAe;YACpB,IAAI,EAAE,UAAU;SACjB;QACD;YACE,KAAK,EAAE,iBAAiB;YACxB,GAAG,EAAE,YAAY;YACjB,IAAI,EAAE,MAAM;SACb;QACD;YACE,KAAK,EAAE,iBAAiB;YACxB,GAAG,EAAE,YAAY;YACjB,IAAI,EAAE,UAAU;SACjB;QACD;YACE,KAAK,EAAE,qBAAqB;YAC5B,GAAG,EAAE,aAAa;YAClB,IAAI,EAAE,UAAU;YAChB,OAAO,EAAE,SAAS;SACnB;QACD;YACE,KAAK,EAAE,gBAAgB;YACvB,GAAG,EAAE,WAAW;YAChB,IAAI,EAAE,MAAM;SACb;QACD;YACE,KAAK,EAAE,gBAAgB;YACvB,GAAG,EAAE,eAAe;YACpB,IAAI,EAAE,UAAU;SACjB;QACD;YACE,KAAK,EAAE,sBAAsB;YAC7B,GAAG,EAAE,cAAc;YACnB,IAAI,EAAE,UAAU;SACjB;QACD;YACE,KAAK,EAAE,iBAAiB;YACxB,GAAG,EAAE,YAAY;YACjB,IAAI,EAAE,MAAM;SACb;QACD;YACE,KAAK,EAAE,iBAAiB;YACxB,GAAG,EAAE,gBAAgB;YACrB,IAAI,EAAE,UAAU;SACjB;QACD;YACE,KAAK,EAAE,wBAAwB;YAC/B,GAAG,EAAE,gBAAgB;YACrB,IAAI,EAAE,UAAU;SACjB;QACD;YACE,KAAK,EAAE,mBAAmB;YAC1B,GAAG,EAAE,WAAW;YAChB,IAAI,EAAE,UAAU;SACjB;QACD;YACE,KAAK,EAAE,oBAAoB;YAC3B,GAAG,EAAE,YAAY;YACjB,IAAI,EAAE,UAAU;SACjB;QACD;YACE,KAAK,EAAE,+BAA+B;YACtC,GAAG,EAAE,eAAe;YACpB,IAAI,EAAE,UAAU;SACjB;QACD;YACE,KAAK,EAAE,yBAAyB;YAChC,GAAG,EAAE,YAAY;YACjB,IAAI,EAAE,UAAU;SACjB;QACD;YACE,KAAK,EAAE,0BAA0B;YACjC,GAAG,EAAE,aAAa;YAClB,IAAI,EAAE,UAAU;SACjB;QACD;YACE,KAAK,EAAE,wBAAwB;YAC/B,GAAG,EAAE,WAAW;YAChB,IAAI,EAAE,UAAU;SACjB;QACD;YACE,KAAK,EAAE,yBAAyB;YAChC,GAAG,EAAE,YAAY;YACjB,IAAI,EAAE,UAAU;YAChB,OAAO,EAAE,SAAS;SACnB;QACD;YACE,KAAK,EAAE,wBAAwB;YAC/B,GAAG,EAAE,WAAW;YAChB,IAAI,EAAE,UAAU;YAChB,OAAO,EAAE,SAAS;SACnB;KACF;CACF,CAAC"}
|
dist/addon/server.js
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import stremio from "stremio-addon-sdk";
|
2 |
+
import { streamHandler } from "./streams.js";
|
3 |
+
import { manifest } from "./manifest.js";
|
4 |
+
export const serveHTTP = async (port) => {
|
5 |
+
const builder = new stremio.addonBuilder(manifest);
|
6 |
+
// @ts-ignore
|
7 |
+
builder.defineStreamHandler(streamHandler);
|
8 |
+
const addonInterface = builder.getInterface();
|
9 |
+
// @ts-ignore
|
10 |
+
const { url, server, app, } = await stremio.serveHTTP(addonInterface, { port });
|
11 |
+
return app;
|
12 |
+
};
|
13 |
+
//# sourceMappingURL=server.js.map
|
dist/addon/server.js.map
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/addon/server.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,mBAAmB,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGzC,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,EAAE,IAAY,EAAE,EAAE;IAC9C,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;IAEnD,aAAa;IACb,OAAO,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAAC;IAC3C,MAAM,cAAc,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;IAE9C,aAAa;IACb,MAAM,EACJ,GAAG,EACH,MAAM,EACN,GAAG,GACJ,GACC,MAAM,OAAO,CAAC,SAAS,CAAC,cAAc,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;IAEpD,OAAO,GAAG,CAAC;AACb,CAAC,CAAC"}
|
dist/addon/streams.js
ADDED
@@ -0,0 +1,160 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { searchTorrents, } from "../torrent/search.js";
|
2 |
+
import { getTorrentInfo } from "../torrent/webtorrent.js";
|
3 |
+
import { getReadableSize, isSubtitleFile, isVideoFile } from "../utils/file.js";
|
4 |
+
import { getTitles } from "../utils/imdb.js";
|
5 |
+
import { guessLanguage } from "../utils/language.js";
|
6 |
+
import { guessQuality } from "../utils/quality.js";
|
7 |
+
import { isFileNameMatch, isTorrentNameMatch } from "../utils/shows.js";
|
8 |
+
export const streamHandler = async ({ type, id, config, req }) => {
|
9 |
+
let torrents = [];
|
10 |
+
const categories = [];
|
11 |
+
if (type === "movie")
|
12 |
+
categories.push("movie");
|
13 |
+
if (type === "series")
|
14 |
+
categories.push("show");
|
15 |
+
const sources = [];
|
16 |
+
if (config.enableJackett === "on")
|
17 |
+
sources.push("jackett");
|
18 |
+
if (config.enableNcore === "on")
|
19 |
+
sources.push("ncore");
|
20 |
+
if (config.enableInsane === "on")
|
21 |
+
sources.push("insane");
|
22 |
+
if (config.enableItorrent === "on")
|
23 |
+
sources.push("itorrent");
|
24 |
+
if (config.enableYts === "on")
|
25 |
+
sources.push("yts");
|
26 |
+
if (config.enableEztv === "on")
|
27 |
+
sources.push("eztv");
|
28 |
+
const [imdbId, season, episode] = id.split(":");
|
29 |
+
const queries = [imdbId];
|
30 |
+
if (config.searchByTitle === "on")
|
31 |
+
queries.push(...(await getTitles(imdbId)));
|
32 |
+
torrents = (await Promise.all(queries.map((query) => searchTorrents(query, {
|
33 |
+
categories,
|
34 |
+
sources,
|
35 |
+
jackett: {
|
36 |
+
url: config.jackettUrl,
|
37 |
+
apiKey: config.jackettKey,
|
38 |
+
},
|
39 |
+
ncore: {
|
40 |
+
user: config.nCoreUser,
|
41 |
+
password: config.nCorePassword,
|
42 |
+
},
|
43 |
+
insane: {
|
44 |
+
user: config.insaneUser,
|
45 |
+
password: config.insanePassword,
|
46 |
+
},
|
47 |
+
})))).flat();
|
48 |
+
torrents = dedupeTorrents(torrents);
|
49 |
+
torrents = torrents.filter((torrent) => {
|
50 |
+
if (!torrent.seeds)
|
51 |
+
return false;
|
52 |
+
if (torrent.category?.includes("DVD"))
|
53 |
+
return false;
|
54 |
+
if (!isAllowedFormat(config, torrent.name))
|
55 |
+
return false;
|
56 |
+
if (!isAllowedQuality(config, guessQuality(torrent.name).quality))
|
57 |
+
return false;
|
58 |
+
if (season &&
|
59 |
+
episode &&
|
60 |
+
!isTorrentNameMatch(torrent.name, Number(season), Number(episode)))
|
61 |
+
return false;
|
62 |
+
return true;
|
63 |
+
});
|
64 |
+
let streams = (await Promise.all(torrents.map((torrent) => getStreamsFromTorrent(req, torrent, season, episode)))).flat();
|
65 |
+
streams = streams.filter((stream) => {
|
66 |
+
if (!isAllowedFormat(config, stream.fileName))
|
67 |
+
return false;
|
68 |
+
if (!isAllowedQuality(config, stream.quality))
|
69 |
+
return false;
|
70 |
+
return true;
|
71 |
+
});
|
72 |
+
streams.sort((a, b) => b.score - a.score);
|
73 |
+
return { streams: streams.map((stream) => stream.stream) };
|
74 |
+
};
|
75 |
+
const dedupeTorrents = (torrents) => {
|
76 |
+
const map = new Map(torrents.map((torrent) => [`${torrent.tracker}:${torrent.name}`, torrent]));
|
77 |
+
return [...map.values()];
|
78 |
+
};
|
79 |
+
export const getStreamsFromTorrent = async (req, torrent, season, episode) => {
|
80 |
+
const uri = torrent.torrent || torrent.magnet;
|
81 |
+
if (!uri)
|
82 |
+
return [];
|
83 |
+
const torrentInfo = await getTorrentInfo(uri);
|
84 |
+
if (!torrentInfo)
|
85 |
+
return [];
|
86 |
+
let videos = torrentInfo.files.filter((file) => isVideoFile(file.name));
|
87 |
+
if (season && episode) {
|
88 |
+
videos = videos.filter((file) => isFileNameMatch(file.name, Number(season), Number(episode)));
|
89 |
+
}
|
90 |
+
const videosSize = videos.reduce((acc, file) => acc + file.size, 0);
|
91 |
+
videos = videos.filter((file) => file.size > videosSize / (videos.length + 1));
|
92 |
+
const subs = torrentInfo.files.filter((file) => isSubtitleFile(file.name));
|
93 |
+
const torrentQuality = guessQuality(torrent.name);
|
94 |
+
const language = guessLanguage(torrent.name, torrent.category);
|
95 |
+
// @ts-ignore
|
96 |
+
return videos.map((file) => {
|
97 |
+
const fileQuality = guessQuality(file.name);
|
98 |
+
const { quality, score } = fileQuality.score > torrentQuality.score ? fileQuality : torrentQuality;
|
99 |
+
const description = [
|
100 |
+
...(season && episode ? [torrent.name, file.name] : [torrent.name]),
|
101 |
+
[
|
102 |
+
`💾 ${getReadableSize(file.size)}`,
|
103 |
+
`⬆️ ${torrent.seeds}`,
|
104 |
+
`⬇️ ${torrent.peers}`,
|
105 |
+
].join(" "),
|
106 |
+
[`🔊 ${language}`, `⚙️ ${torrent.tracker}`].join(" "),
|
107 |
+
].join("\n");
|
108 |
+
const streamEndpoint = `${req.protocol}://${req.get("host")}/stream`;
|
109 |
+
const url = [
|
110 |
+
streamEndpoint,
|
111 |
+
encodeURIComponent(uri),
|
112 |
+
encodeURIComponent(file.path),
|
113 |
+
].join("/");
|
114 |
+
const subtitles = subs.map((sub, index) => ({
|
115 |
+
id: index.toString(),
|
116 |
+
url: [
|
117 |
+
streamEndpoint,
|
118 |
+
encodeURIComponent(uri),
|
119 |
+
encodeURIComponent(sub.path),
|
120 |
+
].join("/"),
|
121 |
+
lang: sub.name,
|
122 |
+
}));
|
123 |
+
return {
|
124 |
+
stream: {
|
125 |
+
name: quality,
|
126 |
+
description,
|
127 |
+
url,
|
128 |
+
subtitles,
|
129 |
+
behaviorHints: {
|
130 |
+
bingeGroup: torrent.name,
|
131 |
+
},
|
132 |
+
},
|
133 |
+
torrentName: torrent.name,
|
134 |
+
fileName: file.name,
|
135 |
+
quality,
|
136 |
+
score,
|
137 |
+
};
|
138 |
+
});
|
139 |
+
};
|
140 |
+
const isAllowedQuality = (config, quality) => {
|
141 |
+
if (config?.disable4k === "on" && quality.includes("4K"))
|
142 |
+
return false;
|
143 |
+
if (config?.disableCam === "on" && quality.includes("CAM"))
|
144 |
+
return false;
|
145 |
+
if (config?.disableHdr === "on" &&
|
146 |
+
(quality.includes("HDR") || quality.includes("Dolby Vision")))
|
147 |
+
return false;
|
148 |
+
if (config?.disable3d === "on" && quality.includes("3D"))
|
149 |
+
return false;
|
150 |
+
return true;
|
151 |
+
};
|
152 |
+
const isAllowedFormat = (config, name) => {
|
153 |
+
if (config?.disableHevc === "on") {
|
154 |
+
const str = name.replace(/\W/g, "").toLowerCase();
|
155 |
+
if (str.includes("x265") || str.includes("h265") || str.includes("hevc"))
|
156 |
+
return false;
|
157 |
+
}
|
158 |
+
return true;
|
159 |
+
};
|
160 |
+
//# sourceMappingURL=streams.js.map
|
dist/addon/streams.js.map
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"version":3,"file":"streams.js","sourceRoot":"","sources":["../../src/addon/streams.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,cAAc,GACf,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAChF,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,aAAa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,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;QAClD,IAAI,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC;YACtE,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
|
dist/index.js
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import "./utils/dotenv.js";
|
2 |
+
import express from "express";
|
3 |
+
import { serveHTTP } from "./addon/server.js";
|
4 |
+
import { router } from "./router.js";
|
5 |
+
import { serveHTTPS } from "./utils/https.js";
|
6 |
+
const PORT = Number(process.env.PORT) || 58827;
|
7 |
+
const HTTPS_PORT = Number(process.env.HTTPS_PORT) || 58828;
|
8 |
+
const main = async () => {
|
9 |
+
const app = await serveHTTP(PORT);
|
10 |
+
app.use(express.json()).use(router);
|
11 |
+
await serveHTTPS(app, HTTPS_PORT);
|
12 |
+
};
|
13 |
+
main();
|
14 |
+
//# sourceMappingURL=index.js.map
|
dist/index.js.map
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,mBAAmB,CAAC;AAE3B,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC;AAC/C,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,KAAK,CAAC;AAE3D,MAAM,IAAI,GAAG,KAAK,IAAI,EAAE;IACtB,MAAM,GAAG,GAAG,MAAM,SAAS,CAAC,IAAI,CAAC,CAAC;IAClC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACpC,MAAM,UAAU,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;AACpC,CAAC,CAAC;AAEF,IAAI,EAAE,CAAC"}
|
dist/router.js
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { Router } from "express";
|
2 |
+
import { searchTorrents } from "./torrent/search.js";
|
3 |
+
import { getFile, getOrAddTorrent, getStats, getTorrentInfo, streamClosed, streamOpened, } from "./torrent/webtorrent.js";
|
4 |
+
import { getStreamingMimeType } from "./utils/file.js";
|
5 |
+
export const router = Router();
|
6 |
+
router.get("/stats", (req, res) => {
|
7 |
+
const stats = getStats();
|
8 |
+
res.json(stats);
|
9 |
+
});
|
10 |
+
router.get("/torrents/:query", async (req, res) => {
|
11 |
+
const { query } = req.params;
|
12 |
+
const torrents = await searchTorrents(query);
|
13 |
+
res.json(torrents);
|
14 |
+
});
|
15 |
+
router.post("/torrents/:query", async (req, res) => {
|
16 |
+
const { query } = req.params;
|
17 |
+
const options = req.body;
|
18 |
+
const torrents = await searchTorrents(query, options);
|
19 |
+
res.json(torrents);
|
20 |
+
});
|
21 |
+
router.get("/torrent/:torrentUri", async (req, res) => {
|
22 |
+
const { torrentUri } = req.params;
|
23 |
+
const torrent = await getTorrentInfo(torrentUri);
|
24 |
+
if (!torrent)
|
25 |
+
return res.status(500).send("Failed to get torrent");
|
26 |
+
torrent.files.forEach((file) => {
|
27 |
+
file.url = [
|
28 |
+
`${req.protocol}://${req.get("host")}`,
|
29 |
+
"stream",
|
30 |
+
encodeURIComponent(torrentUri),
|
31 |
+
encodeURIComponent(file.path),
|
32 |
+
].join("/");
|
33 |
+
});
|
34 |
+
res.json(torrent);
|
35 |
+
});
|
36 |
+
router.get("/stream/:torrentUri/:filePath", async (req, res) => {
|
37 |
+
const { torrentUri, filePath } = req.params;
|
38 |
+
const torrent = await getOrAddTorrent(torrentUri);
|
39 |
+
if (!torrent)
|
40 |
+
return res.status(500).send("Failed to add torrent");
|
41 |
+
const file = getFile(torrent, filePath);
|
42 |
+
if (!file)
|
43 |
+
return res.status(404).send("File not found");
|
44 |
+
const { range } = req.headers;
|
45 |
+
const positions = (range || "").replace(/bytes=/, "").split("-");
|
46 |
+
const start = Number(positions[0]);
|
47 |
+
const end = Number(positions[1]) || file.length - 1;
|
48 |
+
if (start >= file.length || end >= file.length) {
|
49 |
+
res.writeHead(416, {
|
50 |
+
"Content-Range": `bytes */${file.length}`,
|
51 |
+
});
|
52 |
+
return res.end();
|
53 |
+
}
|
54 |
+
const headers = {
|
55 |
+
"Content-Range": `bytes ${start}-${end}/${file.length}`,
|
56 |
+
"Accept-Ranges": "bytes",
|
57 |
+
"Content-Length": end - start + 1,
|
58 |
+
"Content-Type": getStreamingMimeType(file.name),
|
59 |
+
};
|
60 |
+
res.writeHead(206, headers);
|
61 |
+
try {
|
62 |
+
const noDataTimeout = setTimeout(() => {
|
63 |
+
res.status(500).end();
|
64 |
+
}, 10000);
|
65 |
+
const noReadTimeout = setTimeout(() => {
|
66 |
+
res.status(200).end();
|
67 |
+
}, 60000);
|
68 |
+
const videoStream = file.createReadStream({ start, end });
|
69 |
+
videoStream.on("data", () => {
|
70 |
+
clearTimeout(noDataTimeout);
|
71 |
+
});
|
72 |
+
videoStream.on("readable", () => {
|
73 |
+
noReadTimeout.refresh();
|
74 |
+
});
|
75 |
+
videoStream.on("error", (error) => { });
|
76 |
+
videoStream.pipe(res);
|
77 |
+
streamOpened(torrent.infoHash, file.name);
|
78 |
+
res.on("close", () => {
|
79 |
+
streamClosed(torrent.infoHash, file.name);
|
80 |
+
});
|
81 |
+
}
|
82 |
+
catch (error) {
|
83 |
+
res.status(500).end();
|
84 |
+
}
|
85 |
+
});
|
86 |
+
//# sourceMappingURL=router.js.map
|
dist/router.js.map
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"version":3,"file":"router.js","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EACL,OAAO,EACP,eAAe,EACf,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,YAAY,GACb,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAEvD,MAAM,CAAC,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC;AAE/B,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;IAChC,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAC;IACzB,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC;AAEH,MAAM,CAAC,GAAG,CAAC,kBAAkB,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE;IAChD,MA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C,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;IACxB,CAAC;AACH,CAAC,CAAC,CAAC"}
|
dist/torrent/eztv.js
ADDED
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import axios from "axios";
|
2 |
+
import * as cheerio from "cheerio";
|
3 |
+
import { getTorrentsByImdbId } from "eztv-crawler";
|
4 |
+
import { isImdbId } from "../utils/imdb.js";
|
5 |
+
export const searchEztv = async (searchQuery) => {
|
6 |
+
try {
|
7 |
+
if (isImdbId(searchQuery)) {
|
8 |
+
const res = await getTorrentsByImdbId(searchQuery);
|
9 |
+
return res.torrents.map((torrent) => ({
|
10 |
+
name: torrent.title.replace("EZTV", "").trim(),
|
11 |
+
tracker: "EZTV",
|
12 |
+
category: parseCategory(torrent.title),
|
13 |
+
size: Number(torrent.size_bytes),
|
14 |
+
seeds: torrent.seeds,
|
15 |
+
peers: torrent.peers,
|
16 |
+
torrent: torrent.torrent_url,
|
17 |
+
magnet: torrent.magnet_url,
|
18 |
+
}));
|
19 |
+
}
|
20 |
+
else {
|
21 |
+
const formData = new FormData();
|
22 |
+
formData.append("layout", "def_wlinks");
|
23 |
+
const eztvPage = await axios.post(`https://eztv.wf/search/${encodeURIComponent(searchQuery)}`, formData);
|
24 |
+
const $ = cheerio.load(eztvPage.data);
|
25 |
+
const results = $('[name="hover"]').toArray();
|
26 |
+
return results.map((res) => {
|
27 |
+
const title = $(res).find("td:nth-child(2)").text()?.replace(/\n/g, "");
|
28 |
+
const size = $(res).find("td:nth-child(4)").text();
|
29 |
+
const seeds = $(res).find("td:nth-child(6)").text();
|
30 |
+
const torrent = $(res)
|
31 |
+
.find("td:nth-child(3) .download_1")
|
32 |
+
.attr("href")
|
33 |
+
?.replace(/\n/g, "");
|
34 |
+
const magnet = $(res)
|
35 |
+
.find("td:nth-child(3) .magnet")
|
36 |
+
.attr("href")
|
37 |
+
?.replace(/\n/g, "");
|
38 |
+
return {
|
39 |
+
name: title.replace("[eztv]", "").trim(),
|
40 |
+
tracker: "EZTV",
|
41 |
+
category: parseCategory(title),
|
42 |
+
size: parseSize(size),
|
43 |
+
seeds: Number(seeds) || 0,
|
44 |
+
peers: 0,
|
45 |
+
torrent,
|
46 |
+
magnet,
|
47 |
+
};
|
48 |
+
});
|
49 |
+
}
|
50 |
+
}
|
51 |
+
catch (error) {
|
52 |
+
return [];
|
53 |
+
}
|
54 |
+
};
|
55 |
+
const parseCategory = (title) => {
|
56 |
+
let quality = "SD";
|
57 |
+
if (title.includes("720p"))
|
58 |
+
quality = "720p";
|
59 |
+
if (title.includes("1080p"))
|
60 |
+
quality = "1080p";
|
61 |
+
if (title.includes("2160p"))
|
62 |
+
quality = "2160p";
|
63 |
+
return `TV/${quality}`;
|
64 |
+
};
|
65 |
+
const parseSize = (size) => {
|
66 |
+
const units = {
|
67 |
+
TB: 1024 ** 4,
|
68 |
+
GB: 1024 ** 3,
|
69 |
+
MB: 1024 ** 2,
|
70 |
+
KB: 1024,
|
71 |
+
B: 1,
|
72 |
+
};
|
73 |
+
const [sizeStr, unit] = size.split(" ");
|
74 |
+
const sizeNum = Number(sizeStr);
|
75 |
+
if (!sizeNum || !units[unit])
|
76 |
+
return 0;
|
77 |
+
return Math.ceil(sizeNum * units[unit]);
|
78 |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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import axios from "axios";
|
2 |
+
import { wrapper } from "axios-cookiejar-support";
|
3 |
+
import * as cheerio from "cheerio";
|
4 |
+
import { CookieJar } from "tough-cookie";
|
5 |
+
const INSANE_USER = process.env.INSANE_USER;
|
6 |
+
const INSANE_PASSWORD = process.env.INSANE_PASSWORD;
|
7 |
+
const USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0";
|
8 |
+
export var InsaneCategory;
|
9 |
+
(function (InsaneCategory) {
|
10 |
+
InsaneCategory[InsaneCategory["Film_Hun_SD"] = 41] = "Film_Hun_SD";
|
11 |
+
InsaneCategory[InsaneCategory["Film_Hun_HD"] = 27] = "Film_Hun_HD";
|
12 |
+
InsaneCategory[InsaneCategory["Film_Hun_UHD"] = 44] = "Film_Hun_UHD";
|
13 |
+
InsaneCategory[InsaneCategory["Film_Eng_SD"] = 42] = "Film_Eng_SD";
|
14 |
+
InsaneCategory[InsaneCategory["Film_Eng_HD"] = 25] = "Film_Eng_HD";
|
15 |
+
InsaneCategory[InsaneCategory["Film_Eng_UHD"] = 45] = "Film_Eng_UHD";
|
16 |
+
InsaneCategory[InsaneCategory["Sorozat_Hun"] = 8] = "Sorozat_Hun";
|
17 |
+
InsaneCategory[InsaneCategory["Sorozat_Hun_HD"] = 40] = "Sorozat_Hun_HD";
|
18 |
+
InsaneCategory[InsaneCategory["Sorozat_Hun_UHD"] = 47] = "Sorozat_Hun_UHD";
|
19 |
+
InsaneCategory[InsaneCategory["Sorozat_Eng"] = 7] = "Sorozat_Eng";
|
20 |
+
InsaneCategory[InsaneCategory["Sorozat_Eng_HD"] = 39] = "Sorozat_Eng_HD";
|
21 |
+
InsaneCategory[InsaneCategory["Sorozat_Eng_UHD"] = 46] = "Sorozat_Eng_UHD";
|
22 |
+
})(InsaneCategory || (InsaneCategory = {}));
|
23 |
+
export const searchInsane = async (searchQuery, categories, insaneUser, insanePassword) => {
|
24 |
+
try {
|
25 |
+
const user = insaneUser || INSANE_USER;
|
26 |
+
const password = insanePassword || INSANE_PASSWORD;
|
27 |
+
if (!user || !password)
|
28 |
+
return [];
|
29 |
+
const jar = new CookieJar();
|
30 |
+
const client = wrapper(
|
31 |
+
// @ts-ignore
|
32 |
+
axios.create({
|
33 |
+
// @ts-ignore
|
34 |
+
jar,
|
35 |
+
baseURL: "https://newinsane.info",
|
36 |
+
headers: { "User-Agent": USER_AGENT },
|
37 |
+
}));
|
38 |
+
const formData = new FormData();
|
39 |
+
formData.append("username", user);
|
40 |
+
formData.append("password", password);
|
41 |
+
await client.post("/login.php", formData);
|
42 |
+
const torrents = [];
|
43 |
+
let page = 0;
|
44 |
+
while (page <= 5) {
|
45 |
+
try {
|
46 |
+
let torrentsOnPage = 0;
|
47 |
+
let params = new URLSearchParams({
|
48 |
+
page: page.toString(),
|
49 |
+
search: searchQuery,
|
50 |
+
searchsort: "normal",
|
51 |
+
searchtype: "desc",
|
52 |
+
torart: "tor",
|
53 |
+
});
|
54 |
+
for (const category of categories) {
|
55 |
+
params.append("cat[]", category.toString());
|
56 |
+
}
|
57 |
+
const link = `/browse.php?${params.toString()}}`;
|
58 |
+
const torrentsPage = await client.get(link);
|
59 |
+
const $ = cheerio.load(torrentsPage.data);
|
60 |
+
for (const el of $("tr.torrentrow")) {
|
61 |
+
torrentsOnPage++;
|
62 |
+
const tracker = "iNSANE";
|
63 |
+
const name = $(el).find("a.torrentname").attr("title");
|
64 |
+
const category = parseCategory($(el).find("td.caticon > a > img").attr("title"));
|
65 |
+
const size = parseSize($(el).find("td.size").text());
|
66 |
+
const seeds = Number($(el).find("td.data > a:nth-of-type(1)").text());
|
67 |
+
const peers = Number($(el).find("td.data > a:nth-of-type(2)").text());
|
68 |
+
const torrent = $(el).find("a.downloadicon").attr("href");
|
69 |
+
if (!name || !torrent)
|
70 |
+
continue;
|
71 |
+
torrents.push({
|
72 |
+
name,
|
73 |
+
tracker,
|
74 |
+
category,
|
75 |
+
size,
|
76 |
+
seeds,
|
77 |
+
peers,
|
78 |
+
torrent,
|
79 |
+
});
|
80 |
+
}
|
81 |
+
if (torrentsOnPage < 25)
|
82 |
+
break;
|
83 |
+
page++;
|
84 |
+
}
|
85 |
+
catch {
|
86 |
+
continue;
|
87 |
+
}
|
88 |
+
}
|
89 |
+
return torrents;
|
90 |
+
}
|
91 |
+
catch (error) {
|
92 |
+
return [];
|
93 |
+
}
|
94 |
+
};
|
95 |
+
const parseCategory = (category) => {
|
96 |
+
const categories = {
|
97 |
+
"Film/Hun/SD": "Movies/SD/HU",
|
98 |
+
"Film/Hun/HD": "Movies/HD/HU",
|
99 |
+
"Film/Hun/UHD": "Movies/UHD/HU",
|
100 |
+
"Film/Eng/SD": "Movies/SD/EN",
|
101 |
+
"Film/Eng/HD": "Movies/HD/EN",
|
102 |
+
"Film/Eng/UHD": "Movies/UHD/EN",
|
103 |
+
"Sorozat/Hun": "TV/SD/HU",
|
104 |
+
"Sorozat/Hun/HD": "TV/HD/HU",
|
105 |
+
"Sorozat/Hun/UHD": "TV/UHD/HU",
|
106 |
+
"Sorozat/Eng": "TV/SD/EN",
|
107 |
+
"Sorozat/Eng/HD": "TV/HD/EN",
|
108 |
+
"Sorozat/Eng/UHD": "TV/UHD/EN",
|
109 |
+
};
|
110 |
+
return categories[category];
|
111 |
+
};
|
112 |
+
const parseSize = (sizeStr) => {
|
113 |
+
const size = sizeStr.replace(",", ".").trim();
|
114 |
+
let bytes = 0;
|
115 |
+
if (size.endsWith("TiB"))
|
116 |
+
bytes = (Number(size.replace("TiB", "")) || 0) * 1024 ** 4;
|
117 |
+
else if (size.endsWith("GiB"))
|
118 |
+
bytes = (Number(size.replace("GiB", "")) || 0) * 1024 ** 3;
|
119 |
+
else if (size.endsWith("MiB"))
|
120 |
+
bytes = (Number(size.replace("MiB", "")) || 0) * 1024 ** 2;
|
121 |
+
else if (size.endsWith("KiB"))
|
122 |
+
bytes = (Number(size.replace("KiB", "")) || 0) * 1024;
|
123 |
+
else if (size.endsWith("B"))
|
124 |
+
bytes = Number(size.replace("B", "")) || 0;
|
125 |
+
return Math.ceil(bytes);
|
126 |
+
};
|
127 |
+
//# sourceMappingURL=insane.js.map
|
dist/torrent/insane.js.map
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"version":3,"file":"insane.js","sourceRoot":"","sources":["../../src/torrent/insane.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGzC,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC;AAC5C,MAAM,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC;AAEpD,MAAM,UAAU,GACd,+HAA+H,CAAC;AAElI,MAAM,CAAN,IAAY,cAa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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import axios from "axios";
|
2 |
+
import * as cheerio from "cheerio";
|
3 |
+
export var ItorrentCategory;
|
4 |
+
(function (ItorrentCategory) {
|
5 |
+
ItorrentCategory[ItorrentCategory["Film"] = 3] = "Film";
|
6 |
+
ItorrentCategory[ItorrentCategory["Sorozat"] = 4] = "Sorozat";
|
7 |
+
})(ItorrentCategory || (ItorrentCategory = {}));
|
8 |
+
export var ItorrentQuality;
|
9 |
+
(function (ItorrentQuality) {
|
10 |
+
ItorrentQuality["SD"] = "sd";
|
11 |
+
ItorrentQuality["HD"] = "hd";
|
12 |
+
ItorrentQuality["CAM"] = "cam";
|
13 |
+
})(ItorrentQuality || (ItorrentQuality = {}));
|
14 |
+
export const searchItorrent = async (searchQuery, categories, qualities) => {
|
15 |
+
const torrents = [];
|
16 |
+
const quality = qualities.join(",");
|
17 |
+
await Promise.all(categories.map(async (category) => {
|
18 |
+
let page = 0;
|
19 |
+
while (page <= 5) {
|
20 |
+
try {
|
21 |
+
page++;
|
22 |
+
let torrentsOnPage = 0;
|
23 |
+
const link = `https://itorrent.ws/torrentek/category/${category}/title/${searchQuery}/qualities[]/${quality}/page/${page}/`;
|
24 |
+
const torrentsPage = await axios.get(link);
|
25 |
+
const $ = cheerio.load(torrentsPage.data);
|
26 |
+
await Promise.all([...$("tr.gradeX")].map(async (el) => {
|
27 |
+
torrentsOnPage++;
|
28 |
+
const tracker = "iTorrent";
|
29 |
+
const torrentAnchor = $(el).find("td.ellipse > a");
|
30 |
+
const torrentHref = torrentAnchor.attr("href");
|
31 |
+
const name = torrentAnchor.text().trim();
|
32 |
+
if (!torrentHref || !name)
|
33 |
+
return;
|
34 |
+
const category = parseCategory($(el).find("i.zqf").attr("title"));
|
35 |
+
const size = parseSize($(el).find("td:nth-child(5)").text().trim());
|
36 |
+
const seeds = Number($(el).find("td:nth-child(7)").text());
|
37 |
+
const peers = Number($(el).find("td:nth-child(8)").text());
|
38 |
+
const torrentPageLink = `https://itorrent.ws${torrentHref}`;
|
39 |
+
let torrent;
|
40 |
+
let magnet;
|
41 |
+
try {
|
42 |
+
const torrentPage = await axios.get(torrentPageLink);
|
43 |
+
const $ = cheerio.load(torrentPage.data);
|
44 |
+
const torrentFileHref = $("a.btn-primary.seed-warning").attr("href");
|
45 |
+
if (torrentFileHref)
|
46 |
+
torrent = `https://itorrent.ws${torrentFileHref}`;
|
47 |
+
magnet = $("a.btn-success.seed-warning").attr("href");
|
48 |
+
if (!torrent && !magnet)
|
49 |
+
return;
|
50 |
+
}
|
51 |
+
catch {
|
52 |
+
return;
|
53 |
+
}
|
54 |
+
torrents.push({
|
55 |
+
name,
|
56 |
+
tracker,
|
57 |
+
category,
|
58 |
+
size,
|
59 |
+
seeds,
|
60 |
+
peers,
|
61 |
+
torrent,
|
62 |
+
magnet,
|
63 |
+
});
|
64 |
+
}));
|
65 |
+
if (torrentsOnPage < 48)
|
66 |
+
break;
|
67 |
+
}
|
68 |
+
catch {
|
69 |
+
continue;
|
70 |
+
}
|
71 |
+
}
|
72 |
+
}));
|
73 |
+
return torrents;
|
74 |
+
};
|
75 |
+
const parseCategory = (category) => {
|
76 |
+
const categories = {
|
77 |
+
"Film/HU/CAM": "Movies/CAM/HU",
|
78 |
+
"Film/HU/SD": "Movies/SD/HU",
|
79 |
+
"Film/HU/HD": "Movies/HD/HU",
|
80 |
+
"Sorozat/HU/SD": "TV/SD/HU",
|
81 |
+
"Sorozat/HU/HD": "TV/HD/HU",
|
82 |
+
};
|
83 |
+
return categories[category];
|
84 |
+
};
|
85 |
+
const parseSize = (size) => {
|
86 |
+
const units = {
|
87 |
+
TB: 1024 ** 4,
|
88 |
+
GB: 1024 ** 3,
|
89 |
+
MB: 1024 ** 2,
|
90 |
+
KB: 1024,
|
91 |
+
B: 1,
|
92 |
+
};
|
93 |
+
const [sizeStr, unit] = size.split(" ");
|
94 |
+
const sizeNum = Number(sizeStr);
|
95 |
+
if (!sizeNum || !units[unit])
|
96 |
+
return 0;
|
97 |
+
return Math.ceil(sizeNum * units[unit]);
|
98 |
+
};
|
99 |
+
//# sourceMappingURL=itorrent.js.map
|
dist/torrent/itorrent.js.map
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"version":3,"file":"itorrent.js","sourceRoot":"","sources":["../../src/torrent/itorrent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAGnC,MAAM,CAAN,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IAC1B,uDAAQ,CAAA;IACR,6DAAW,CAAA;AACb,CAAC,EAHW,gBAAgB,KAAhB,gBAAgB,QAG3B;AAED,MAAM,CAAN,IAAY,eAIX;AAJD,WAAY,eAAe;IACzB,4BAAS,CAAA;IACT,4BAAS,CAAA;IACT,8BAAW,CAAA;AACb,CAAC,EAJW,eAAe,KAAf,eAAe,QAI1B;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,EACjC,WAAmB,EACnB,UAA8B,EAC9B,SAA4B,EACI,EAAE;IAClC,MAAM,QAAQ,GAA0B,EAAE,CAAC;IAC3C,MAAM,OAAO,GAAG,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAEpC,MAAM,OAAO,CAAC,GAAG,CACf,UAAU,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE;QAChC,IAAI,IAAI,GAA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,EAAE,eAAe;QAC9B,YAAY,EAAE,cAAc;QAC5B,YAAY,EAAE,cAAc;QAC5B,eAAe,EAAE,UAAU;QAC3B,eAAe,EAAE,UAAU;KAC5B,CAAC;IAEF,OAAO,UAAU,CAAC,QAAkB,CAAC,CAAC;AACxC,CAAC,CAAC;AAEF,MAAM,SAAS,GAAG,CAAC,IAAY,EAAE,EAAE;IACjC,MAAM,KAAK,GAA2B;QACpC,EAAE,EAAE,IAAI,IAAI,CAAC;QACb,EAAE,EAAE,IAAI,IAAI,CAAC;QACb,EAAE,EAAE,IAAI,IAAI,CAAC;QACb,EAAE,EAAE,IAAI;QACR,CAAC,EAAE,CAAC;KACL,CAAC;IAEF,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACxC,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;IAEhC,IAAI,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;QAAE,OAAO,CAAC,CAAC;IAEvC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;AAC1C,CAAC,CAAC"}
|
dist/torrent/jackett.js
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { JackettApi } from "ts-jackett-api";
|
2 |
+
const JACKETT_URL = process.env.JACKETT_URL;
|
3 |
+
const JACKETT_KEY = process.env.JACKETT_KEY;
|
4 |
+
export const searchJackett = async (searchQuery, categories, jackettUrl, jackettKey) => {
|
5 |
+
try {
|
6 |
+
const url = jackettUrl || JACKETT_URL;
|
7 |
+
const key = jackettKey || JACKETT_KEY;
|
8 |
+
if (!url || !key)
|
9 |
+
return [];
|
10 |
+
const client = new JackettApi(url, key);
|
11 |
+
const res = await client.search({
|
12 |
+
query: searchQuery,
|
13 |
+
category: categories,
|
14 |
+
});
|
15 |
+
return res.Results.map((result) => ({
|
16 |
+
name: result.Title,
|
17 |
+
tracker: result.Tracker,
|
18 |
+
category: result.CategoryDesc || undefined,
|
19 |
+
size: result.Size,
|
20 |
+
seeds: result.Seeders,
|
21 |
+
peers: result.Peers,
|
22 |
+
torrent: result.Link || undefined,
|
23 |
+
magnet: result.MagnetUri || undefined,
|
24 |
+
}));
|
25 |
+
}
|
26 |
+
catch (error) {
|
27 |
+
return [];
|
28 |
+
}
|
29 |
+
};
|
30 |
+
//# sourceMappingURL=jackett.js.map
|
dist/torrent/jackett.js.map
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"version":3,"file":"jackett.js","sourceRoot":"","sources":["../../src/torrent/jackett.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAI5C,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC;AAC5C,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC;AAE5C,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,EAChC,WAAmB,EACnB,UAA6B,EAC7B,UAAmB,EACnB,UAAmB,EACa,EAAE;IAClC,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,UAAU,IAAI,WAAW,CAAC;QACtC,MAAM,GAAG,GAAG,UAAU,IAAI,WAAW,CAAC;QAEtC,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG;YAAE,OAAO,EAAE,CAAC;QAE5B,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAExC,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC;YAC9B,KAAK,EAAE,WAAW;YAClB,QAAQ,EAAE,UAAU;SACrB,CAAC,CAAC;QAEH,O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from "cheerio";
|
4 |
+
import { CookieJar } from "tough-cookie";
|
5 |
+
import { isImdbId } from "../utils/imdb.js";
|
6 |
+
const NCORE_USER = process.env.NCORE_USER;
|
7 |
+
const NCORE_PASSWORD = process.env.NCORE_PASSWORD;
|
8 |
+
export var NcoreCategory;
|
9 |
+
(function (NcoreCategory) {
|
10 |
+
NcoreCategory["Film_SD_HU"] = "xvid_hun";
|
11 |
+
NcoreCategory["Film_SD_EN"] = "xvid";
|
12 |
+
NcoreCategory["Film_HD_HU"] = "hd_hun";
|
13 |
+
NcoreCategory["Film_HD_EN"] = "hd";
|
14 |
+
NcoreCategory["Sorozat_SD_HU"] = "xvidser_hun";
|
15 |
+
NcoreCategory["Sorozat_SD_EN"] = "xvidser";
|
16 |
+
NcoreCategory["Sorozat_HD_HU"] = "hdser_hun";
|
17 |
+
NcoreCategory["Sorozat_HD_EN"] = "hdser";
|
18 |
+
})(NcoreCategory || (NcoreCategory = {}));
|
19 |
+
export const searchNcore = async (searchQuery, categories, ncoreUser, ncorePassword) => {
|
20 |
+
try {
|
21 |
+
const user = ncoreUser || NCORE_USER;
|
22 |
+
const password = ncorePassword || NCORE_PASSWORD;
|
23 |
+
if (!user || !password)
|
24 |
+
return [];
|
25 |
+
const jar = new CookieJar();
|
26 |
+
// @ts-ignore
|
27 |
+
const client = wrapper(axios.create({ jar, baseURL: "https://ncore.pro" }));
|
28 |
+
const formData = new FormData();
|
29 |
+
formData.append("nev", user);
|
30 |
+
formData.append("pass", password);
|
31 |
+
formData.append("set_lang", "hu");
|
32 |
+
formData.append("submitted", "1");
|
33 |
+
await client.post("/login.php", formData);
|
34 |
+
const torrents = [];
|
35 |
+
let page = 0;
|
36 |
+
while (page <= 5) {
|
37 |
+
try {
|
38 |
+
page++;
|
39 |
+
let torrentsOnPage = 0;
|
40 |
+
let params = new URLSearchParams({
|
41 |
+
oldal: page.toString(),
|
42 |
+
tipus: "kivalasztottak_kozott",
|
43 |
+
kivalasztott_tipus: categories.join(","),
|
44 |
+
mire: searchQuery,
|
45 |
+
miben: isImdbId(searchQuery) ? "imdb" : "name",
|
46 |
+
miszerint: "ctime",
|
47 |
+
hogyan: "DESC",
|
48 |
+
});
|
49 |
+
const link = `/torrents.php?${params.toString()}}`;
|
50 |
+
const torrentsPage = await client.get(link);
|
51 |
+
const $ = cheerio.load(torrentsPage.data);
|
52 |
+
const rssUrl = $("link[rel=alternate]").attr("href");
|
53 |
+
const downloadKey = rssUrl?.split("=")[1];
|
54 |
+
if (!downloadKey)
|
55 |
+
return torrents;
|
56 |
+
for (const el of $("div.box_torrent")) {
|
57 |
+
torrentsOnPage++;
|
58 |
+
const name = $(el).find("div.torrent_txt > a").attr("title");
|
59 |
+
const categoryHref = $(el)
|
60 |
+
.find("a > img.categ_link")
|
61 |
+
.parent()
|
62 |
+
.attr("href");
|
63 |
+
const tracker = "nCore";
|
64 |
+
const category = parseCategory(categoryHref?.split("=")[1]);
|
65 |
+
const size = parseSize($(el).find("div.box_meret2").text());
|
66 |
+
const seeds = Number($(el).find("div.box_s2").text());
|
67 |
+
const peers = Number($(el).find("div.box_l2").text());
|
68 |
+
const torrentId = $(el).next().next().attr("id");
|
69 |
+
const torrent = `https://ncore.pro/torrents.php?action=download&id=${torrentId}&key=${downloadKey}`;
|
70 |
+
if (!name || !torrentId)
|
71 |
+
continue;
|
72 |
+
torrents.push({
|
73 |
+
name,
|
74 |
+
tracker,
|
75 |
+
category,
|
76 |
+
size,
|
77 |
+
seeds,
|
78 |
+
peers,
|
79 |
+
torrent,
|
80 |
+
});
|
81 |
+
}
|
82 |
+
if (torrentsOnPage < 50)
|
83 |
+
break;
|
84 |
+
}
|
85 |
+
catch {
|
86 |
+
continue;
|
87 |
+
}
|
88 |
+
}
|
89 |
+
return torrents;
|
90 |
+
}
|
91 |
+
catch (error) {
|
92 |
+
return [];
|
93 |
+
}
|
94 |
+
};
|
95 |
+
const parseCategory = (category) => {
|
96 |
+
const categories = {
|
97 |
+
[NcoreCategory.Film_SD_HU]: "Movies/SD/HU",
|
98 |
+
[NcoreCategory.Film_SD_EN]: "Movies/SD/EN",
|
99 |
+
[NcoreCategory.Film_HD_HU]: "Movies/HD/HU",
|
100 |
+
[NcoreCategory.Film_HD_EN]: "Movies/HD/EN",
|
101 |
+
[NcoreCategory.Sorozat_SD_HU]: "TV/SD/HU",
|
102 |
+
[NcoreCategory.Sorozat_SD_EN]: "TV/SD/EN",
|
103 |
+
[NcoreCategory.Sorozat_HD_HU]: "TV/HD/HU",
|
104 |
+
[NcoreCategory.Sorozat_HD_EN]: "TV/HD/EN",
|
105 |
+
};
|
106 |
+
return categories[category];
|
107 |
+
};
|
108 |
+
const parseSize = (size) => {
|
109 |
+
const units = {
|
110 |
+
TiB: 1024 ** 4,
|
111 |
+
GiB: 1024 ** 3,
|
112 |
+
MiB: 1024 ** 2,
|
113 |
+
KiB: 1024,
|
114 |
+
B: 1,
|
115 |
+
};
|
116 |
+
const [sizeStr, unit] = size.split(" ");
|
117 |
+
const sizeNum = Number(sizeStr);
|
118 |
+
if (!sizeNum || !units[unit])
|
119 |
+
return 0;
|
120 |
+
return Math.ceil(sizeNum * units[unit]);
|
121 |
+
};
|
122 |
+
//# sourceMappingURL=ncore.js.map
|
dist/torrent/ncore.js.map
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"version":3,"file":"ncore.js","sourceRoot":"","sources":["../../src/torrent/ncore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC;AAC1C,MAAM,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { JackettCategory } from "ts-jackett-api/lib/types/JackettCategory.js";
|
2 |
+
import { searchEztv } from "./eztv.js";
|
3 |
+
import { ItorrentCategory, ItorrentQuality, searchItorrent, } from "./itorrent.js";
|
4 |
+
import { searchJackett } from "./jackett.js";
|
5 |
+
import { NcoreCategory, searchNcore } from "./ncore.js";
|
6 |
+
import { searchYts } from "./yts.js";
|
7 |
+
import { InsaneCategory, searchInsane } from "./insane.js";
|
8 |
+
export const searchTorrents = async (query, options) => {
|
9 |
+
const searchAllCategories = !options?.categories?.length;
|
10 |
+
const searchAllSources = !options?.sources?.length;
|
11 |
+
const promises = [];
|
12 |
+
if (options?.sources?.includes("jackett") || searchAllSources) {
|
13 |
+
const categories = new Set();
|
14 |
+
if (options?.categories?.includes("movie") || searchAllCategories) {
|
15 |
+
categories.add(JackettCategory.Movies);
|
16 |
+
}
|
17 |
+
if (options?.categories?.includes("show") || searchAllCategories) {
|
18 |
+
categories.add(JackettCategory.TV);
|
19 |
+
}
|
20 |
+
promises.push(searchJackett(query, Array.from(categories), options?.jackett?.url, options?.jackett?.apiKey));
|
21 |
+
}
|
22 |
+
if (options?.sources?.includes("ncore") || searchAllSources) {
|
23 |
+
const categories = new Set();
|
24 |
+
if (options?.categories?.includes("movie") || searchAllCategories) {
|
25 |
+
categories.add(NcoreCategory.Film_HD_HU);
|
26 |
+
categories.add(NcoreCategory.Film_HD_EN);
|
27 |
+
categories.add(NcoreCategory.Film_SD_HU);
|
28 |
+
categories.add(NcoreCategory.Film_SD_EN);
|
29 |
+
}
|
30 |
+
if (options?.categories?.includes("show") || searchAllCategories) {
|
31 |
+
categories.add(NcoreCategory.Sorozat_HD_HU);
|
32 |
+
categories.add(NcoreCategory.Sorozat_HD_EN);
|
33 |
+
categories.add(NcoreCategory.Sorozat_SD_HU);
|
34 |
+
categories.add(NcoreCategory.Sorozat_SD_EN);
|
35 |
+
}
|
36 |
+
promises.push(searchNcore(query, Array.from(categories), options?.ncore?.user, options?.ncore?.password));
|
37 |
+
}
|
38 |
+
if (options?.sources?.includes("insane") || searchAllSources) {
|
39 |
+
const categories = new Set();
|
40 |
+
if (options?.categories?.includes("movie") || searchAllCategories) {
|
41 |
+
categories.add(InsaneCategory.Film_Hun_SD);
|
42 |
+
categories.add(InsaneCategory.Film_Hun_HD);
|
43 |
+
categories.add(InsaneCategory.Film_Hun_UHD);
|
44 |
+
categories.add(InsaneCategory.Film_Eng_SD);
|
45 |
+
categories.add(InsaneCategory.Film_Eng_HD);
|
46 |
+
categories.add(InsaneCategory.Film_Eng_UHD);
|
47 |
+
}
|
48 |
+
if (options?.categories?.includes("show") || searchAllCategories) {
|
49 |
+
categories.add(InsaneCategory.Sorozat_Hun);
|
50 |
+
categories.add(InsaneCategory.Sorozat_Hun_HD);
|
51 |
+
categories.add(InsaneCategory.Sorozat_Hun_UHD);
|
52 |
+
categories.add(InsaneCategory.Sorozat_Eng);
|
53 |
+
categories.add(InsaneCategory.Sorozat_Eng_HD);
|
54 |
+
categories.add(InsaneCategory.Sorozat_Eng_UHD);
|
55 |
+
}
|
56 |
+
promises.push(searchInsane(query, Array.from(categories), options?.insane?.user, options?.insane?.password));
|
57 |
+
}
|
58 |
+
if (options?.sources?.includes("itorrent") || searchAllSources) {
|
59 |
+
const categories = new Set();
|
60 |
+
if (options?.categories?.includes("movie") || searchAllCategories) {
|
61 |
+
categories.add(ItorrentCategory.Film);
|
62 |
+
}
|
63 |
+
if (options?.categories?.includes("show") || searchAllCategories) {
|
64 |
+
categories.add(ItorrentCategory.Sorozat);
|
65 |
+
}
|
66 |
+
const qualities = [
|
67 |
+
ItorrentQuality.HD,
|
68 |
+
ItorrentQuality.SD,
|
69 |
+
ItorrentQuality.CAM,
|
70 |
+
];
|
71 |
+
promises.push(searchItorrent(query, Array.from(categories), qualities));
|
72 |
+
}
|
73 |
+
if (options?.sources?.includes("yts") || searchAllSources) {
|
74 |
+
if (options?.categories?.includes("movie") || searchAllCategories) {
|
75 |
+
promises.push(searchYts(query));
|
76 |
+
}
|
77 |
+
}
|
78 |
+
if (options?.sources?.includes("eztv") || searchAllSources) {
|
79 |
+
if (options?.categories?.includes("show") || searchAllCategories) {
|
80 |
+
promises.push(searchEztv(query));
|
81 |
+
}
|
82 |
+
}
|
83 |
+
const results = (await Promise.all(promises)).flat();
|
84 |
+
console.log(`Search: got ${results.length} results for ${query}`);
|
85 |
+
return results;
|
86 |
+
};
|
87 |
+
//# sourceMappingURL=search.js.map
|
dist/torrent/search.js.map
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"version":3,"file":"search.js","sourceRoot":"","sources":["../../src/torrent/search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,cAAc,GACf,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAwC3D,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,EACjC,KAAa,EACb,OAA8B,EAC9B,EAAE;IACF,MAAM,mBAAmB,GAAG,CAAC,OAAO,EAAE,UAAU,EAAE,MAAM,CAAC;IACzD,MAAM,gBAAgB,GAAG,CAAC,OAAO,EAA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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import fs from "fs-extra";
|
2 |
+
import MemoryStore from "memory-chunk-store";
|
3 |
+
import os from "os";
|
4 |
+
import path from "path";
|
5 |
+
import WebTorrent from "webtorrent";
|
6 |
+
import { getReadableDuration } from "../utils/file.js";
|
7 |
+
// Directory to store downloaded files (default OS temp directory)
|
8 |
+
const DOWNLOAD_DIR = process.env.DOWNLOAD_DIR || path.join(os.tmpdir(), "torrent-stream-server");
|
9 |
+
// Keep downloaded files after all streams are closed (default false)
|
10 |
+
const KEEP_DOWNLOADED_FILES = process.env.KEEP_DOWNLOADED_FILES
|
11 |
+
? process.env.KEEP_DOWNLOADED_FILES === "true"
|
12 |
+
: false;
|
13 |
+
if (!KEEP_DOWNLOADED_FILES)
|
14 |
+
fs.emptyDirSync(DOWNLOAD_DIR);
|
15 |
+
// Maximum number of connections per torrent (default 50)
|
16 |
+
const MAX_CONNS_PER_TORRENT = Number(process.env.MAX_CONNS_PER_TORRENT) || 50;
|
17 |
+
// Max download speed (bytes/s) over all torrents (default 20MB/s)
|
18 |
+
const DOWNLOAD_SPEED_LIMIT = Number(process.env.DOWNLOAD_SPEED_LIMIT) || 20 * 1024 * 1024;
|
19 |
+
// Max upload speed (bytes/s) over all torrents (default 1MB/s)
|
20 |
+
const UPLOAD_SPEED_LIMIT = Number(process.env.UPLOAD_SPEED_LIMIT) || 1 * 1024 * 1024;
|
21 |
+
// Time (ms) to seed torrents after all streams are closed (default 1 minute)
|
22 |
+
const SEED_TIME = Number(process.env.SEED_TIME) || 60 * 1000;
|
23 |
+
// Timeout (ms) when adding torrents if no metadata is received (default 5 seconds)
|
24 |
+
const TORRENT_TIMEOUT = Number(process.env.TORRENT_TIMEOUT) || 5 * 1000;
|
25 |
+
const infoClient = new WebTorrent();
|
26 |
+
const streamClient = new WebTorrent({
|
27 |
+
// @ts-ignore
|
28 |
+
downloadLimit: DOWNLOAD_SPEED_LIMIT,
|
29 |
+
uploadLimit: UPLOAD_SPEED_LIMIT,
|
30 |
+
maxConns: MAX_CONNS_PER_TORRENT,
|
31 |
+
});
|
32 |
+
streamClient.on("torrent", (torrent) => {
|
33 |
+
console.log(`Added torrent: ${torrent.name}`);
|
34 |
+
});
|
35 |
+
streamClient.on("error", (error) => {
|
36 |
+
if (typeof error === "string") {
|
37 |
+
console.error(`Error: ${error}`);
|
38 |
+
}
|
39 |
+
else {
|
40 |
+
if (error.message.startsWith("Cannot add duplicate torrent"))
|
41 |
+
return;
|
42 |
+
console.error(`Error: ${error.message}`);
|
43 |
+
}
|
44 |
+
});
|
45 |
+
infoClient.on("error", () => { });
|
46 |
+
const launchTime = Date.now();
|
47 |
+
export const getStats = () => ({
|
48 |
+
uptime: getReadableDuration(Date.now() - launchTime),
|
49 |
+
openStreams: [...openStreams.values()].reduce((a, b) => a + b, 0),
|
50 |
+
downloadSpeed: streamClient.downloadSpeed,
|
51 |
+
uploadSpeed: streamClient.uploadSpeed,
|
52 |
+
activeTorrents: streamClient.torrents.map((torrent) => ({
|
53 |
+
name: torrent.name,
|
54 |
+
infoHash: torrent.infoHash,
|
55 |
+
size: torrent.length,
|
56 |
+
progress: torrent.progress,
|
57 |
+
downloaded: torrent.downloaded,
|
58 |
+
uploaded: torrent.uploaded,
|
59 |
+
downloadSpeed: torrent.downloadSpeed,
|
60 |
+
uploadSpeed: torrent.uploadSpeed,
|
61 |
+
peers: torrent.numPeers,
|
62 |
+
openStreams: openStreams.get(torrent.infoHash) || 0,
|
63 |
+
files: torrent.files.map((file) => ({
|
64 |
+
name: file.name,
|
65 |
+
path: file.path,
|
66 |
+
size: file.length,
|
67 |
+
progress: file.progress,
|
68 |
+
downloaded: file.downloaded,
|
69 |
+
})),
|
70 |
+
})),
|
71 |
+
});
|
72 |
+
export const getOrAddTorrent = (uri) => new Promise((resolve) => {
|
73 |
+
const torrent = streamClient.add(uri, {
|
74 |
+
path: DOWNLOAD_DIR,
|
75 |
+
destroyStoreOnDestroy: !KEEP_DOWNLOADED_FILES,
|
76 |
+
// @ts-ignore
|
77 |
+
deselect: true,
|
78 |
+
}, (torrent) => {
|
79 |
+
clearTimeout(timeout);
|
80 |
+
resolve(torrent);
|
81 |
+
});
|
82 |
+
const timeout = setTimeout(() => {
|
83 |
+
torrent.destroy();
|
84 |
+
resolve(undefined);
|
85 |
+
}, TORRENT_TIMEOUT);
|
86 |
+
});
|
87 |
+
export const getFile = (torrent, path) => torrent.files.find((file) => file.path === path);
|
88 |
+
export const getTorrentInfo = async (uri) => {
|
89 |
+
const getInfo = (torrent) => ({
|
90 |
+
name: torrent.name,
|
91 |
+
infoHash: torrent.infoHash,
|
92 |
+
size: torrent.length,
|
93 |
+
files: torrent.files.map((file) => ({
|
94 |
+
name: file.name,
|
95 |
+
path: file.path,
|
96 |
+
size: file.length,
|
97 |
+
})),
|
98 |
+
});
|
99 |
+
return await new Promise((resolve) => {
|
100 |
+
const torrent = infoClient.add(uri, { store: MemoryStore, destroyStoreOnDestroy: true }, (torrent) => {
|
101 |
+
clearTimeout(timeout);
|
102 |
+
const info = getInfo(torrent);
|
103 |
+
console.log(`Fetched info: ${info.name}`);
|
104 |
+
torrent.destroy();
|
105 |
+
resolve(info);
|
106 |
+
});
|
107 |
+
const timeout = setTimeout(() => {
|
108 |
+
torrent.destroy();
|
109 |
+
resolve(undefined);
|
110 |
+
}, TORRENT_TIMEOUT);
|
111 |
+
});
|
112 |
+
};
|
113 |
+
const timeouts = new Map();
|
114 |
+
const openStreams = new Map();
|
115 |
+
export const streamOpened = (hash, fileName) => {
|
116 |
+
console.log(`Stream opened: ${fileName}`);
|
117 |
+
const count = openStreams.get(hash) || 0;
|
118 |
+
openStreams.set(hash, count + 1);
|
119 |
+
const timeout = timeouts.get(hash);
|
120 |
+
if (timeout) {
|
121 |
+
clearTimeout(timeout);
|
122 |
+
timeouts.delete(hash);
|
123 |
+
}
|
124 |
+
};
|
125 |
+
export const streamClosed = (hash, fileName) => {
|
126 |
+
console.log(`Stream closed: ${fileName}`);
|
127 |
+
const count = openStreams.get(hash) || 1;
|
128 |
+
openStreams.set(hash, count - 1);
|
129 |
+
if (count > 1)
|
130 |
+
return;
|
131 |
+
openStreams.delete(hash);
|
132 |
+
let timeout = timeouts.get(hash);
|
133 |
+
if (timeout)
|
134 |
+
return;
|
135 |
+
timeout = setTimeout(async () => {
|
136 |
+
const torrent = await streamClient.get(hash);
|
137 |
+
// @ts-ignore
|
138 |
+
torrent?.destroy(undefined, () => {
|
139 |
+
console.log(`Removed torrent: ${torrent.name}`);
|
140 |
+
timeouts.delete(hash);
|
141 |
+
});
|
142 |
+
}, SEED_TIME);
|
143 |
+
timeouts.set(hash, timeout);
|
144 |
+
};
|
145 |
+
//# sourceMappingURL=webtorrent.js.map
|
dist/torrent/webtorrent.js.map
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"version":3,"file":"webtorrent.js","sourceRoot":"","sources":["../../src/torrent/webtorrent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,WAAW,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,UAAuB,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAgCvD,kEAAkE;AAClE,MAAM,YAAY,GAChB,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,uBAAuB,CAAC,CAAC;AAE9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oB,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;YAChD,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACxB,CAAC,CAAC,CAAC;IACL,CAAC,EAAE,SAAS,CAAC,CAAC;IAEd,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAC9B,CAAC,CAAC"}
|
dist/torrent/yts.js
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { details, search } from "yts-api-node";
|
2 |
+
import { isImdbId } from "../utils/imdb.js";
|
3 |
+
const trackers = [
|
4 |
+
"udp://glotorrents.pw:6969/announce",
|
5 |
+
"udp://tracker.opentrackr.org:1337/announce",
|
6 |
+
"udp://torrent.gresille.org:80/announce",
|
7 |
+
"udp://tracker.openbittorrent.com:80",
|
8 |
+
"udp://tracker.coppersurfer.tk:6969",
|
9 |
+
"udp://tracker.leechers-paradise.org:6969",
|
10 |
+
"udp://p4p.arenabg.ch:1337",
|
11 |
+
"udp://tracker.internetwarriors.net:1337",
|
12 |
+
];
|
13 |
+
const trackersString = "&tr=" + trackers.join("&tr=");
|
14 |
+
export const searchYts = async (searchQuery) => {
|
15 |
+
try {
|
16 |
+
if (isImdbId(searchQuery)) {
|
17 |
+
const res = await details({ movie_id: searchQuery });
|
18 |
+
return res.data.movie.torrents.map((torrent) => ({
|
19 |
+
name: `${res.data.movie.title_long} ${torrent.quality} ${torrent.type
|
20 |
+
.replace("bluray", "BluRay")
|
21 |
+
.replace("web", "WEB")}`,
|
22 |
+
tracker: "YTS",
|
23 |
+
category: `Movies/${torrent.quality}`,
|
24 |
+
size: torrent.size_bytes,
|
25 |
+
seeds: torrent.seeds,
|
26 |
+
peers: torrent.peers,
|
27 |
+
torrent: torrent.url,
|
28 |
+
magnet: `magnet:?xt=urn:btih:${torrent.hash}${trackersString}`,
|
29 |
+
}));
|
30 |
+
}
|
31 |
+
else {
|
32 |
+
const res = await search({ query_term: searchQuery });
|
33 |
+
return res.data.movies.flatMap((movie) => movie.torrents.map((torrent) => ({
|
34 |
+
name: `${movie.title_long} ${torrent.quality} ${torrent.type
|
35 |
+
.replace("bluray", "BluRay")
|
36 |
+
.replace("web", "WEB")}`,
|
37 |
+
tracker: "YTS",
|
38 |
+
category: `Movies/${torrent.quality}`,
|
39 |
+
size: torrent.size_bytes,
|
40 |
+
seeds: torrent.seeds,
|
41 |
+
peers: torrent.peers,
|
42 |
+
torrent: torrent.url,
|
43 |
+
magnet: `magnet:?xt=urn:btih:${torrent.hash}${trackersString}`,
|
44 |
+
})));
|
45 |
+
}
|
46 |
+
}
|
47 |
+
catch (error) {
|
48 |
+
return [];
|
49 |
+
}
|
50 |
+
};
|
51 |
+
//# sourceMappingURL=yts.js.map
|
dist/torrent/yts.js.map
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"version":3,"file":"yts.js","sourceRoot":"","sources":["../../src/torrent/yts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,MAAM,QAAQ,GAAG;IACf,oCAAoC;IACpC,4CAA4C;IAC5C,wCAAwC;IACxC,qCAAqC;IACrC,oCAAoC;IACpC,0CAA0C;IAC1C,2BAA2B;IAC3B,yCAAyC;CAC1C,CAAC;AAEF,MAAM,cAAc,GAAG,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAEtD,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,EAC5B,WAAmB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AAK,EAAE,KAAK,CAAC,EAAE;gBAC1B,OAAO,EAAE,KAAK;gBACd,QAAQ,EAAE,UAAU,OAAO,CAAC,OAAO,EAAE;gBACrC,IAAI,EAAE,OAAO,CAAC,UAAU;gBACxB,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,OAAO,EAAE,OAAO,CAAC,GAAG;gBACpB,MAAM,EAAE,uBAAuB,OAAO,CAAC,IAAI,GAAG,cAAc,EAAE;aAC/D,CAAC,CAAC,CACJ,CAAC;QACJ,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC,CAAC"}
|
dist/utils/dotenv.js
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
import dotenv from "dotenv";
|
2 |
+
dotenv.config();
|
3 |
+
//# sourceMappingURL=dotenv.js.map
|
dist/utils/dotenv.js.map
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"version":3,"file":"dotenv.js","sourceRoot":"","sources":["../../src/utils/dotenv.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,MAAM,CAAC,MAAM,EAAE,CAAC"}
|
dist/utils/file.js
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import mime from "mime";
|
2 |
+
export const isVideoFile = (filename) => mime.getType(filename)?.startsWith("video") || false;
|
3 |
+
export const isSubtitleFile = (filename) => filename.toLowerCase().endsWith(".srt") ||
|
4 |
+
filename.toLowerCase().endsWith(".sub") ||
|
5 |
+
filename.toLowerCase().endsWith(".vtt") ||
|
6 |
+
filename.toLowerCase().endsWith(".smi") ||
|
7 |
+
filename.toLowerCase().endsWith(".ssa") ||
|
8 |
+
filename.toLowerCase().endsWith(".ass") ||
|
9 |
+
filename.toLowerCase().endsWith(".txt");
|
10 |
+
export const getStreamingMimeType = (filename) => {
|
11 |
+
const mimeType = mime.getType(filename);
|
12 |
+
return mimeType?.startsWith("video")
|
13 |
+
? "video/mp4"
|
14 |
+
: mimeType || "application/unknown";
|
15 |
+
};
|
16 |
+
export const getReadableSize = (bytes) => {
|
17 |
+
if (bytes == 0) {
|
18 |
+
return "0.00 B";
|
19 |
+
}
|
20 |
+
var e = Math.floor(Math.log(bytes) / Math.log(1024));
|
21 |
+
return ((bytes / Math.pow(1024, e)).toFixed(2) + " " + " KMGTP".charAt(e) + "B");
|
22 |
+
};
|
23 |
+
export const getReadableDuration = (millisecs) => {
|
24 |
+
var seconds = (millisecs / 1000).toFixed(1);
|
25 |
+
var minutes = (millisecs / (1000 * 60)).toFixed(1);
|
26 |
+
var hours = (millisecs / (1000 * 60 * 60)).toFixed(1);
|
27 |
+
var days = (millisecs / (1000 * 60 * 60 * 24)).toFixed(1);
|
28 |
+
if (Number(seconds) < 60) {
|
29 |
+
return seconds + " seconds";
|
30 |
+
}
|
31 |
+
else if (Number(minutes) < 60) {
|
32 |
+
return minutes + " minutes";
|
33 |
+
}
|
34 |
+
else if (Number(hours) < 24) {
|
35 |
+
return hours + " hours";
|
36 |
+
}
|
37 |
+
else {
|
38 |
+
return days + " days";
|
39 |
+
}
|
40 |
+
};
|
41 |
+
//# sourceMappingURL=file.js.map
|
dist/utils/file.js.map
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"version":3,"file":"file.js","sourceRoot":"","sources":["../../src/utils/file.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,QAAgB,EAAE,EAAE,CAC9C,IAAI,CA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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import axios from "axios";
|
2 |
+
import https from "https";
|
3 |
+
import localtunnel from "localtunnel";
|
4 |
+
var HttpsMethod;
|
5 |
+
(function (HttpsMethod) {
|
6 |
+
HttpsMethod["None"] = "none";
|
7 |
+
HttpsMethod["LocalIpMedic"] = "local-ip.medicmobile.org";
|
8 |
+
HttpsMethod["LocalIpCo"] = "local-ip.co";
|
9 |
+
HttpsMethod["Localtunnel"] = "localtunnel";
|
10 |
+
})(HttpsMethod || (HttpsMethod = {}));
|
11 |
+
const HTTPS_METHOD = process.env.HTTPS_METHOD || HttpsMethod.None;
|
12 |
+
export const serveHTTPS = async (app, port) => {
|
13 |
+
if (HTTPS_METHOD === HttpsMethod.LocalIpMedic) {
|
14 |
+
const json = (await axios.get("https://local-ip.medicmobile.org/keys"))
|
15 |
+
.data;
|
16 |
+
const cert = `${json.cert}\n${json.chain}`;
|
17 |
+
const httpsServer = https.createServer({ key: json.privkey, cert }, app);
|
18 |
+
httpsServer.listen(port);
|
19 |
+
console.log(`HTTPS addon listening on port ${port}`);
|
20 |
+
return httpsServer;
|
21 |
+
}
|
22 |
+
if (HTTPS_METHOD === HttpsMethod.LocalIpCo) {
|
23 |
+
const key = (await axios.get("http://local-ip.co/cert/server.key")).data;
|
24 |
+
const serverPem = (await axios.get("http://local-ip.co/cert/server.pem"))
|
25 |
+
.data;
|
26 |
+
const chainPem = (await axios.get("http://local-ip.co/cert/chain.pem"))
|
27 |
+
.data;
|
28 |
+
const cert = `${serverPem}\n${chainPem}`;
|
29 |
+
const httpsServer = https.createServer({ key, cert }, app);
|
30 |
+
httpsServer.listen(port);
|
31 |
+
console.log(`HTTPS addon listening on port ${port}`);
|
32 |
+
return httpsServer;
|
33 |
+
}
|
34 |
+
if (HTTPS_METHOD === HttpsMethod.Localtunnel) {
|
35 |
+
const tunnel = await localtunnel({ port: Number(process.env.PORT) });
|
36 |
+
console.log(`Tunnel accessible at: ${tunnel.url}`);
|
37 |
+
const tunnelPassword = await axios.get("https://loca.lt/mytunnelpassword");
|
38 |
+
console.log(`Tunnel password: ${tunnelPassword.data}`);
|
39 |
+
}
|
40 |
+
};
|
41 |
+
//# sourceMappingURL=https.js.map
|
dist/utils/https.js.map
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"version":3,"file":"https.js","sourceRoot":"","sources":["../../src/utils/https.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,WAAW,MAAM,aAAa,CAAC;AAEtC,IAAK,WAKJ;AALD,WAAK,WAAW;IACd,4BAAa,CAAA;IACb,wDAAyC,CAAA;IACzC,wCAAyB,CAAA;IACzB,0CAA2B,CAAA;AAC7B,CAAC,EALI,WAAW,KAAX,WAAW,QAKf;AAED,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,WAAW,CAAC,IAAI,CAAC;AAElE,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,EAAE,GAAoB,EAAE,IAAY,EAAE,EAAE;IACrE,IAAI,YAAY,KAAK,WAAW,CAAC,YAAY,EAAE,CAAC;QAC9C,MAAM,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,GAAG,CAAC,uCAAuC,CAAC,CAAC;aACpE,IAAI,CAAC;QACR,MAAM,IAAI,GAAG,GAAG,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,KAAK,EAAE,CAAC;QAC3C,MAAM,WAAW,GAAG,KAAK,CAAC,YAAY,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC;QACzE,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACzB,OAAO,CAAC,GAAG,CAAC,iCAAiC,IAAI,EAAE,CAAC,CAAC;QACrD,OAAO,WAAW,CAAC;I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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import axios from "axios";
|
2 |
+
export const getTitle = async (imdbId, language) => {
|
3 |
+
try {
|
4 |
+
const data = (await axios.get(`https://www.imdb.com/title/${imdbId}`, {
|
5 |
+
headers: {
|
6 |
+
"Accept-Language": language,
|
7 |
+
"Accept-Encoding": "gzip,deflate,compress",
|
8 |
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3",
|
9 |
+
},
|
10 |
+
})).data;
|
11 |
+
const title = data.match(/<title>(.*?)<\/title>/)[1];
|
12 |
+
if (!title)
|
13 |
+
return undefined;
|
14 |
+
return title.split(" (")[0];
|
15 |
+
}
|
16 |
+
catch {
|
17 |
+
return undefined;
|
18 |
+
}
|
19 |
+
};
|
20 |
+
export const getTitles = async (imdbId) => {
|
21 |
+
const titles = new Set();
|
22 |
+
(await Promise.all([getTitle(imdbId), getTitle(imdbId, "en")])).forEach((title) => {
|
23 |
+
if (title)
|
24 |
+
titles.add(title);
|
25 |
+
});
|
26 |
+
return [...titles];
|
27 |
+
};
|
28 |
+
export const isImdbId = (str) => /ev\d{7}\/\d{4}(-\d)?|(ch|co|ev|nm|tt)\d{7}/.test(str);
|
29 |
+
//# sourceMappingURL=imdb.js.map
|
dist/utils/imdb.js.map
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"version":3,"file":"imdb.js","sourceRoot":"","sources":["../../src/utils/imdb.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,EAAE,MAAc,EAAE,QAAiB,EAAE,EAAE;IAClE,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,CACX,MAAM,KAAK,CAAC,GAAG,CAAC,8BAA8B,MAAM,EAAE,EAAE;YACtD,OAAO,EAAE;gBACP,iBAAiB,EAAE,QAAQ;gBAC3B,iBAAiB,EAAE,uBAAuB;gBAC1C,YAAY,EACV,oHAAoH;aACvH;SACF,CAAC,CACH,CAAC,IAAI,CAAC;QAEP,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAW,CAAC;QAC/D,IAAI,CAAC,KAAK;YAAE,OAAO,SAAS,CAAC;QAC7B,OAAO,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,EAAE,MAAc,EAAE,EAAE;IAChD,MAAM,MAAM,GAAG,IAAI,GAAG,EAAU,CAAC;IAEjC,CAAC,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CACrE,CAAC,KAAK,EAAE,EAAE;QACR,IAAI,KAAK;YAAE,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC,CACF,CAAC;IAEF,OAAO,CAAC,GAAG,MAAM,CAAC,CAAC;AACrB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAE,EAAE,CACtC,4CAA4C,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC"}
|
dist/utils/language.js
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
export const guessLanguage = (name, category) => {
|
2 |
+
if (category?.includes("HU"))
|
3 |
+
return "Hungarian";
|
4 |
+
const split = name
|
5 |
+
.toLowerCase()
|
6 |
+
.replace(/\W/g, " ")
|
7 |
+
.replace("x", " ")
|
8 |
+
.split(" ");
|
9 |
+
if (split.includes("hun") || split.includes("hungarian"))
|
10 |
+
return "Hungarian";
|
11 |
+
if (split.includes("ger") || split.includes("german"))
|
12 |
+
return "German";
|
13 |
+
if (split.includes("fre") || split.includes("french"))
|
14 |
+
return "French";
|
15 |
+
if (split.includes("ita") || split.includes("italian"))
|
16 |
+
return "Italian";
|
17 |
+
return "English";
|
18 |
+
};
|
19 |
+
//# sourceMappingURL=language.js.map
|
dist/utils/language.js.map
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"version":3,"file":"language.js","sourceRoot":"","sources":["../../src/utils/language.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,IAAY,EAAE,QAAiB,EAAE,EAAE;IAC/D,IAAI,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC;QAAE,OAAO,WAAW,CAAC;IAEjD,MAAM,KAAK,GAAG,IAAI;SACf,WAAW,EAAE;SACb,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;SACnB,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC;SACjB,KAAK,CAAC,GAAG,CAAC,CAAC;IAEd,IAAI,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC;QAAE,OAAO,WAAW,CAAC;IAC7E,IAAI,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC;QAAE,OAAO,QAAQ,CAAC;IACvE,IAAI,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC;QAAE,OAAO,QAAQ,CAAC;IACvE,IAAI,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC;QAAE,OAAO,SAAS,CAAC;IAEzE,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC"}
|
dist/utils/quality.js
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
export const guessQuality = (name) => {
|
2 |
+
const split = name.replace(/\W/g, " ").toLowerCase().split(" ");
|
3 |
+
let score = 0;
|
4 |
+
const parts = [];
|
5 |
+
if (split.includes("2160p")) {
|
6 |
+
parts.push("4K");
|
7 |
+
score += 3000;
|
8 |
+
}
|
9 |
+
else if (split.includes("1080p")) {
|
10 |
+
parts.push("1080p");
|
11 |
+
score += 2000;
|
12 |
+
}
|
13 |
+
else if (split.includes("720p")) {
|
14 |
+
parts.push("720p");
|
15 |
+
score += 1000;
|
16 |
+
}
|
17 |
+
if ((split.includes("dolby") && split.includes("vision")) ||
|
18 |
+
split.includes("dovi") ||
|
19 |
+
split.includes("dv")) {
|
20 |
+
parts.push("Dolby Vision");
|
21 |
+
score += 20;
|
22 |
+
}
|
23 |
+
else if (split.includes("hdr")) {
|
24 |
+
parts.push("HDR");
|
25 |
+
score += 10;
|
26 |
+
}
|
27 |
+
if (split.includes("bluray") ||
|
28 |
+
(split.includes("blu") && split.includes("ray")) ||
|
29 |
+
split.includes("bdrip") ||
|
30 |
+
split.includes("brrip")) {
|
31 |
+
parts.push("BluRay");
|
32 |
+
score += 500;
|
33 |
+
if (split.includes("remux")) {
|
34 |
+
parts.push("Remux");
|
35 |
+
score += 100;
|
36 |
+
}
|
37 |
+
}
|
38 |
+
else if (split.includes("webrip") ||
|
39 |
+
split.includes("webdl") ||
|
40 |
+
split.includes("web")) {
|
41 |
+
parts.push("WEB");
|
42 |
+
score += 400;
|
43 |
+
}
|
44 |
+
else if (split.includes("dvdrip")) {
|
45 |
+
parts.push("DVD");
|
46 |
+
score += 300;
|
47 |
+
}
|
48 |
+
else if (split.includes("hdtv")) {
|
49 |
+
parts.push("HDTV");
|
50 |
+
score += 200;
|
51 |
+
}
|
52 |
+
else if (split.includes("sdtv")) {
|
53 |
+
parts.push("sdtv");
|
54 |
+
score += 100;
|
55 |
+
}
|
56 |
+
else if (split.includes("camrip") ||
|
57 |
+
split.includes("cam") ||
|
58 |
+
split.includes("hdcam") ||
|
59 |
+
split.includes("ts") ||
|
60 |
+
split.includes("hdts") ||
|
61 |
+
split.includes("tc") ||
|
62 |
+
split.includes("hdtc")) {
|
63 |
+
parts.push("CAM");
|
64 |
+
score -= 5000;
|
65 |
+
}
|
66 |
+
if (split.includes("3d")) {
|
67 |
+
parts.push("3D");
|
68 |
+
score -= 1;
|
69 |
+
}
|
70 |
+
if (parts.length === 0) {
|
71 |
+
parts.push("Unknown");
|
72 |
+
score = -Infinity;
|
73 |
+
}
|
74 |
+
return { quality: parts.join(" "), score };
|
75 |
+
};
|
76 |
+
//# sourceMappingURL=quality.js.map
|
dist/utils/quality.js.map
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"version":3,"file":"quality.js","sourceRoot":"","sources":["../../src/utils/quality.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAY,EAAE,EAAE;IAC3C,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAEhE,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,MAAM,KAAK,GAAG,EAAE,CAAC;IAEjB,I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AChB,CAAC;IAED,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACzB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjB,KAAK,IAAI,CAAC,CAAC;IACb,CAAC;IAED,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACtB,KAAK,GAAG,CAAC,QAAQ,CAAC;IACpB,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC;AAC7C,CAAC,CAAC"}
|
dist/utils/shows.js
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
export const guessSeasonEpisode = (name) => {
|
2 |
+
const str = name.replace(/\W/g, " ").toLowerCase();
|
3 |
+
const seasonMatch = [...str.matchAll(/[s](?<season>\d+)/g)];
|
4 |
+
const episodeMatch = str.match(/[e](?<episode>\d+)/);
|
5 |
+
if (seasonMatch.length === 0 && str.includes("complete")) {
|
6 |
+
return { completeSeries: true };
|
7 |
+
}
|
8 |
+
else if (seasonMatch.length === 1 && !episodeMatch) {
|
9 |
+
const season = Number(seasonMatch[0].groups?.season) || 0;
|
10 |
+
return { seasons: [season] };
|
11 |
+
}
|
12 |
+
else if (seasonMatch.length > 1) {
|
13 |
+
const firstSeason = Number(seasonMatch[0].groups?.season) || 0;
|
14 |
+
const lastSeason = Number(seasonMatch[seasonMatch.length - 1].groups?.season) || 0;
|
15 |
+
const seasons = [];
|
16 |
+
for (let i = firstSeason; i <= lastSeason; i++)
|
17 |
+
seasons.push(i);
|
18 |
+
return { seasons };
|
19 |
+
}
|
20 |
+
else if (seasonMatch[0] || episodeMatch) {
|
21 |
+
const season = Number(seasonMatch[0]?.groups?.season) || undefined;
|
22 |
+
const episode = Number(episodeMatch?.groups?.episode) || undefined;
|
23 |
+
return { season, episode };
|
24 |
+
}
|
25 |
+
else {
|
26 |
+
const seasonEpisodeMatch = str.match(/(?<season>\d+)x(?<episode>\d+)/);
|
27 |
+
const season = Number(seasonEpisodeMatch?.groups?.season) || undefined;
|
28 |
+
const episode = Number(seasonEpisodeMatch?.groups?.episode) || undefined;
|
29 |
+
return { season, episode };
|
30 |
+
}
|
31 |
+
};
|
32 |
+
export const isTorrentNameMatch = (name, season, episode) => {
|
33 |
+
const guess = guessSeasonEpisode(name);
|
34 |
+
if (guess.completeSeries)
|
35 |
+
return true;
|
36 |
+
if (guess.seasons?.includes(season))
|
37 |
+
return true;
|
38 |
+
if (guess.season === season && guess.episode === episode)
|
39 |
+
return true;
|
40 |
+
if (season === 0) {
|
41 |
+
if (name.toLowerCase().includes("special"))
|
42 |
+
return true;
|
43 |
+
if (guess.season === undefined && guess.seasons === undefined)
|
44 |
+
return true;
|
45 |
+
}
|
46 |
+
return false;
|
47 |
+
};
|
48 |
+
export const isFileNameMatch = (name, season, episode) => {
|
49 |
+
const guess = guessSeasonEpisode(name);
|
50 |
+
if (guess.season === season && guess.episode === episode)
|
51 |
+
return true;
|
52 |
+
if (season === 0)
|
53 |
+
return true;
|
54 |
+
return false;
|
55 |
+
};
|
56 |
+
//# sourceMappingURL=shows.js.map
|
dist/utils/shows.js.map
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"version":3,"file":"shows.js","sourceRoot":"","sources":["../../src/utils/shows.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,IAAY,EAAE,EAAE;IACjD,MAAM,G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