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

fix for failed download with no subtitles when requested #37

Merged
merged 6 commits into from
Aug 2, 2014
Merged

fix for failed download with no subtitles when requested #37

merged 6 commits into from
Aug 2, 2014

Conversation

przemyslawpluta
Copy link
Owner

At the moment if video doesn't have subtitles but they were requested by the user youtube-dl fails with ...

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.

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) {

Copy link
Collaborator

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?

*/
function reIndexOf(arr, rx) {
var i;
for (i = 0; i < arr.length; i++) {
Copy link
Collaborator

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--) {

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already reversed L124

Copy link
Collaborator

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; }
Copy link
Collaborator

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?

fent added a commit that referenced this pull request Aug 2, 2014
fix for failed download with no subtitles when requested
@fent fent merged commit 29539bd into przemyslawpluta:master Aug 2, 2014
@fent
Copy link
Collaborator

fent commented Aug 2, 2014

Thank you again!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants