tor-dl 1.0.13 → 1.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -0
- package/dist/cli/display.d.ts.map +1 -1
- package/dist/cli/display.js +68 -2
- package/dist/cli/display.js.map +1 -1
- package/dist/sources/yts.js +1 -1
- package/dist/sources/yts.js.map +1 -1
- package/package.json +34 -34
- package/src/cli/display.ts +59 -2
- package/src/sources/yts.ts +85 -85
- package/dist/cli/progress.d.ts +0 -15
- package/dist/cli/progress.d.ts.map +0 -1
- package/dist/cli/progress.js +0 -76
- package/dist/cli/progress.js.map +0 -1
- package/dist/src/cli/display.d.ts +0 -7
- package/dist/src/cli/display.d.ts.map +0 -1
- package/dist/src/cli/display.js +0 -59
- package/dist/src/cli/display.js.map +0 -1
- package/dist/src/cli/parser.d.ts +0 -5
- package/dist/src/cli/parser.d.ts.map +0 -1
- package/dist/src/cli/parser.js +0 -122
- package/dist/src/cli/parser.js.map +0 -1
- package/dist/src/cli/progress.d.ts +0 -15
- package/dist/src/cli/progress.d.ts.map +0 -1
- package/dist/src/cli/progress.js +0 -76
- package/dist/src/cli/progress.js.map +0 -1
- package/dist/src/commands/download.d.ts +0 -2
- package/dist/src/commands/download.d.ts.map +0 -1
- package/dist/src/commands/download.js +0 -70
- package/dist/src/commands/download.js.map +0 -1
- package/dist/src/commands/search.d.ts +0 -3
- package/dist/src/commands/search.d.ts.map +0 -1
- package/dist/src/commands/search.js +0 -46
- package/dist/src/commands/search.js.map +0 -1
- package/dist/src/commands/update.d.ts +0 -2
- package/dist/src/commands/update.d.ts.map +0 -1
- package/dist/src/commands/update.js +0 -32
- package/dist/src/commands/update.js.map +0 -1
- package/dist/src/download/engine.d.ts +0 -6
- package/dist/src/download/engine.d.ts.map +0 -1
- package/dist/src/download/engine.js +0 -163
- package/dist/src/download/engine.js.map +0 -1
- package/dist/src/filters/category.d.ts +0 -3
- package/dist/src/filters/category.d.ts.map +0 -1
- package/dist/src/filters/category.js +0 -24
- package/dist/src/filters/category.js.map +0 -1
- package/dist/src/filters/index.d.ts +0 -5
- package/dist/src/filters/index.d.ts.map +0 -1
- package/dist/src/filters/index.js +0 -13
- package/dist/src/filters/index.js.map +0 -1
- package/dist/src/filters/seeds.d.ts +0 -3
- package/dist/src/filters/seeds.d.ts.map +0 -1
- package/dist/src/filters/seeds.js +0 -7
- package/dist/src/filters/seeds.js.map +0 -1
- package/dist/src/filters/size.d.ts +0 -4
- package/dist/src/filters/size.d.ts.map +0 -1
- package/dist/src/filters/size.js +0 -36
- package/dist/src/filters/size.js.map +0 -1
- package/dist/src/filters/sort.d.ts +0 -5
- package/dist/src/filters/sort.d.ts.map +0 -1
- package/dist/src/filters/sort.js +0 -25
- package/dist/src/filters/sort.js.map +0 -1
- package/dist/src/index.d.ts +0 -11
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/index.js +0 -30
- package/dist/src/index.js.map +0 -1
- package/dist/src/sources/1337x.d.ts +0 -11
- package/dist/src/sources/1337x.d.ts.map +0 -1
- package/dist/src/sources/1337x.js +0 -121
- package/dist/src/sources/1337x.js.map +0 -1
- package/dist/src/sources/eztv.d.ts +0 -11
- package/dist/src/sources/eztv.d.ts.map +0 -1
- package/dist/src/sources/eztv.js +0 -104
- package/dist/src/sources/eztv.js.map +0 -1
- package/dist/src/sources/httpClient.d.ts +0 -24
- package/dist/src/sources/httpClient.d.ts.map +0 -1
- package/dist/src/sources/httpClient.js +0 -42
- package/dist/src/sources/httpClient.js.map +0 -1
- package/dist/src/sources/limetorrent.d.ts +0 -11
- package/dist/src/sources/limetorrent.d.ts.map +0 -1
- package/dist/src/sources/limetorrent.js +0 -113
- package/dist/src/sources/limetorrent.js.map +0 -1
- package/dist/src/sources/nyaa.d.ts +0 -11
- package/dist/src/sources/nyaa.d.ts.map +0 -1
- package/dist/src/sources/nyaa.js +0 -119
- package/dist/src/sources/nyaa.js.map +0 -1
- package/dist/src/sources/rarbg.d.ts +0 -11
- package/dist/src/sources/rarbg.d.ts.map +0 -1
- package/dist/src/sources/rarbg.js +0 -122
- package/dist/src/sources/rarbg.js.map +0 -1
- package/dist/src/sources/registry.d.ts +0 -9
- package/dist/src/sources/registry.d.ts.map +0 -1
- package/dist/src/sources/registry.js +0 -70
- package/dist/src/sources/registry.js.map +0 -1
- package/dist/src/sources/solidtorrents.d.ts +0 -11
- package/dist/src/sources/solidtorrents.d.ts.map +0 -1
- package/dist/src/sources/solidtorrents.js +0 -105
- package/dist/src/sources/solidtorrents.js.map +0 -1
- package/dist/src/sources/thepiratebay.d.ts +0 -11
- package/dist/src/sources/thepiratebay.d.ts.map +0 -1
- package/dist/src/sources/thepiratebay.js +0 -67
- package/dist/src/sources/thepiratebay.js.map +0 -1
- package/dist/src/sources/torlock.d.ts +0 -11
- package/dist/src/sources/torlock.d.ts.map +0 -1
- package/dist/src/sources/torlock.js +0 -116
- package/dist/src/sources/torlock.js.map +0 -1
- package/dist/src/sources/torrentproject.d.ts +0 -11
- package/dist/src/sources/torrentproject.d.ts.map +0 -1
- package/dist/src/sources/torrentproject.js +0 -105
- package/dist/src/sources/torrentproject.js.map +0 -1
- package/dist/src/sources/torrentscsv.d.ts +0 -11
- package/dist/src/sources/torrentscsv.d.ts.map +0 -1
- package/dist/src/sources/torrentscsv.js +0 -62
- package/dist/src/sources/torrentscsv.js.map +0 -1
- package/dist/src/sources/yts.d.ts +0 -12
- package/dist/src/sources/yts.d.ts.map +0 -1
- package/dist/src/sources/yts.js +0 -88
- package/dist/src/sources/yts.js.map +0 -1
- package/dist/src/types.d.ts +0 -60
- package/dist/src/types.d.ts.map +0 -1
- package/dist/src/types.js +0 -3
- package/dist/src/types.js.map +0 -1
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.scrapers = void 0;
|
|
7
|
-
exports.loadSourcesConfig = loadSourcesConfig;
|
|
8
|
-
exports.getEnabledSources = getEnabledSources;
|
|
9
|
-
exports.getSourceConfig = getSourceConfig;
|
|
10
|
-
exports.getUpdateUrl = getUpdateUrl;
|
|
11
|
-
exports.getAllScrapers = getAllScrapers;
|
|
12
|
-
const fs_1 = require("fs");
|
|
13
|
-
const path_1 = require("path");
|
|
14
|
-
const eztv_1 = __importDefault(require("./eztv"));
|
|
15
|
-
const solidtorrents_1 = __importDefault(require("./solidtorrents"));
|
|
16
|
-
const thepiratebay_1 = __importDefault(require("./thepiratebay"));
|
|
17
|
-
const torlock_1 = __importDefault(require("./torlock"));
|
|
18
|
-
const torrentproject_1 = __importDefault(require("./torrentproject"));
|
|
19
|
-
const torrentscsv_1 = __importDefault(require("./torrentscsv"));
|
|
20
|
-
const limetorrent_1 = __importDefault(require("./limetorrent"));
|
|
21
|
-
const _1337x_1 = __importDefault(require("./1337x"));
|
|
22
|
-
const rarbg_1 = __importDefault(require("./rarbg"));
|
|
23
|
-
const yts_1 = __importDefault(require("./yts"));
|
|
24
|
-
const nyaa_1 = __importDefault(require("./nyaa"));
|
|
25
|
-
const scrapers = {
|
|
26
|
-
eztv: eztv_1.default,
|
|
27
|
-
solidtorrents: solidtorrents_1.default,
|
|
28
|
-
thepiratebay: thepiratebay_1.default,
|
|
29
|
-
torlock: torlock_1.default,
|
|
30
|
-
torrentproject: torrentproject_1.default,
|
|
31
|
-
torrentscsv: torrentscsv_1.default,
|
|
32
|
-
limetorrent: limetorrent_1.default,
|
|
33
|
-
'1337x': _1337x_1.default,
|
|
34
|
-
rarbg: rarbg_1.default,
|
|
35
|
-
yts: yts_1.default,
|
|
36
|
-
nyaa: nyaa_1.default
|
|
37
|
-
};
|
|
38
|
-
exports.scrapers = scrapers;
|
|
39
|
-
function loadSourcesConfig() {
|
|
40
|
-
const sourcesPath = (0, path_1.join)(process.cwd(), 'sources.json');
|
|
41
|
-
if ((0, fs_1.existsSync)(sourcesPath)) {
|
|
42
|
-
return JSON.parse((0, fs_1.readFileSync)(sourcesPath, 'utf-8'));
|
|
43
|
-
}
|
|
44
|
-
return { updateUrl: '', version: '1.0.0', sources: {} };
|
|
45
|
-
}
|
|
46
|
-
function getEnabledSources() {
|
|
47
|
-
const config = loadSourcesConfig();
|
|
48
|
-
const enabled = [];
|
|
49
|
-
for (const [key, sourceConfig] of Object.entries(config.sources)) {
|
|
50
|
-
if (sourceConfig.enabled && scrapers[key]) {
|
|
51
|
-
enabled.push(scrapers[key]);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
if (enabled.length === 0) {
|
|
55
|
-
return Object.values(scrapers);
|
|
56
|
-
}
|
|
57
|
-
return enabled;
|
|
58
|
-
}
|
|
59
|
-
function getSourceConfig(name) {
|
|
60
|
-
const config = loadSourcesConfig();
|
|
61
|
-
return config.sources[name];
|
|
62
|
-
}
|
|
63
|
-
function getUpdateUrl() {
|
|
64
|
-
const config = loadSourcesConfig();
|
|
65
|
-
return config.updateUrl;
|
|
66
|
-
}
|
|
67
|
-
function getAllScrapers() {
|
|
68
|
-
return scrapers;
|
|
69
|
-
}
|
|
70
|
-
//# sourceMappingURL=registry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../src/sources/registry.ts"],"names":[],"mappings":";;;;;;AA8BA,8CAMC;AAED,8CAeC;AAED,0CAGC;AAED,oCAGC;AAED,wCAEC;AAnED,2BAA8C;AAC9C,+BAA4B;AAG5B,kDAA0B;AAC1B,oEAA4C;AAC5C,kEAA0C;AAC1C,wDAAgC;AAChC,sEAA8C;AAC9C,gEAAwC;AACxC,gEAAwC;AACxC,qDAA6B;AAC7B,oDAA4B;AAC5B,gDAAwB;AACxB,kDAA0B;AAE1B,MAAM,QAAQ,GAAkC;IAC9C,IAAI,EAAJ,cAAI;IACJ,aAAa,EAAb,uBAAa;IACb,YAAY,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ACnC,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC;AAED,SAAgB,YAAY;IAC1B,MAAM,MAAM,GAAG,iBAAiB,EAAE,CAAC;IACnC,OAAO,MAAM,CAAC,SAAS,CAAC;AAC1B,CAAC;AAED,SAAgB,cAAc;IAC5B,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { TorrentResult, SourceScraper } from '../types';
|
|
2
|
-
export declare class SolidTorrentsScraper implements SourceScraper {
|
|
3
|
-
name: string;
|
|
4
|
-
search(query: string, category?: string): Promise<TorrentResult[]>;
|
|
5
|
-
getTorrentUrl(result: TorrentResult): Promise<string>;
|
|
6
|
-
getMagnet(result: TorrentResult): Promise<string>;
|
|
7
|
-
private parseSize;
|
|
8
|
-
}
|
|
9
|
-
declare const _default: SolidTorrentsScraper;
|
|
10
|
-
export default _default;
|
|
11
|
-
//# sourceMappingURL=solidtorrents.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"solidtorrents.d.ts","sourceRoot":"","sources":["../../../src/sources/solidtorrents.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGxD,qBAAa,oBAAqB,YAAW,aAAa;IACxD,IAAI,SAAmB;IAEjB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IA0ClE,aAAa,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC;IAIrD,SAAS,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC;IAIvD,OAAO,CAAC,SAAS;CASlB;;AAED,wBAA0C"}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.SolidTorrentsScraper = void 0;
|
|
40
|
-
const axios_1 = __importDefault(require("axios"));
|
|
41
|
-
const cheerio = __importStar(require("cheerio"));
|
|
42
|
-
const httpClient_1 = require("./httpClient");
|
|
43
|
-
class SolidTorrentsScraper {
|
|
44
|
-
constructor() {
|
|
45
|
-
this.name = 'SolidTorrents';
|
|
46
|
-
}
|
|
47
|
-
async search(query, category) {
|
|
48
|
-
try {
|
|
49
|
-
const url = `https://solidtorrents.to/search?q=${encodeURIComponent(query)}`;
|
|
50
|
-
const { data } = await axios_1.default.get(url, {
|
|
51
|
-
headers: httpClient_1.DEFAULT_HEADERS,
|
|
52
|
-
timeout: httpClient_1.TIMEOUT
|
|
53
|
-
});
|
|
54
|
-
const $ = cheerio.load(data);
|
|
55
|
-
const results = [];
|
|
56
|
-
$('div[data-href^="/torrent/"]').each((i, el) => {
|
|
57
|
-
const title = $(el).find('a.torrent-title').text().trim();
|
|
58
|
-
const size = $(el).find('span[data-size]').attr('data-size') || 'Unknown';
|
|
59
|
-
const seeds = parseInt($(el).find('span.seed-count').text().trim()) || 0;
|
|
60
|
-
const peers = parseInt($(el).find('span.leech-count').text().trim()) || 0;
|
|
61
|
-
const link = 'https://solidtorrents.to' + $(el).find('a.torrent-title').attr('href');
|
|
62
|
-
const magnet = $(el).find('a[href^="magnet:"]').attr('href');
|
|
63
|
-
if (title) {
|
|
64
|
-
results.push({
|
|
65
|
-
num: results.length + 1,
|
|
66
|
-
name: title,
|
|
67
|
-
size,
|
|
68
|
-
sizeBytes: this.parseSize(size),
|
|
69
|
-
seeds,
|
|
70
|
-
peers,
|
|
71
|
-
source: 'SolidTorrents',
|
|
72
|
-
url: link,
|
|
73
|
-
magnet
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
return results;
|
|
78
|
-
}
|
|
79
|
-
catch (error) {
|
|
80
|
-
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
81
|
-
console.error(`SolidTorrents search error: ${message}`);
|
|
82
|
-
return [];
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
async getTorrentUrl(result) {
|
|
86
|
-
return result.url;
|
|
87
|
-
}
|
|
88
|
-
async getMagnet(result) {
|
|
89
|
-
return result.magnet || '';
|
|
90
|
-
}
|
|
91
|
-
parseSize(size) {
|
|
92
|
-
if (!size || size === 'Unknown')
|
|
93
|
-
return 0;
|
|
94
|
-
const match = size.toString().match(/([\d.]+)\s*(GB|MB|TB|KB)/i);
|
|
95
|
-
if (!match)
|
|
96
|
-
return 0;
|
|
97
|
-
const value = parseFloat(match[1]);
|
|
98
|
-
const unit = match[2].toUpperCase();
|
|
99
|
-
const multipliers = { 'KB': 1024, 'MB': 1024 ** 2, 'GB': 1024 ** 3, 'TB': 1024 ** 4 };
|
|
100
|
-
return value * (multipliers[unit] || 1);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
exports.SolidTorrentsScraper = SolidTorrentsScraper;
|
|
104
|
-
exports.default = new SolidTorrentsScraper();
|
|
105
|
-
//# sourceMappingURL=solidtorrents.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"solidtorrents.js","sourceRoot":"","sources":["../../../src/sources/solidtorrents.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,iDAAmC;AAEnC,6CAAwD;AAExD,MAAa,oBAAoB;IAAjC;QACE,SAAI,GAAG,eAAe,CAAC;IA6DzB,CAAC;IA3DC,KAAK,CAAC,MAAM,CAAC,KAAa,EAAE,QAAiB;QAC3C,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,qCAAqC,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC;YAC7E,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,eAAK,CAAC,GAAG,CAAC,GAAG,EAAE;gBACpC,OAAO,EAAE,4BAAe;gBACxB,OAAO,EAAE,oBAAO;aACjB,CAAC,CAAC;YAEH,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC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,11 +0,0 @@
|
|
|
1
|
-
import { TorrentResult, SourceScraper } from '../types';
|
|
2
|
-
export declare class ThePirateBayScraper implements SourceScraper {
|
|
3
|
-
name: string;
|
|
4
|
-
search(query: string, category?: string): Promise<TorrentResult[]>;
|
|
5
|
-
getTorrentUrl(result: TorrentResult): Promise<string>;
|
|
6
|
-
getMagnet(result: TorrentResult): Promise<string>;
|
|
7
|
-
private formatSize;
|
|
8
|
-
}
|
|
9
|
-
declare const _default: ThePirateBayScraper;
|
|
10
|
-
export default _default;
|
|
11
|
-
//# sourceMappingURL=thepiratebay.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"thepiratebay.d.ts","sourceRoot":"","sources":["../../../src/sources/thepiratebay.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAOxD,qBAAa,mBAAoB,YAAW,aAAa;IACvD,IAAI,SAAkB;IAEhB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAkClE,aAAa,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC;IAIrD,SAAS,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC;IAIvD,OAAO,CAAC,UAAU;CASnB;;AAED,wBAAyC"}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.ThePirateBayScraper = void 0;
|
|
7
|
-
const axios_1 = __importDefault(require("axios"));
|
|
8
|
-
const httpClient_1 = require("./httpClient");
|
|
9
|
-
const API_URL = 'https://apibay.org/q.php';
|
|
10
|
-
const CAT_MAP = { movie: '201', tv: '205', music: '102', games: '400', apps: '300' };
|
|
11
|
-
class ThePirateBayScraper {
|
|
12
|
-
constructor() {
|
|
13
|
-
this.name = 'ThePirateBay';
|
|
14
|
-
}
|
|
15
|
-
async search(query, category) {
|
|
16
|
-
try {
|
|
17
|
-
const cat = category && CAT_MAP[category] ? CAT_MAP[category] : '0';
|
|
18
|
-
const url = `${API_URL}?q=${encodeURIComponent(query)}&cat=${cat}&limit=100`;
|
|
19
|
-
const { data } = await axios_1.default.get(url, {
|
|
20
|
-
headers: httpClient_1.DEFAULT_HEADERS,
|
|
21
|
-
timeout: httpClient_1.TIMEOUT
|
|
22
|
-
});
|
|
23
|
-
if (!Array.isArray(data))
|
|
24
|
-
return [];
|
|
25
|
-
const results = data.slice(0, 50).map((item) => ({
|
|
26
|
-
num: 0,
|
|
27
|
-
name: item.name,
|
|
28
|
-
size: this.formatSize(parseInt(item.size)),
|
|
29
|
-
sizeBytes: parseInt(item.size),
|
|
30
|
-
seeds: parseInt(item.seeders) || 0,
|
|
31
|
-
peers: parseInt(item.leechers) || 0,
|
|
32
|
-
source: 'ThePirateBay',
|
|
33
|
-
url: `https://thepiratebay.org/torrent/${item.id}`,
|
|
34
|
-
magnet: `magnet:?xt=urn:btih:${item.info_hash}`,
|
|
35
|
-
hash: item.info_hash
|
|
36
|
-
}));
|
|
37
|
-
results.forEach((r, i) => r.num = i + 1);
|
|
38
|
-
return results;
|
|
39
|
-
}
|
|
40
|
-
catch (error) {
|
|
41
|
-
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
42
|
-
console.error(`ThePirateBay search error: ${message}`);
|
|
43
|
-
return [];
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
async getTorrentUrl(result) {
|
|
47
|
-
return result.url;
|
|
48
|
-
}
|
|
49
|
-
async getMagnet(result) {
|
|
50
|
-
return result.magnet || '';
|
|
51
|
-
}
|
|
52
|
-
formatSize(bytes) {
|
|
53
|
-
const gb = bytes / (1024 ** 3);
|
|
54
|
-
if (gb >= 1)
|
|
55
|
-
return `${gb.toFixed(2)} GB`;
|
|
56
|
-
const mb = bytes / (1024 ** 2);
|
|
57
|
-
if (mb >= 1)
|
|
58
|
-
return `${mb.toFixed(2)} MB`;
|
|
59
|
-
const kb = bytes / 1024;
|
|
60
|
-
if (kb >= 1)
|
|
61
|
-
return `${kb.toFixed(2)} KB`;
|
|
62
|
-
return `${bytes} B`;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
exports.ThePirateBayScraper = ThePirateBayScraper;
|
|
66
|
-
exports.default = new ThePirateBayScraper();
|
|
67
|
-
//# sourceMappingURL=thepiratebay.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"thepiratebay.js","sourceRoot":"","sources":["../../../src/sources/thepiratebay.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,6CAAwD;AAExD,MAAM,OAAO,GAAG,0BAA0B,CAAC;AAE3C,MAAM,OAAO,GAA2B,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;AAE7G,MAAa,mBAAmB;IAAhC;QACE,SAAI,GAAG,cAAc,CAAC;IAqDxB,CAAC;IAnDC,KAAK,CAAC,MAAM,CAAC,KAAa,EAAE,QAAiB;QAC3C,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,QAAQ,IAAI,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;YACpE,MAAM,GAAG,GAAG,GAAG,OAAO,MAAM,kBAAkB,CAAC,KAAK,CAAC,QAAQ,GAAG,YAAY,CAAC;YAE7E,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,eAAK,CAAC,GAAG,CAAC,GAAG,EAAE;gBACpC,OAAO,EAAE,4BAAe;gBAC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QACvC,OAAO,MAAM,CAAC,GAAG,CAAC;IACpB,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,MAAqB;QACnC,OAAO,MAAM,CAAC,MAAM,IAAI,EAAE,CAAC;IAC7B,CAAC;IAEO,UAAU,CAAC,KAAa;QAC9B,MAAM,EAAE,GAAG,KAAK,GAAG,CAAC,IAAI,IAAE,CAAC,CAAC,CAAC;QAC7B,IAAI,EAAE,IAAI,CAAC;YAAE,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;QAC1C,MAAM,EAAE,GAAG,KAAK,GAAG,CAAC,IAAI,IAAE,CAAC,CAAC,CAAC;QAC7B,IAAI,EAAE,IAAI,CAAC;YAAE,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;QAC1C,MAAM,EAAE,GAAG,KAAK,GAAG,IAAI,CAAC;QACxB,IAAI,EAAE,IAAI,CAAC;YAAE,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;QAC1C,OAAO,GAAG,KAAK,IAAI,CAAC;IACtB,CAAC;CACF;AAtDD,kDAsDC;AAED,kBAAe,IAAI,mBAAmB,EAAE,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { TorrentResult, SourceScraper } from '../types';
|
|
2
|
-
export declare class TorLockScraper implements SourceScraper {
|
|
3
|
-
name: string;
|
|
4
|
-
search(query: string, category?: string): Promise<TorrentResult[]>;
|
|
5
|
-
getTorrentUrl(result: TorrentResult): Promise<string>;
|
|
6
|
-
getMagnet(result: TorrentResult): Promise<string>;
|
|
7
|
-
private parseSize;
|
|
8
|
-
}
|
|
9
|
-
declare const _default: TorLockScraper;
|
|
10
|
-
export default _default;
|
|
11
|
-
//# sourceMappingURL=torlock.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"torlock.d.ts","sourceRoot":"","sources":["../../../src/sources/torlock.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAUxD,qBAAa,cAAe,YAAW,aAAa;IAClD,IAAI,SAAa;IAEX,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAyClE,aAAa,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC;IAIrD,SAAS,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC;IAUvD,OAAO,CAAC,SAAS;CASlB;;AAED,wBAAoC"}
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.TorLockScraper = void 0;
|
|
40
|
-
const axios_1 = __importDefault(require("axios"));
|
|
41
|
-
const cheerio = __importStar(require("cheerio"));
|
|
42
|
-
const httpClient_1 = require("./httpClient");
|
|
43
|
-
const AD_KEYWORDS = ['vpn', 'service', 'banner', 'advertisement', 'sponsored', 'aclib', 'zoneid'];
|
|
44
|
-
function isAdContent(title) {
|
|
45
|
-
const lower = title.toLowerCase();
|
|
46
|
-
return AD_KEYWORDS.some(keyword => lower.includes(keyword));
|
|
47
|
-
}
|
|
48
|
-
class TorLockScraper {
|
|
49
|
-
constructor() {
|
|
50
|
-
this.name = 'TorLock';
|
|
51
|
-
}
|
|
52
|
-
async search(query, category) {
|
|
53
|
-
try {
|
|
54
|
-
const url = `https://www.torlock.com/all/torrents/${encodeURIComponent(query)}.html`;
|
|
55
|
-
const { data } = await axios_1.default.get(url, {
|
|
56
|
-
headers: httpClient_1.DEFAULT_HEADERS,
|
|
57
|
-
timeout: httpClient_1.TIMEOUT
|
|
58
|
-
});
|
|
59
|
-
const $ = cheerio.load(data);
|
|
60
|
-
const results = [];
|
|
61
|
-
$('table tbody tr').each((i, el) => {
|
|
62
|
-
const title = $(el).find('td:nth-child(2) a').text().trim();
|
|
63
|
-
const size = $(el).find('td:nth-child(3)').text().trim();
|
|
64
|
-
const seeds = parseInt($(el).find('td:nth-child(4)').text().trim()) || 0;
|
|
65
|
-
const peers = parseInt($(el).find('td:nth-child(5)').text().trim()) || 0;
|
|
66
|
-
const link = 'https://www.torlock.com' + ($(el).find('td:nth-child(2) a').attr('href') || '');
|
|
67
|
-
if (title && !isAdContent(title)) {
|
|
68
|
-
results.push({
|
|
69
|
-
num: results.length + 1,
|
|
70
|
-
name: title,
|
|
71
|
-
size: size || 'Unknown',
|
|
72
|
-
sizeBytes: this.parseSize(size),
|
|
73
|
-
seeds,
|
|
74
|
-
peers,
|
|
75
|
-
source: 'TorLock',
|
|
76
|
-
url: link,
|
|
77
|
-
magnet: ''
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
return results;
|
|
82
|
-
}
|
|
83
|
-
catch (error) {
|
|
84
|
-
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
85
|
-
console.error(`TorLock search error: ${message}`);
|
|
86
|
-
return [];
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
async getTorrentUrl(result) {
|
|
90
|
-
return result.url;
|
|
91
|
-
}
|
|
92
|
-
async getMagnet(result) {
|
|
93
|
-
try {
|
|
94
|
-
const { data } = await axios_1.default.get(result.url, { headers: httpClient_1.DEFAULT_HEADERS, timeout: httpClient_1.TIMEOUT });
|
|
95
|
-
const $ = cheerio.load(data);
|
|
96
|
-
return $('a[href^="magnet:"]').attr('href') || '';
|
|
97
|
-
}
|
|
98
|
-
catch {
|
|
99
|
-
return '';
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
parseSize(size) {
|
|
103
|
-
if (!size)
|
|
104
|
-
return 0;
|
|
105
|
-
const match = size.toString().match(/([\d.]+)\s*(GB|MB|TB|KB)/i);
|
|
106
|
-
if (!match)
|
|
107
|
-
return 0;
|
|
108
|
-
const value = parseFloat(match[1]);
|
|
109
|
-
const unit = match[2].toUpperCase();
|
|
110
|
-
const multipliers = { 'KB': 1024, 'MB': 1024 ** 2, 'GB': 1024 ** 3, 'TB': 1024 ** 4 };
|
|
111
|
-
return value * (multipliers[unit] || 1);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
exports.TorLockScraper = TorLockScraper;
|
|
115
|
-
exports.default = new TorLockScraper();
|
|
116
|
-
//# sourceMappingURL=torlock.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"torlock.js","sourceRoot":"","sources":["../../../src/sources/torlock.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,iDAAmC;AAEnC,6CAAwD;AAExD,MAAM,WAAW,GAAG,CAAC,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,eAAe,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;AAElG,SAAS,WAAW,CAAC,KAAa;IAChC,MAAM,KAAK,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;IAClC,OAAO,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;AAC9D,CAAC;AAED,MAAa,cAAc;IAA3B;QACE,SAAI,GAAG,SAAS,CAAC;IAkEnB,CAAC;IAhEC,KAAK,CAAC,MAAM,CAAC,KAAa,EAAE,QAAiB;QAC3C,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,wCAAwC,kBAAkB,CAAC,KAAK,CAAC,OAAO,CAAC;YACrF,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,eAAK,CAAC,GAAG,CAAC,GAAG,EAAE;gBACpC,OAAO,EAAE,4BAAe;gBACxB,OAAO,EAAE,oBAAO;aACjB,CAAC,CAAC;YAEH,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC7B,MAAM,OAAO,GAAoB,EAAE,CAAC;YAEpC,CAAC,CAAC,gBAAgB,CAAC,CA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,CAAC,EAAE,IAAI,EAAE,IAAI,IAAE,CAAC,EAAE,CAAC;QACxG,OAAO,KAAK,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC1C,CAAC;CACF;AAnED,wCAmEC;AAED,kBAAe,IAAI,cAAc,EAAE,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { TorrentResult, SourceScraper } from '../types';
|
|
2
|
-
export declare class TorrentProjectScraper implements SourceScraper {
|
|
3
|
-
name: string;
|
|
4
|
-
search(query: string, category?: string): Promise<TorrentResult[]>;
|
|
5
|
-
getTorrentUrl(result: TorrentResult): Promise<string>;
|
|
6
|
-
getMagnet(result: TorrentResult): Promise<string>;
|
|
7
|
-
private parseSize;
|
|
8
|
-
}
|
|
9
|
-
declare const _default: TorrentProjectScraper;
|
|
10
|
-
export default _default;
|
|
11
|
-
//# sourceMappingURL=torrentproject.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"torrentproject.d.ts","sourceRoot":"","sources":["../../../src/sources/torrentproject.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGxD,qBAAa,qBAAsB,YAAW,aAAa;IACzD,IAAI,SAAoB;IAElB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IA0ClE,aAAa,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC;IAIrD,SAAS,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC;IAIvD,OAAO,CAAC,SAAS;CASlB;;AAED,wBAA2C"}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.TorrentProjectScraper = void 0;
|
|
40
|
-
const axios_1 = __importDefault(require("axios"));
|
|
41
|
-
const cheerio = __importStar(require("cheerio"));
|
|
42
|
-
const httpClient_1 = require("./httpClient");
|
|
43
|
-
class TorrentProjectScraper {
|
|
44
|
-
constructor() {
|
|
45
|
-
this.name = 'TorrentProject';
|
|
46
|
-
}
|
|
47
|
-
async search(query, category) {
|
|
48
|
-
try {
|
|
49
|
-
const url = `https://torrentproject.site/?s=${encodeURIComponent(query)}&p=1`;
|
|
50
|
-
const { data } = await axios_1.default.get(url, {
|
|
51
|
-
headers: httpClient_1.DEFAULT_HEADERS,
|
|
52
|
-
timeout: httpClient_1.TIMEOUT
|
|
53
|
-
});
|
|
54
|
-
const $ = cheerio.load(data);
|
|
55
|
-
const results = [];
|
|
56
|
-
$('div.torrent_row, div.torrents__torrent').each((i, el) => {
|
|
57
|
-
const title = $(el).find('a.title').text().trim() || $(el).find('a').first().text().trim();
|
|
58
|
-
const size = $(el).find('span.size, div.size').text().trim();
|
|
59
|
-
const seeds = parseInt($(el).find('span.seeders, div.seeds').text().trim()) || 0;
|
|
60
|
-
const peers = parseInt($(el).find('span.leechers, div.leechs').text().trim()) || 0;
|
|
61
|
-
const link = $(el).find('a.title').attr('href') || $(el).find('a').first().attr('href') || '';
|
|
62
|
-
const magnet = $(el).find('a[href^="magnet:"]').attr('href');
|
|
63
|
-
if (title && link) {
|
|
64
|
-
results.push({
|
|
65
|
-
num: results.length + 1,
|
|
66
|
-
name: title,
|
|
67
|
-
size: size || 'Unknown',
|
|
68
|
-
sizeBytes: this.parseSize(size),
|
|
69
|
-
seeds,
|
|
70
|
-
peers,
|
|
71
|
-
source: 'TorrentProject',
|
|
72
|
-
url: link.startsWith('http') ? link : `https://torrentproject.site${link}`,
|
|
73
|
-
magnet
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
return results;
|
|
78
|
-
}
|
|
79
|
-
catch (error) {
|
|
80
|
-
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
81
|
-
console.error(`TorrentProject search error: ${message}`);
|
|
82
|
-
return [];
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
async getTorrentUrl(result) {
|
|
86
|
-
return result.url;
|
|
87
|
-
}
|
|
88
|
-
async getMagnet(result) {
|
|
89
|
-
return result.magnet || '';
|
|
90
|
-
}
|
|
91
|
-
parseSize(size) {
|
|
92
|
-
if (!size)
|
|
93
|
-
return 0;
|
|
94
|
-
const match = size.toString().match(/([\d.]+)\s*(GB|MB|TB|KB)/i);
|
|
95
|
-
if (!match)
|
|
96
|
-
return 0;
|
|
97
|
-
const value = parseFloat(match[1]);
|
|
98
|
-
const unit = match[2].toUpperCase();
|
|
99
|
-
const multipliers = { 'KB': 1024, 'MB': 1024 ** 2, 'GB': 1024 ** 3, 'TB': 1024 ** 4 };
|
|
100
|
-
return value * (multipliers[unit] || 1);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
exports.TorrentProjectScraper = TorrentProjectScraper;
|
|
104
|
-
exports.default = new TorrentProjectScraper();
|
|
105
|
-
//# sourceMappingURL=torrentproject.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"torrentproject.js","sourceRoot":"","sources":["../../../src/sources/torrentproject.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,iDAAmC;AAEnC,6CAAwD;AAExD,MAAa,qBAAqB;IAAlC;QACE,SAAI,GAAG,gBAAgB,CAAC;IA6D1B,CAAC;IA3DC,KAAK,CAAC,MAAM,CAAC,KAAa,EAAE,QAAiB;QAC3C,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,kCAAkC,kBAAkB,CAAC,KAAK,CAAC,MAAM,CAAC;YAC9E,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,eAAK,CAAC,GAAG,CAAC,GAAG,EAAE;gBACpC,OAAO,EAAE,4BAAe;gBACxB,OAAO,EAAE,oBAAO;aACjB,CAAC,CAAC;YAEH,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC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,WAAW,GAA2B,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,IAAE,CAAC,EAAE,IAAI,EAAE,IAAI,IAAE,CAAC,EAAE,IAAI,EAAE,IAAI,IAAE,CAAC,EAAE,CAAC;QACxG,OAAO,KAAK,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC1C,CAAC;CACF;AA9DD,sDA8DC;AAED,kBAAe,IAAI,qBAAqB,EAAE,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { TorrentResult, SourceScraper } from '../types';
|
|
2
|
-
export declare class TorrentsCsvScraper implements SourceScraper {
|
|
3
|
-
name: string;
|
|
4
|
-
search(query: string, category?: string): Promise<TorrentResult[]>;
|
|
5
|
-
getTorrentUrl(result: TorrentResult): Promise<string>;
|
|
6
|
-
getMagnet(result: TorrentResult): Promise<string>;
|
|
7
|
-
private formatSize;
|
|
8
|
-
}
|
|
9
|
-
declare const _default: TorrentsCsvScraper;
|
|
10
|
-
export default _default;
|
|
11
|
-
//# sourceMappingURL=torrentscsv.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"torrentscsv.d.ts","sourceRoot":"","sources":["../../../src/sources/torrentscsv.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGxD,qBAAa,kBAAmB,YAAW,aAAa;IACtD,IAAI,SAAkB;IAEhB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAkClE,aAAa,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC;IAIrD,SAAS,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC;IAIvD,OAAO,CAAC,UAAU;CAMnB;;AAED,wBAAwC"}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.TorrentsCsvScraper = void 0;
|
|
7
|
-
const axios_1 = __importDefault(require("axios"));
|
|
8
|
-
const httpClient_1 = require("./httpClient");
|
|
9
|
-
class TorrentsCsvScraper {
|
|
10
|
-
constructor() {
|
|
11
|
-
this.name = 'torrents-csv';
|
|
12
|
-
}
|
|
13
|
-
async search(query, category) {
|
|
14
|
-
try {
|
|
15
|
-
const url = `https://torrents-csv.ml/api/search?q=${encodeURIComponent(query)}`;
|
|
16
|
-
const { data } = await axios_1.default.get(url, {
|
|
17
|
-
headers: httpClient_1.DEFAULT_HEADERS,
|
|
18
|
-
timeout: httpClient_1.TIMEOUT
|
|
19
|
-
});
|
|
20
|
-
const results = [];
|
|
21
|
-
const torrents = Array.isArray(data) ? data : data.torrents || [];
|
|
22
|
-
for (const t of torrents.slice(0, 50)) {
|
|
23
|
-
results.push({
|
|
24
|
-
num: results.length + 1,
|
|
25
|
-
name: t.name || t.title || 'Unknown',
|
|
26
|
-
size: this.formatSize(t.length || t.size || 0),
|
|
27
|
-
sizeBytes: t.length || t.size || 0,
|
|
28
|
-
seeds: t.seeders || t.s || 0,
|
|
29
|
-
peers: t.leechers || t.l || 0,
|
|
30
|
-
source: 'torrents-csv',
|
|
31
|
-
url: t.link || t.info_hash ? `magnet:?xt=urn:btih:${t.info_hash}` : '',
|
|
32
|
-
magnet: t.link || t.magnet ? `magnet:?xt=urn:btih:${t.info_hash}` : '',
|
|
33
|
-
hash: t.info_hash
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
return results;
|
|
37
|
-
}
|
|
38
|
-
catch (error) {
|
|
39
|
-
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
40
|
-
console.error(`torrents-csv search error: ${message}`);
|
|
41
|
-
return [];
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
async getTorrentUrl(result) {
|
|
45
|
-
return result.url;
|
|
46
|
-
}
|
|
47
|
-
async getMagnet(result) {
|
|
48
|
-
return result.magnet || `magnet:?xt=urn:btih:${result.hash}`;
|
|
49
|
-
}
|
|
50
|
-
formatSize(bytes) {
|
|
51
|
-
if (bytes < 1024)
|
|
52
|
-
return bytes + ' B';
|
|
53
|
-
if (bytes < 1024 * 1024)
|
|
54
|
-
return (bytes / 1024).toFixed(2) + ' KB';
|
|
55
|
-
if (bytes < 1024 * 1024 * 1024)
|
|
56
|
-
return (bytes / (1024 * 1024)).toFixed(2) + ' MB';
|
|
57
|
-
return (bytes / (1024 * 1024 * 1024)).toFixed(2) + ' GB';
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
exports.TorrentsCsvScraper = TorrentsCsvScraper;
|
|
61
|
-
exports.default = new TorrentsCsvScraper();
|
|
62
|
-
//# sourceMappingURL=torrentscsv.js.map
|