-
Notifications
You must be signed in to change notification settings - Fork 364
fix for failed download with no subtitles when requested #37
Conversation
At the moment if video doesn't have subtitles `youtube-dl` fails with ... ```js events.js:72 throw er; // Unhandled 'error' event ^ Error: : video doesn't have subtitles at /test/youtube-dl/lib/youtube-dl.js:122:23 at ChildProcess.exithandler (child_process.js:645:7) at ChildProcess.emit (events.js:98:17) at maybeClose (child_process.js:755:16) at Process.ChildProcess._handle.onexit (child_process.js:822:5) ``` ... this fix catches and removes possible options passed by the user and tries once to download video only without the subtitles.
@@ -71,6 +71,7 @@ var ytdl = module.exports = function(url, args, options) { | |||
* @param {Function(!Error, String)} callback | |||
*/ | |||
function call(video, args1, args2, options, callback) { | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure why these new lines are being placed at the start of blocks?
Cleanup, traverse the list of args backwards, match all possible languages, regex in global var
*/ | ||
function reIndexOf(arr, rx) { | ||
var i; | ||
for (i = 0; i < arr.length; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Iterate backwards, should look like
for (i = arr.length - 1; i >= 0; i--) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Already reversed L124
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reversing the array wouldn't fix the issue. The issue with iterating it in incremental order is that once you process an item and remove it from the current index, the length of the array decreases. The item in the next index will be moved to the current index, but i
will still increase, skipping that item.
function reIndexOf(arr, rx) { | ||
var i; | ||
for (i = arr.length - 1; i >= 0; i--) { | ||
if (arr[i].toString().match(rx)) { return i; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not use RegExp#test()
instead, and create the regexp objects beforehand?
this should do it ...
fix for failed download with no subtitles when requested
Thank you again! |
At the moment if video doesn't have subtitles but they were requested by the user
youtube-dl
fails with ...... this fix catches and removes possible options passed by the user and tries once to download video only without the subtitles.