-
Notifications
You must be signed in to change notification settings - Fork 887
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
Localization inconsistency fix for Local API #2535
Localization inconsistency fix for Local API #2535
Conversation
This changes where the title comes from on the response object from ytdl. This is related to FreeTubeApp#2530.
Co-authored-by: absidue <48293849+absidue@users.noreply.github.com>
Head branch was pushed to by a user without write access
Head branch was pushed to by a user without write access
Co-authored-by: absidue <48293849+absidue@users.noreply.github.com>
Co-authored-by: absidue <48293849+absidue@users.noreply.github.com>
Head branch was pushed to by a user without write access
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Head branch was pushed to by a user without write access
Co-authored-by: absidue <48293849+absidue@users.noreply.github.com>
I feel like these were all very good changes. I see the merging is blocked because 1 review is requesting changes, but I believe that I reviewed all of the requested changes. I can make more changes if it is necessary. I am just checking in on where we left off on this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay, at the time I had finished the code review but hadn't tested the code yet.
While testing I noticed that it spits out the fallback error if the video is missing a description (second video in the playlist in your issue), one easy way to fix that would be to check if there is a non translated description (empty string) before doing the whole try catch stuff. Ideally we only want the error being logged if it legitimately failed to extract the translated description (not being able to do it when there is no description is expected behaviour).
This should prevent errors from erroneously being thrown on videos which have a blank description. If the description is undefined or does not contain a 'runs' field, the resulting descriptionLines should be and empty array. Then, videoDescription will be an empty string.
Head branch was pushed to by a user without write access
Hi @absidue, You are exactly correct. // Adding a ? to line 310 of src\renderer\views\Watch\Watch.js
const descriptionLines = result.response.contents.twoColumnWatchNextResults.results.results.contents[1].videoSecondaryInfoRenderer.description?.runs
this.videoDescription = descriptionLines?.map(line => line.text).join('\n') ?? '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me now. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks fine but how do I test the behaviour locally?
These are some examples of videos I have collected of where this code changes the behavior:
It would also be worth testing some videos which have a default locale of I just noticed a problem. There are extra new lines that shouldn't be there. It looks like there is already a |
Head branch was pushed to by a user without write access
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hopefully we won't have to hardcode en-us in the future and will be able to respect user's locale preferences
* development: Translated using Weblate (Spanish) Don't log any errors if there are no SponsorBlock segments (FreeTubeApp#2555) Add Scoop to readme, issue template and label workflow (FreeTubeApp#2553) Build and release 7zip artifacts (FreeTubeApp#2558) Increase width of quality selector so that 1080p60 doesn't overflow into the full screen button (FreeTubeApp#2556) Translated using Weblate (Russian) Localization inconsistency fix for Local API (FreeTubeApp#2535) Translated using Weblate (Italian)
Localization inconsistency fix for Local API
Pull Request Type
Please select what type of pull request this is:
Related issue
closes #2530
Description
This applies a workaround for the inconsistency in the responses from
ytdl
andytpl
. The result of this change is that the video title and description are localized toen-US
byytdl
(as it was expected to be based on the following code snippet).Screenshots (if appropriate)
Before this change:
After this change:
Desktop (please complete the following information):
Additional context
The inconsistency described in #2530 still occurs when using the Invidious API; however, as far as I can tell, this is an issue with invidious. Even if we aren't sending a locale, it should give back titles and descriptions that reflect a consistent locale, but I don't believe there is a way to fix that inconsistency without digging into the invidious source, and at that point, it isn't an issue with FreeTube.