mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 22:30:01 +00:00
Added type definitions for torrent-search-api
This commit is contained in:
90
types/torrent-search-api/index.d.ts
vendored
Normal file
90
types/torrent-search-api/index.d.ts
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
// Type definitions for torrent-search-api 2.0
|
||||
// Project: https://github.com/JimmyLaurent/torrent-search-api#readme
|
||||
// Definitions by: Nicolas Girardin <https://github.com/ngirardin>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export interface Torrent {
|
||||
title: string;
|
||||
time: string;
|
||||
size: string;
|
||||
magnet: string;
|
||||
desc: string;
|
||||
provider: string;
|
||||
}
|
||||
|
||||
export interface TorrentProvider {
|
||||
name: string;
|
||||
baseUrl: string;
|
||||
requireAuthentification: boolean;
|
||||
supportTokenAuthentification: boolean;
|
||||
supportCookiesAuthentification: boolean;
|
||||
supportCredentialsAuthentification: boolean;
|
||||
loginUrl: string;
|
||||
loginQueryString: string;
|
||||
searchUrl: string;
|
||||
categories: any; // FIXME {key: [string]}
|
||||
defaultCategory: string;
|
||||
resultsPerPageCount: number;
|
||||
itemsSelector: string;
|
||||
itemSelectors: any; // FIXME {key: [string]}
|
||||
paginateSelector: string;
|
||||
torrentDetailsSelector: string;
|
||||
enableCloudFareBypass: boolean;
|
||||
headers: any; // FIXME {key:[string]}
|
||||
magnetSelector: string;
|
||||
autoFixUnstableUrl: boolean;
|
||||
}
|
||||
|
||||
export function lodProvider(providerParam: string): void;
|
||||
export function loadProvider(providerParam: string | TorrentProvider): void;
|
||||
|
||||
export function addProvider(provider: string): void;
|
||||
|
||||
export function loadProviders(...args: string[]): void;
|
||||
export function loadProviders(...args: TorrentProvider[]): void;
|
||||
|
||||
export function removeProvider(providerName: string): void;
|
||||
|
||||
export function enableProvider(providerName: string, args?: string[]): void;
|
||||
export function enableProvider(providerName: string, ...args: string[]): void;
|
||||
|
||||
export function enablePublicProviders(): void;
|
||||
|
||||
export function disableProvider(providerName: string): void;
|
||||
|
||||
export function disableAllProviders(): void;
|
||||
|
||||
export function getProviders(): TorrentProvider[];
|
||||
|
||||
export function getActiveProviders(): TorrentProvider[];
|
||||
|
||||
export function isProviderActive(name: string): boolean;
|
||||
|
||||
export function search(
|
||||
query: string,
|
||||
category: string,
|
||||
limit: number
|
||||
): Promise<Torrent[]>;
|
||||
|
||||
export function search(
|
||||
providers: string[],
|
||||
query: string,
|
||||
category: string,
|
||||
limit: number
|
||||
): Promise<Torrent[]>;
|
||||
|
||||
export function getTorrentDetails(torrent: Torrent): Promise<string>;
|
||||
|
||||
export function downloadTorrent(
|
||||
torrent: Torrent,
|
||||
filenamePath?: string
|
||||
): Promise<string>;
|
||||
|
||||
export function overrideConfig(
|
||||
providerName: string,
|
||||
newConfig: TorrentProvider
|
||||
): Promise<string>;
|
||||
|
||||
export function getMagnet(torrent: Torrent): Promise<string>;
|
||||
|
||||
export function getProvider(name: string, throwOnError: boolean): string;
|
||||
107
types/torrent-search-api/torrent-search-api-tests.ts
Normal file
107
types/torrent-search-api/torrent-search-api-tests.ts
Normal file
@@ -0,0 +1,107 @@
|
||||
import TorrentSearchApi = require("torrent-search-api");
|
||||
|
||||
// $ExpectType void
|
||||
TorrentSearchApi.enableProvider("Torrent9");
|
||||
|
||||
// $ExpectType Promise<Torrent[]>
|
||||
TorrentSearchApi.search("1080", "Movies", 20);
|
||||
|
||||
// $ExpectType TorrentProvider[]
|
||||
TorrentSearchApi.getProviders();
|
||||
|
||||
// $ExpectType TorrentProvider[]
|
||||
TorrentSearchApi.getActiveProviders();
|
||||
|
||||
// $ExpectType void
|
||||
TorrentSearchApi.enablePublicProviders();
|
||||
|
||||
// $ExpectType void
|
||||
TorrentSearchApi.enableProvider("Torrent9");
|
||||
|
||||
// $ExpectType void
|
||||
TorrentSearchApi.enableProvider("IpTorrents", ["uid=XXX;", "pass=XXX;"]);
|
||||
|
||||
// $ExpectType void
|
||||
TorrentSearchApi.enableProvider("IpTorrents", "USERNAME", "PASSWORD");
|
||||
|
||||
// $ExpectType void
|
||||
TorrentSearchApi.enableProvider("xxx", "TOKEN");
|
||||
|
||||
// $ExpectType void
|
||||
TorrentSearchApi.disableProvider("TorrentLeech");
|
||||
|
||||
// $ExpectType void
|
||||
TorrentSearchApi.disableAllProviders();
|
||||
|
||||
// $ExpectType boolean
|
||||
TorrentSearchApi.isProviderActive("1337x");
|
||||
|
||||
// $ExpectType Promise<Torrent[]>
|
||||
TorrentSearchApi.search("1080", "Movies", 20);
|
||||
|
||||
// $ExpectType Promise<Torrent[]>
|
||||
TorrentSearchApi.search(["IpTorrents", "Torrent9"], "1080", "Movies", 20);
|
||||
|
||||
const torrent = {
|
||||
title: "tile",
|
||||
time: "time",
|
||||
size: "size",
|
||||
magnet: "magnet",
|
||||
desc: "desc",
|
||||
provider: "provider"
|
||||
};
|
||||
|
||||
// $ExpectType Promise<string>
|
||||
TorrentSearchApi.getTorrentDetails(torrent);
|
||||
|
||||
// $ExpectType Promise<string>
|
||||
TorrentSearchApi.getMagnet(torrent);
|
||||
|
||||
// $ExpectType Promise<string>
|
||||
TorrentSearchApi.downloadTorrent(torrent);
|
||||
|
||||
// $ExpectType Promise<string>
|
||||
TorrentSearchApi.downloadTorrent(torrent, "file.mp4");
|
||||
|
||||
const provider = {
|
||||
name: "name",
|
||||
baseUrl: "baseUrl",
|
||||
requireAuthentification: true,
|
||||
supportTokenAuthentification: true,
|
||||
supportCookiesAuthentification: true,
|
||||
supportCredentialsAuthentification: true,
|
||||
loginUrl: "loginUrl",
|
||||
loginQueryString: "loginQueryString",
|
||||
searchUrl: "searchUrl",
|
||||
categories: {
|
||||
All: "all",
|
||||
Movies: "movies"
|
||||
},
|
||||
defaultCategory: "all",
|
||||
resultsPerPageCount: 50,
|
||||
itemsSelector: ".selector",
|
||||
itemSelectors: {
|
||||
title: ".title",
|
||||
seeds: ".seeds",
|
||||
peers: ".peers",
|
||||
size: ".size",
|
||||
desc: ".desc"
|
||||
},
|
||||
paginateSelector: ".page",
|
||||
torrentDetailsSelector: ".detail",
|
||||
enableCloudFareBypass: true,
|
||||
headers: {
|
||||
UserAgent: "ua"
|
||||
},
|
||||
magnetSelector: ".magnet",
|
||||
autoFixUnstableUrl: true
|
||||
};
|
||||
|
||||
// $ExpectType void
|
||||
TorrentSearchApi.loadProvider(provider);
|
||||
|
||||
// $ExpectType void
|
||||
TorrentSearchApi.loadProviders("/path/to/provider");
|
||||
|
||||
// $ExpectType void
|
||||
TorrentSearchApi.removeProvider("MyCustomProvider");
|
||||
16
types/torrent-search-api/tsconfig.json
Normal file
16
types/torrent-search-api/tsconfig.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es6"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": ["index.d.ts", "torrent-search-api-tests.ts"]
|
||||
}
|
||||
1
types/torrent-search-api/tslint.json
Normal file
1
types/torrent-search-api/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user