ytdl-org / youtube-dl

Command-line program to download videos from YouTube.com and other video sites
http://ytdl-org.github.io/youtube-dl/
The Unlicense
131.56k stars 9.97k forks source link

Please add workaround for forced YouTube translated video titles #10758

Open rcajal opened 8 years ago

rcajal commented 8 years ago

Please follow the guide below


Make sure you are using the latest version: run youtube-dl --version and ensure your version is 2016.09.24. If it's not read this FAQ entry and update. Issues with outdated version will be rejected.


YouTube has added a feature where it allows users or channel owners to contribute translations of video titles. This feature has been around for some time but rolled out in increments hitting users in different regions.

On YouTube's web interface whether the original title (desired) or one of the translated titles are shown depends on the choice of interface language. If the language interface is selected to be other than English then YouTube will show the non-English titles in their original form.

When using youtube-dl the desired outcome is for %(title)s to be the original title since this allows for better accounting of the saved material. There is no guarantee user-contributed or machine translations are accurate. These titles also make searching among files saved by youtube-dl harder than it should be.

The problem has now hit youtube-dl because it requests en-US (or en-GB for embedded SWF) content from YouTube via hardcoded 'hl=en' parameter in multiple places in extractor/youtube.py. This results in YouTube presenting youtube-dl with (often inaccurate or nonsensical) translated titles.

Please make the location, 'gl=??', and language 'hl=??', configurable via commandline switches. The parameter hl=?? is in particular effective for working around this issue. Currently, changing the occurrences of hl=en to, for example, hl=fr causes YouTuble, and consequently youtube-dl, to present the correct original title of videos.

Example

Video code: 2sKgVz79NZE

Original correct title (in Japanese, accessible via YouTube API or a browser where YouTube language interface has been set to something other than English): "人を怒らせる方法 「放棄」"

Translated title (acquired with --get-filename -f22 -o '%(title)s.%(ext)s' to youtube-dl, or a browser with YouTube interface language set to English): "How to make peopke angry 'renounse'.mp4"

yan12125 commented 8 years ago

For interested, there are some more details on IRC.

V1rtuousCycle commented 7 years ago

Seems like a doable issue. I'm not advanced enough to solve it yet, but wish I could.

Slider-Whistle commented 5 years ago

This seems to be the default behaviour with video titles for me at the moment. Descriptions are still localised, though, and I imagine implementing the specific feature rcajal described would solve this.

rautamiekka commented 5 years ago

This is ancient. I'm on Python 3.7.1 x64 installed through Anaconda x64 I've updated, on Window$ 10.0.17134.345 Enterprise x64, of course using NTFS on my C drive, and youtube-dl 2018.12.03, and the filename is correct using just the defaults (人を怒らせる方法 「放棄」-2sKgVz79NZE.webm). So, surely, this problem has been fixed on either end ?

Slider-Whistle commented 5 years ago

As far as the title of the issue goes, but descriptions still seem to be localised. I imagine that changing the gl and hl attributes by command switch as suggested by the first post would resolve it. I downloaded one video and the title was accurately recorded in Japanese, but the description was still in English, with a section clarifying that it was the version that displays for all non-Japanese users.

rococode commented 5 years ago

I think this is the relevant issue - is there anything we can do to force a title language? I'm trying to download some videos from nicovideo.jp (niconico) and the titles are downloaded in English when available. I'd prefer to have the titles downloaded in Japanese. On the website, the way to force Japanese is to swap the website language to it (from English).

Edit: It seems like language is selected based on browser language - when I swap my browser language to Japanese I get the Japanese version by default (I presume through checking window.navigator.userLanguage || window.navigator.language). Is there a flag in youtube-dl that allows setting this so that we can choose the title language in this kind of scenario?

sebma commented 5 years ago

@yan12125 Hi, I propose you use this translate-shell tool :

Here's an example of usage of the trans tool :

First here's a video title displayed in Chinese :

$ youtube-dl --ignore-config --get-filename XMaxBthVLx4 
273 恩典的话语满有能力-XMaxBthVLx4.mp4

To translate it to English (language used by trans by default) :

$ youtube-dl --ignore-config --get-filename XMaxBthVLx4 | trans -b
273 The Word of Grace is full of power - XMaxBthVLx4.mp4

To translate it to French (for example) :

$ youtube-dl --ignore-config --get-filename XMaxBthVLx4 | trans -b :fr
273 La Parole de Grâce est pleine de puissance - XMaxBthVLx4.mp4

You could call the trans tool by a sub-process through a new --translate or --trans option.

Slider-Whistle commented 5 years ago

@sebma; The important part isn't being able to read the title or not, it's being able to avoid the translations Youtube provides.

remitamine commented 4 years ago

it's the same, youtube-dl is using the description from the English interface, while what you're getting in the browser is the description from the Hindi interface.

aheadlead commented 3 years ago

FYR: --add-header 'Accept-Language: zh-CN' works fine for me when downloading a playlist from YouTube.

Slider-Whistle commented 3 years ago

Thanks, that's very useful information.

rmd13 commented 3 years ago

--add-header 'Accept-Language: zh-CN' does not work

aheadlead commented 3 years ago

--add-header 'Accept-Language: zh-CN' does not work

Are you downloading a playlist?

rmd13 commented 3 years ago

--add-header 'Accept-Language: zh-CN' does not work

Are you downloading a playlist? Yes. It still returns english title.

"D:\GreenSoft\youtube\youtube-dl.exe" --playlist-items 81 "https://www.youtube.com/channel/UCBJmYv3Vf_tKcQr5_qmayXg/videos" --get-filename --add-header "Accept-Language: zh-CN"

the results is : State Banquet Master Chef - Stir-fry kale borecole with pork and peanuts.-Tt959- hPKh0.mp4

but it should be 【国宴大师•榄菜肉丁长寿果】二伯首创下酒菜,酥脆无比、回味无穷,再来点小酒,绝了! |老饭骨

if remove --get-filename , the mp4 was downloaded with english name.

MarcG2 commented 2 years ago

Is there a work around for retrieving a translated version of a title? Is it possible using the -add-header flag?