newpipe-extractor-js
Version:
JavaScript/Node.js port of NewPipeExtractor
82 lines • 2.28 kB
TypeScript
import { CookieJar } from 'tough-cookie';
export interface Response {
responseCode: number;
responseMessage: string;
responseHeaders: {
[key: string]: string[];
};
responseBody: string;
latestUrl: string;
}
export interface Request {
httpMethod: string;
url: string;
headers: {
[key: string]: string[];
};
dataToSend?: Uint8Array;
localization?: {
languageCode: string;
countryCode?: string;
};
}
export declare abstract class Downloader {
/**
* Download the text at the given URL.
*/
abstract download(url: string, localization?: {
languageCode: string;
countryCode?: string;
}): Promise<string>;
/**
* Download the text at the given URL using POST method.
*/
abstract downloadPost(url: string, headers: {
[key: string]: string[];
}, dataToSend: Uint8Array, localization?: {
languageCode: string;
countryCode?: string;
}): Promise<string>;
/**
* Execute a request and return the response.
*/
abstract execute(request: Request): Promise<Response>;
/**
* Convenience method to download JSON and parse it.
*/
downloadJson(url: string, localization?: {
languageCode: string;
countryCode?: string;
}): Promise<any>;
}
export declare class DefaultDownloader extends Downloader {
private cookieJar;
private userAgent;
constructor(cookieJar?: CookieJar, userAgent?: string);
download(url: string, localization?: {
languageCode: string;
countryCode?: string;
}): Promise<string>;
downloadPost(url: string, headers: {
[key: string]: string[];
}, dataToSend: Uint8Array, localization?: {
languageCode: string;
countryCode?: string;
}): Promise<string>;
execute(request: Request): Promise<Response>;
private getDefaultHeaders;
private getAcceptLanguageHeader;
/**
* Set a custom user agent
*/
setUserAgent(userAgent: string): void;
/**
* Get the cookie jar
*/
getCookieJar(): CookieJar;
/**
* Load cookies from a JSON array
*/
loadCookiesFromJson(jsonCookies: any[]): Promise<void>;
}
//# sourceMappingURL=Downloader.d.ts.map