Skip to content
This repository has been archived by the owner on Dec 3, 2023. It is now read-only.

Commit

Permalink
add editorconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Dec 17, 2018
1 parent 4b1ba39 commit 8a92f0b
Show file tree
Hide file tree
Showing 19 changed files with 760 additions and 738 deletions.
22 changes: 22 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# http://editorconfig.org

root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 80
indent_brace_style = 1TBS
spaces_around_operators = true
quote_type = auto

[package.json]
indent_style = space
indent_size = 2

[*.md]
trim_trailing_whitespace = false
8 changes: 4 additions & 4 deletions example/audio.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var url = 'https://www.youtube.com/watch?v=H7HmzwI67ec';
// pass ['-f', 'bestaudio'] || ['-f', 'm4a'] for other formats with yt

ytdl.exec(url, ['-x', '--audio-format', 'mp3'], {}, function exec(err, output) {
'use strict';
if (err) { throw err; }
console.log(output.join('\n'));
});
'use strict';
if (err) { throw err; }
console.log(output.join('\n'));
});
8 changes: 4 additions & 4 deletions example/best.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var ytdl = require('..');
var url = 'https://www.youtube.com/watch?v=fmIGnd98DX4';

ytdl.exec(url, ['-f', 'bestvideo[ext=mp4]+bestaudio[ext=m4a]'], {}, function exec(err, output) {
'use strict';
if (err) { throw err; }
console.log(output.join('\n'));
});
'use strict';
if (err) { throw err; }
console.log(output.join('\n'));
});
40 changes: 20 additions & 20 deletions example/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,35 @@ var fs = require('fs');
var ytdl = require('..');

var video = ytdl('https://www.youtube.com/watch?v=AW8OOp2undg',
// Optional arguments passed to youtube-dl.
['-f', '18']);
// Optional arguments passed to youtube-dl.
['-f', '18']);

var size = 0;
video.on('info', function(info) {
'use strict';
size = info.size;
video.on('info', function (info) {
'use strict';
size = info.size;

console.log('Got video info');
var file = path.join(__dirname, info._filename);
video.pipe(fs.createWriteStream(file));
console.log('Got video info');
var file = path.join(__dirname, info._filename);
video.pipe(fs.createWriteStream(file));

});

var pos = 0;
video.on('data', function data(chunk) {
'use strict';
pos += chunk.length;
'use strict';
pos += chunk.length;

// `size` should not be 0 here.
if (size) {
var percent = (pos / size * 100).toFixed(2);
process.stdout.cursorTo(0);
process.stdout.clearLine(1);
process.stdout.write(percent + '%');
}
// `size` should not be 0 here.
if (size) {
var percent = (pos / size * 100).toFixed(2);
process.stdout.cursorTo(0);
process.stdout.clearLine(1);
process.stdout.write(percent + '%');
}
});

video.on('end', function end() {
'use strict';
console.log('\nDone');
});
'use strict';
console.log('\nDone');
});
20 changes: 10 additions & 10 deletions example/extractors.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
var ytdl = require('..');

ytdl.getExtractors(true, function getExtractors(err, list) {
'use strict';
console.log('Found ' + list.length + ' extractors');
'use strict';
console.log('Found ' + list.length + ' extractors');

var show = 4;
for (var i = 0; i < Math.min(show, list.length); i++) {
console.log(list[i]);
}
var show = 4;
for (var i = 0; i < Math.min(show, list.length); i++) {
console.log(list[i]);
}

if (list.length > show) {
console.log('...' + (list.length - show) + ' not shown');
}
if (list.length > show) {
console.log('...' + (list.length - show) + ' not shown');
}

});
});
22 changes: 11 additions & 11 deletions example/formats.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ var ytdl = require('..');
var url = 'http://www.youtube.com/watch?v=0RUvealeXZ0';

function mapInfo(item) {
'use strict';
return {
itag: item.format_id,
filetype: item.ext,
resolution: item.resolution || ((item.width) ? item.width + 'x' + item.height : 'audio only')
};
'use strict';
return {
itag: item.format_id,
filetype: item.ext,
resolution: item.resolution || ((item.width) ? item.width + 'x' + item.height : 'audio only')
};
}

ytdl.getInfo(url, function getInfo(err, info) {
'use strict';
if (err) { throw err; }
var formats = { id: info.id, formats: info.formats.map(mapInfo) };
console.log(formats);
});
'use strict';
if (err) { throw err; }
var formats = { id: info.id, formats: info.formats.map(mapInfo) };
console.log(formats);
});
28 changes: 14 additions & 14 deletions example/info.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
var ytdl = require('..');
var url = 'http://www.youtube.com/watch?v=0RUvealeXZ0';

