File size: 2,057 Bytes
762fa11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { details, search } from "yts-api-node";
import { isImdbId } from "../utils/imdb.js";
const trackers = [
    "udp://glotorrents.pw:6969/announce",
    "udp://tracker.opentrackr.org:1337/announce",
    "udp://torrent.gresille.org:80/announce",
    "udp://tracker.openbittorrent.com:80",
    "udp://tracker.coppersurfer.tk:6969",
    "udp://tracker.leechers-paradise.org:6969",
    "udp://p4p.arenabg.ch:1337",
    "udp://tracker.internetwarriors.net:1337",
];
const trackersString = "&tr=" + trackers.join("&tr=");
export const searchYts = async (searchQuery) => {
    try {
        if (isImdbId(searchQuery)) {
            const res = await details({ movie_id: searchQuery });
            return res.data.movie.torrents.map((torrent) => ({
                name: `${res.data.movie.title_long} ${torrent.quality} ${torrent.type
                    .replace("bluray", "BluRay")
                    .replace("web", "WEB")}`,
                tracker: "YTS",
                category: `Movies/${torrent.quality}`,
                size: torrent.size_bytes,
                seeds: torrent.seeds,
                peers: torrent.peers,
                torrent: torrent.url,
                magnet: `magnet:?xt=urn:btih:${torrent.hash}${trackersString}`,
            }));
        }
        else {
            const res = await search({ query_term: searchQuery });
            return res.data.movies.flatMap((movie) => movie.torrents.map((torrent) => ({
                name: `${movie.title_long} ${torrent.quality} ${torrent.type
                    .replace("bluray", "BluRay")
                    .replace("web", "WEB")}`,
                tracker: "YTS",
                category: `Movies/${torrent.quality}`,
                size: torrent.size_bytes,
                seeds: torrent.seeds,
                peers: torrent.peers,
                torrent: torrent.url,
                magnet: `magnet:?xt=urn:btih:${torrent.hash}${trackersString}`,
            })));
        }
    }
    catch (error) {
        return [];
    }
};
//# sourceMappingURL=yts.js.map