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

fix: wrong selection of default audio language #3892

Merged
merged 1 commit into from
Jan 7, 2025

Conversation

bonswouar
Copy link
Contributor

@bonswouar bonswouar commented Dec 15, 2024

It would always fallback to en as the loop was over array keys, not values.
I don't know much about JS but this for..of works in Firefox. Apparently it is ES6 compliant, supported pretty much everywhere except IE11

Really needed now that many English tracks of non-English videos are AI translated (because yt enabled it by default) 🤢

Notes:

  • Ideally it would be great to be able to detect AI translated tracks, or "original language", not sure if it's possible with current extractor (or with yt in general) EDIT: Apparently it is, and it's already included in proxy's response, nice!
  • And also have a separate setting for Audio language (right now it's the same as UI language, which isn't so great)

EDIT: I've added this to a related open feature request #2240 (comment)

it would always fallback to "en"
as the loop was over array keys not values
@@ -613,7 +613,7 @@ export default {
// Set the audio language
const prefLang = this.getPreferenceString("hl", "en").substr(0, 2);
var lang = "en";
for (var l in player.getAudioLanguages()) {
for (var l of player.getAudioLanguages()) {
Copy link
Member

Choose a reason for hiding this comment

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

We could actually simplify this more, i.e.

Suggested change
for (var l of player.getAudioLanguages()) {
const lang = player.getAudioLanguages().includes(prefLang) ? prefLang : "en";

but that can be done in a different commit (I'll push that shortly after merging your PR).

Copy link
Member

@Bnyro Bnyro left a comment

Choose a reason for hiding this comment

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

don't know much about JS but this for..of works in Firefox. Apparently it is ES6 compliant, supported pretty much everywhere except IE11

Should be fine, it's used in other places at Piped too.

Thanks for the PR!

@Bnyro Bnyro merged commit b39574a into TeamPiped:master Jan 7, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants