Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to download subtitles using class YoutubeDL, but works on CLI? #1750

Closed
victorhooi opened this issue Nov 11, 2013 · 1 comment
Closed

Unable to download subtitles using class YoutubeDL, but works on CLI? #1750

victorhooi opened this issue Nov 11, 2013 · 1 comment
Assignees
Labels
bug

Comments

@victorhooi
Copy link

@victorhooi victorhooi commented Nov 11, 2013

Hi,

I'm using the edu_10gen_dl script (https://github.com/nonsleepr/edu_10gen_dl) to download videos, which just calls youtube-dl under the hood.

The videos download correctly, however, the subtitles do not. Output from the script:

Processing lectures/M101P_-_MongoDB_for_Developers/Week_4_-_Performance/04.12.*...
[04.12.01] When is an Index Used? (Lecture)
http://www.youtube.com/watch?v=
Lwms58Y_3Jc
[youtube] Setting language
[youtube] Lwms58Y_3Jc: Downloading video webpage
[youtube] Lwms58Y_3Jc: Downloading video info webpage
[youtube] Lwms58Y_3Jc: Extracting video information
WARNING: unable to download video subtitles for en: Unable to download webpage: HTTP Error 404: Not Found; please report this issue on https://yt-dl.org/bug . Be sure to call youtube-dl with the --verbose flag and include its complete output. Make sure you are using the latest version; type  youtube-dl -U  to update.
[download] Destination: lectures/M101P_-_MongoDB_for_Developers/Week_4_-_Performance/04.12.01 When_is_an_Index_Used_Lecture.mp4
[download]  17.6% of 21.28MiB at  1.64MiB/s ETA 00:10

The strange thing is, when I download that same video id (Lwms58Y_3Jc) using the youtube-dl command line client, it works fine:

$ youtube-dl --write-sub Lwms58Y_3Jc
[youtube] Setting language
[youtube] Lwms58Y_3Jc: Downloading video webpage
[youtube] Lwms58Y_3Jc: Downloading video info webpage
[youtube] Lwms58Y_3Jc: Extracting video information
[info] Writing video subtitles to: m101 19 query plans-Lwms58Y_3Jc.en.srt
[download] Destination: m101 19 query plans-Lwms58Y_3Jc.mp4
[download] 100% of 21.28MiB in 00:12

However, when the edx_dl.py imports from the youtube-dl library, it does not work:

from youtube_dl.YoutubeDL import YoutubeDL
...
        self._fd = YoutubeDL(config.YDL_PARAMS)
...
                    self._fd.download([video_id])

In this case, video_id is simply the unicode string "Lwms58Y_3Jc".

I was wondering, is there some difference in behaviour between calling the youtube-dl command line client, versus important YoutubeDL and calling .download() with a video id?

Or anything else that might explain the above behaviour?

Thanks,
Victor

@jaimeMF
Copy link
Collaborator

@jaimeMF jaimeMF commented Nov 13, 2013

It should be fixed now, we didn't set a default value for the subtitles format, this produced that the subtitles urls have the fmt=None in the them, that caused the 404 error.
If you find any other issue when using youtube_dl from python code, please open a new issue, we'd really appreciate it.
Thanks for the report!

There are some differences when using YoutubeDL manually, for example:

  • You have to manually add the post processors.
  • You should considere setting the url openers (youtube_dl._setup_opener), for handling cookies and gzipped pages.

But apart from that, they should behave the same, in that case if any field is missing in the params dict. there should be a default value.

victorhooi added a commit to victorhooi/edu_10gen_dl that referenced this issue Nov 17, 2013
This version contains a fix for an issue which prevents the old version from downloading subtitles:

ytdl-org/youtube-dl#1750
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.