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

Wanted: a way to download english subtitles without worrying about en vs enUS. #6596

Closed
keybounce opened this issue Aug 18, 2015 · 10 comments
Closed
Labels

Comments

@keybounce
Copy link

@keybounce keybounce commented Aug 18, 2015

I am looking to have a "simple" macro that downloads with subtitles.

For example, my current shell script is

#!/bin/bash
set -x
# Usage: youtube-480 url
## youtube-dl -f "bestvideo[height<=480][ext=mp4]+bestaudio[ext=m4a]/[height<=?480]" --sub-lang en --write-sub --recode-video mp4 "$@"
youtube-dl -f "bestvideo[height<=480][ext=mp4]" --sub-lang en --write-sub --recode-video mp4 "$@"

It's simple enough, but has taken me some time to learn the formatting. This tries to grab a 480p file, either in mp4 format, or recoded into mp4; it's been updated as I've been able to get 480p mp4's from youtube in one step now.

All is well and good until I run into sites where english subtitles are "enUS" instead of "en". Suddenly, it fails with
WARNING: en subtitles not available for 678135
ERROR: requested format not available

Is there a way to make this "just work"?

@yan12125
Copy link
Collaborator

@yan12125 yan12125 commented Aug 18, 2015

Can you give an example URL with enUS subtitles?

@ping
Copy link
Contributor

@ping ping commented Aug 18, 2015

@keybounce You can try --sub-lang "en,enUS" or even --sub-lang "en,enUS,English". There may be warning messages, but you'll still get the right subtitles.

@keybounce
Copy link
Author

@keybounce keybounce commented Aug 18, 2015

An example of an enUS was on crunchyroll.

Silly me, I saw that youtube-dl had updated that morning (I have a cron job that checks every morning), and didn't realize that the chrunchyroll support wasn't in yet. So it died on the subtitle before it could die on the video.

@yan12125
Copy link
Collaborator

@yan12125 yan12125 commented Aug 18, 2015

FYI: Crunhyroll support is just fixed, in a01da8b.

Thanks @ping for the approach, while I think it's still preferred to get warnings out.

@yan12125 yan12125 added the request label Aug 18, 2015
@keybounce
Copy link
Author

@keybounce keybounce commented Aug 18, 2015

Alright, and with the fixed crunchyroll support:

youtube-dl -f 'bestvideo[height<=480][ext=mp4]' --sub-lang en,enUS,English --write-sub --recode-video mp4 http://www.crunchyroll.com/is-it-wrong-to-try-to-pick-up-girls-in-a-dungeon
[crunchyroll:playlist] is-it-wrong-to-try-to-pick-up-girls-in-a-dungeon: Downloading webpage
[download] Downloading playlist: Is It Wrong to Try to Pick Up Girls in a Dungeon?
[crunchyroll:playlist] playlist Is It Wrong to Try to Pick Up Girls in a Dungeon?: Collected 13 video ids (downloading 13 of them)
[download] Downloading video 1 of 13
[Crunchyroll] 678135: Downloading webpage
[Crunchyroll] 678135: Downloading media info
[Crunchyroll] 678135: Downloading media info for 360p
[Crunchyroll] 678135: Checking 360p URL
[Crunchyroll] 678135: Downloading media info for 480p
[Crunchyroll] 678135: Checking 480p URL
[Crunchyroll] 678135: Downloading media info for 720p
[Crunchyroll] 678135: Checking 720p URL
[Crunchyroll] 678135: Downloading media info for 720p
[Crunchyroll] 678135: Checking 720p URL
[Crunchyroll] 678135: Downloading media info for 1080p
[Crunchyroll] 678135: Checking 1080p URL
[Crunchyroll] 678135: Downloading media info for 1080p
[Crunchyroll] 678135: Checking 1080p URL
[Crunchyroll] 678135: Downloading subtitles for English (US)
[Crunchyroll] 678135: Downloading subtitles for Español
[Crunchyroll] 678135: Downloading subtitles for Português (Brasil)
[Crunchyroll] 678135: Downloading subtitles for العربية
WARNING: en subtitles not available for 678135
WARNING: English subtitles not available for 678135
ERROR: requested format not available

Looks like it found the enUS, but didn't find the other two, and complained. So how do I say "any of these" instead of "all of these"?

@yan12125
Copy link
Collaborator

@yan12125 yan12125 commented Aug 18, 2015

"any of these" is not implemented yet.

@keybounce
Copy link
Author

@keybounce keybounce commented Aug 18, 2015

Ha. Well, that answers my question from the first post,
Is there a way to make this "just work"?

@keybounce
Copy link
Author

@keybounce keybounce commented Aug 18, 2015

Ok, now for a shell-scripting issue for python.

My "macro script" now looks like:

#!/bin/bash
set -x
# Usage: youtube-480 url
## youtube-dl -f "bestvideo[height<=480][ext=mp4]+bestaudio[ext=m4a]/[height<=?480]" --sub-lang en --write-sub --recode-video mp4 "$@"
youtube-dl -f "bestvideo[height<=480][ext=mp4]" --list-sub "$@" | grep -m 1 '^[eE][nN]' | awk '{print $1}' > /tmp/yt-sub.$$
##youtube-dl -f "bestvideo[height<=480][ext=mp4]" --sub-lang $(cat /tmp/yt-sub.$$) --write-sub --recode-video mp4 "$@"
cat /tmp/yt-sub.$$
rm -f /tmp/yt-sub.$$

Simple enough: Turn on debugging, get a list of subtitles, select the first english one, save it, and then use that -- but for debugging, just print what it would be.

What I need help with is python reporting an error:

Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/Users/michael/bin/youtube-dl/__main__.py", line 19, in <module>
  File "/Users/michael/bin/youtube-dl/youtube_dl/__init__.py", line 410, in main
  File "/Users/michael/bin/youtube-dl/youtube_dl/__init__.py", line 400, in _real_main
  File "/Users/michael/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 1653, in download
  File "/Users/michael/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 666, in extract_info
  File "/Users/michael/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 807, in process_ie_result
  File "/Users/michael/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 413, in to_screen
  File "/Users/michael/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 427, in to_stdout
  File "/Users/michael/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 416, in _write_string
  File "/Users/michael/bin/youtube-dl/youtube_dl/utils.py", line 1031, in write_string
IOError: [Errno 32] Broken pipe

How do I tell python to not complain?

@keybounce
Copy link
Author

@keybounce keybounce commented Jul 19, 2016

Ok, "Any of these" for subtitles seems to be working now, on Crunchyroll.

Python is no longer complaining on that "try to find the subtitles", and it isn't even needed anymore.

@keybounce keybounce closed this Jul 19, 2016
@mzso
Copy link

@mzso mzso commented Apr 4, 2020

@ping commented on 2015. aug. 18. 13:57 CEST:

@keybounce You can try --sub-lang "en,enUS" or even --sub-lang "en,enUS,English". There may be warning messages, but you'll still get the right subtitles.

So I have to do this for every darned english variant that might pop up? Or guess every single english variant and its country code that might exist... (Who knows how many.) Recently I ran into Canadian english, so with my config it was of course ignored.

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
4 participants
You can’t perform that action at this time.