diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/login.js | 15 | ||||
-rw-r--r-- | lib/videos.js | 8 |
2 files changed, 23 insertions, 0 deletions
diff --git a/lib/login.js b/lib/login.js index d7f3fdf..01ecd6d 100644 --- a/lib/login.js +++ b/lib/login.js @@ -193,5 +193,20 @@ module.exports = { callback(new Error(res.statusCode)); }); + }, + + checkProxy: function checkProxy(target, callback) { + request(target, function get(err, response) { + if (err !== null) { return callback(err); } + if (response.statusCode === 200) { + var stack = ''; + if (response.headers.server) { stack = 'Proxy Server: '.bold + response.headers.server.cyan + ' '; } + if (response.headers['x-powered-by']) { stack += 'Powered-by: '.bold + response.headers['x-powered-by'].cyan + ' '; } + stack.trim(); + if (stack === '') { stack = target; } + return callback(null, stack); + } + callback(new Error('Server Response: '.red + response.statusCode)); + }); } }; diff --git a/lib/videos.js b/lib/videos.js index a71d4e3..bf8973e 100644 --- a/lib/videos.js +++ b/lib/videos.js @@ -325,5 +325,13 @@ module.exports = { }); + }, + + checkProxyDownload: function checkProxyDownload(argv) { + setOptions(argv); + var video = 'https://youtu.be/nm20j_x9Ol8', opt = { all: undefined, cancel: undefined }; + if (typeof argv.test === 'string') { video = argv.test; } + opt[video] = 0; + handleList([video], opt); } }; |