mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-07 00:07:07 +00:00
Vendored
+27
@@ -1,6 +1,7 @@
|
||||
// Type definitions for youtube-dl 1.12
|
||||
// Project: https://www.npmjs.com/package/youtube-dl
|
||||
// Definitions by: Bogdan Surai <https://github.com/bsurai>
|
||||
// Moshe Feuchtwanger <https://github.com/moshfeu>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.4
|
||||
|
||||
@@ -18,5 +19,31 @@ declare namespace youtubedl {
|
||||
_filename: string;
|
||||
filename: string;
|
||||
size: number;
|
||||
_duration_raw: number;
|
||||
_duration_hms: string;
|
||||
duration: string;
|
||||
}
|
||||
|
||||
interface Options {
|
||||
auto?: boolean;
|
||||
all?: boolean;
|
||||
lang?: string;
|
||||
cwd?: string;
|
||||
}
|
||||
|
||||
function exec(url: string, args: string[], options: Options, callback: (err: any, output: string[]) => void): void;
|
||||
|
||||
function getInfo(url: string, args: string[], options: Options, callback: (err: any, output: Info) => void): void;
|
||||
function getInfo(url: string, args: string[], callback: (err: any, output: Info) => void): void;
|
||||
function getInfo(url: string, callback: (err: any, output: Info) => void): void;
|
||||
|
||||
function getSubs(url: string, options: Options, callback: (err: any, output: string[]) => void): void;
|
||||
function getSubs(url: string, callback: (err: any, output: string[]) => void): void;
|
||||
|
||||
function getThumbs(url: string, options: Options, callback: (err: any, output: string[]) => void): void;
|
||||
function getThumbs(url: string, callback: (err: any, output: string[]) => void): void;
|
||||
|
||||
function getExtractors(descriptions: boolean, options: Options, callback: (err: any, output: string[]) => void): void;
|
||||
function getExtractors(descriptions: boolean, callback: (err: any, output: string[]) => void): void;
|
||||
function getExtractors(callback: (err: any, output: string[]) => void): void;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
import * as fs from 'fs';
|
||||
import youtubedl = require('youtube-dl');
|
||||
|
||||
const video = youtubedl('http://www.youtube.com/watch?v=90AiXO1pAiA',
|
||||
const videoUrl = 'http://www.youtube.com/watch?v=90AiXO1pAiA';
|
||||
const args = ['--format=18'];
|
||||
const options = { cwd: __dirname };
|
||||
|
||||
const video = youtubedl(videoUrl,
|
||||
// Optional arguments passed to youtube-dl.
|
||||
['--format=18'],
|
||||
args,
|
||||
// Additional options can be given for calling `child_process.execFile()`.
|
||||
{ cwd: __dirname });
|
||||
options
|
||||
);
|
||||
|
||||
// Will be called when the download starts.
|
||||
video.on('info', (info: youtubedl.Info) => {
|
||||
@@ -16,3 +21,55 @@ video.on('info', (info: youtubedl.Info) => {
|
||||
});
|
||||
|
||||
video.pipe(fs.createWriteStream('myvideo.mp4'));
|
||||
|
||||
youtubedl.exec(videoUrl, args, options, (err: any, output: string[]) => {
|
||||
console.log(err);
|
||||
console.log(output.join('\n'));
|
||||
});
|
||||
|
||||
youtubedl.getInfo(videoUrl, args, options, (err: any, output: youtubedl.Info) => {
|
||||
console.log('_filename: ' + output._filename);
|
||||
});
|
||||
|
||||
youtubedl.getInfo(videoUrl, args, (err: any, output: youtubedl.Info) => {
|
||||
console.log('_filename: ' + output._filename);
|
||||
});
|
||||
|
||||
youtubedl.getInfo(videoUrl, (err: any, output: youtubedl.Info) => {
|
||||
console.log('_filename: ' + output._filename);
|
||||
});
|
||||
|
||||
youtubedl.getSubs(videoUrl, options, (err: any, output: string[]) => {
|
||||
console.log(err);
|
||||
console.log(output.join('\n'));
|
||||
});
|
||||
|
||||
youtubedl.getSubs(videoUrl, (err: any, output: string[]) => {
|
||||
console.log(err);
|
||||
console.log(output.join('\n'));
|
||||
});
|
||||
|
||||
youtubedl.getThumbs(videoUrl, options, (err: any, output: string[]) => {
|
||||
console.log(err);
|
||||
console.log(output.join('\n'));
|
||||
});
|
||||
|
||||
youtubedl.getThumbs(videoUrl, (err: any, output: string[]) => {
|
||||
console.log(err);
|
||||
console.log(output.join('\n'));
|
||||
});
|
||||
|
||||
youtubedl.getExtractors(true, options, (err: any, output: string[]) => {
|
||||
console.log(err);
|
||||
console.log(output.join('\n'));
|
||||
});
|
||||
|
||||
youtubedl.getExtractors(true, (err: any, output: string[]) => {
|
||||
console.log(err);
|
||||
console.log(output.join('\n'));
|
||||
});
|
||||
|
||||
youtubedl.getExtractors((err: any, output: string[]) => {
|
||||
console.log(err);
|
||||
console.log(output.join('\n'));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user