ytdl.getInfo(url, function(err, info) {
ytdl.getInfo(url, function (err, info) {

'use strict';
if (err) { throw err; }
'use strict';
if (err) { throw err; }

console.log('id:', info.id);
console.log('title:', info.title);
console.log('url:', info.url);
console.log('thumbnail:', info.thumbnail);
console.log('description:', info.description);
console.log('filename:', info._filename);
console.log('duration:', info.duration);
console.log('raw duration:', info._duration_raw);
console.log('duration hms:', info._duration_hms);
console.log('format_id:', info.format_id);
});
console.log('id:', info.id);
console.log('title:', info.title);
console.log('url:', info.url);
console.log('thumbnail:', info.thumbnail);
console.log('description:', info.description);
console.log('filename:', info._filename);
console.log('duration:', info.duration);
console.log('raw duration:', info._duration_raw);
console.log('duration hms:', info._duration_hms);
console.log('format_id:', info.format_id);
});
12 changes: 6 additions & 6 deletions example/missing.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
var ytdl = require('..');

var playlist = [
'http://www.youtube.com/watch?v=SvPZo52X5vo',
'http://www.youtube.com/watch?v=2xJWQPdG7jE'
'http://www.youtube.com/watch?v=SvPZo52X5vo',
'http://www.youtube.com/watch?v=2xJWQPdG7jE'
];

ytdl.getInfo(playlist, function info(err, info) {

'use strict';
if (err) { throw err; }
'use strict';
if (err) { throw err; }

console.dir(info);
console.dir(info);

});
});
56 changes: 28 additions & 28 deletions example/playlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,34 @@ var ytdl = require('..');

function playlist(url) {

'use strict';
var video = ytdl(url);

video.on('error', function error(err) {
console.log(err.stack);
});

var size = 0;
video.on('info', function(info) {
size = info.size;
var output = path.join(__dirname + '/', size + '.mp4');
video.pipe(fs.createWriteStream(output));
});

var pos = 0;
video.on('data', function data(chunk) {
pos += chunk.length;
// `size` should not be 0 here.
if (size) {
var percent = (pos / size * 100).toFixed(2);
process.stdout.cursorTo(0);
process.stdout.clearLine(1);
process.stdout.write(percent + '%');
}
});

video.on('next', playlist);
'use strict';
var video = ytdl(url);

video.on('error', function error(err) {
console.log(err.stack);
});

var size = 0;
video.on('info', function (info) {
size = info.size;
var output = path.join(__dirname + '/', size + '.mp4');
video.pipe(fs.createWriteStream(output));
});

var pos = 0;
video.on('data', function data(chunk) {
pos += chunk.length;
// `size` should not be 0 here.
if (size) {
var percent = (pos / size * 100).toFixed(2);
process.stdout.cursorTo(0);
process.stdout.clearLine(1);
process.stdout.write(percent + '%');
}
});

video.on('next', playlist);

}

playlist('https://www.youtube.com/playlist?list=PLEFA9E9D96CB7F807');
playlist('https://www.youtube.com/playlist?list=PLEFA9E9D96CB7F807');
44 changes: 22 additions & 22 deletions example/resume.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,41 @@ if (fs.existsSync(output)) { downloaded = fs.statSync(output).size; }

var video = ytdl('https://www.youtube.com/watch?v=179MiZSibco',

// Optional arguments passed to youtube-dl.
['--format=18'],
// Optional arguments passed to youtube-dl.
['--format=18'],

// start will be sent as a range header
{ start: downloaded, cwd: __dirname });
// start will be sent as a range header
{ start: downloaded, cwd: __dirname });

// Will be called when the download starts.
video.on('info', function(info) {
video.on('info', function (info) {

'use strict';
console.log('Download started');
console.log('filename: ' + info._filename);
'use strict';
console.log('Download started');
console.log('filename: ' + info._filename);

// info.size will be the amount to download, add
var total = info.size + downloaded;
console.log('size: ' + total);
// info.size will be the amount to download, add
var total = info.size + downloaded;
console.log('size: ' + total);

if (downloaded > 0) {
// size will be the amount already downloaded
console.log('resuming from: ' + downloaded);
if (downloaded > 0) {
// size will be the amount already downloaded
console.log('resuming from: ' + downloaded);

// display the remaining bytes to download
console.log('remaining bytes: ' + info.size);
}
// display the remaining bytes to download
console.log('remaining bytes: ' + info.size);
}
});

video.pipe(fs.createWriteStream('myvideo.mp4', { flags: 'a' }));

// Will be called if download was already completed and there is nothing more to download.
video.on('complete', function complete(info) {
'use strict';
console.log('filename: ' + info._filename + ' already downloaded.');
'use strict';
console.log('filename: ' + info._filename + ' already downloaded.');
});

video.on('end', function end() {
'use strict';
console.log('finished downloading!');
});
'use strict';
console.log('finished downloading!');
});
8 changes: 4 additions & 4 deletions example/thumbs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var ytdl = require('..');
var url = 'https://www.youtube.com/watch?v=yy7EUIR0fic';

ytdl.getThumbs(url, { cwd: __dirname }, function thumbs(err, files) {
'use strict';
if (err) { throw err; }
console.dir(files);
});
'use strict';
if (err) { throw err; }
console.dir(files);
});
Loading

0 comments on commit 8a92f0b

Please sign in to comment.