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

Store streamed video subtitle on custom subtitles path if defined by user #24752

Merged
merged 1 commit into from
Mar 7, 2024

Conversation

hagaygo
Copy link
Contributor

@hagaygo hagaygo commented Feb 23, 2024

Description

The fix is by checking if a custom subtitle path is defined, if so, do store the downloaded subtitle on the custom path.
This way the user is allowed to keep the old kodi behavior if indeed needed.

Motivation and context

fixes the "regression" described on #24742 which was introduced on #24252

How has this been tested?

Tested locally on a windows machine on my setup.

When no custom subtitles path is defined , the new behavior is kept.
When setting a custom subtitle path the old behavior is back , and the file is stored as stream.lang.srt on the custom subtitle path.

What is the effect on users?

Users like me which utilized the old behavior can keep it.
Users which did not set custom subtitles path should not be affected at all.

Types of change

  • Bug fix (non-breaking change which fixes an issue)
  • Clean up (non-breaking change which removes non-working, unmaintained functionality)
  • Improvement (non-breaking change which improves existing functionality)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that will cause existing functionality to change)
  • Cosmetic change (non-breaking change that doesn't touch code)
  • Student submission (PR was done for educational purposes and will be treated as such)
  • None of the above (please explain below)

Checklist:

  • My code follows the Code Guidelines of this project
  • My change requires a change to the documentation, either Doxygen or wiki
  • I have updated the documentation accordingly
  • I have read the Contributing document
  • I have added tests to cover my change
  • All new and existing tests passed

@neo1973 neo1973 added Type: Fix non-breaking change which fixes an issue Component: Subtitles v21 Omega labels Feb 26, 2024
@neo1973 neo1973 added this to the "P" 22.0 Alpha 1 milestone Feb 26, 2024
@fuzzard fuzzard added v22 "P" and removed v21 Omega labels Feb 26, 2024
@hagaygo
Copy link
Contributor Author

hagaygo commented Feb 26, 2024

@fuzzard @neo1973
If i understand the labels correctly , this will not get into omega (v21) but only to v22 ?
If so it means v21 users will have the "regression" i mentioned (most users don't try beta versions and especially since it was introduced between b2 and b3)

@arnova
Copy link
Member

arnova commented Feb 29, 2024

@fuzzard : IMO this should go in for v21 as well.

@CastagnaIT
Copy link
Collaborator

@hagaygo please apply jenkins changes
and also the commit title should follow our guidelines
in short: too long title, and missing component prefix

@hagaygo
Copy link
Contributor Author

hagaygo commented Mar 2, 2024

@CastagnaIT
I hope it is o.k now.

@CastagnaIT
Copy link
Collaborator

when you merge the 2 commits in a single one then will be ok

@hagaygo
Copy link
Contributor Author

hagaygo commented Mar 2, 2024

@CastagnaIT
Squashed the commits

jenkins4kodi popped a message again about coding style although the previous fix seems to be in.
Tried to apply the patch just to make sure and i get

error: patch failed: xbmc/video/dialogs/GUIDialogSubtitles.cpp:556
error: xbmc/video/dialogs/GUIDialogSubtitles.cpp: patch does not apply

So i guess it is a false positive or something like that.

Thanks for your patience.

@CastagnaIT
Copy link
Collaborator

yes was the previous check, when jenkins will have finish should disappear

Copy link
Member

@ksooo ksooo left a comment

Choose a reason for hiding this comment

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

Sorry, need to put a -1 to overrule the one +1 this PR already has. I think the code should be polished a bit more before merge.

Comment on lines 551 to 553
const std::string subPath = CSpecialProtocol::TranslatePath("special://subtitles");

if (URIUtils::IsHTTP(strCurrentFile) && subPath.empty())
Copy link
Member

@ksooo ksooo Mar 3, 2024

Choose a reason for hiding this comment

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

If URIUtils::IsHTTP(strCurrentFile)evaluates to false you do not need the value of subPath - so no point to always calculate it. The code should be optimized to only calculate subPath if it is actually needed.

Copy link
Contributor Author

@hagaygo hagaygo Mar 3, 2024

Choose a reason for hiding this comment

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

Hi

Thanks for your feedback.

While i understand the motive for optimization here (although i am not sure how really "pricey" is a call for TranslatePath) the only solutions i can think of (not a cpp expert) are :

1.Make the .empty() check inline in the if conidtion something like :

if (URIUtils::IsHTTP(strCurrentFile) && CSpecialProtocol::TranslatePath("special://subtitles").empty())

and move the subPath back to the original location

In this case , we will only save the call to TranslatePath when IsHttp is false but we'll have 2 assignments in the code for TranslatePath, which is kinda of duplicate code in same method logic (if the settings key is gonna changed somewhere in the future , we'll have 2 lines to update here) i perosnally prefer a more maintainable code than more optimized one (again , not sure about the "cost" of TranslatePath call).

2.Create a wrapper method that will return the value of CSpecialProtocol::TranslatePath("special://subtitles") and call it all around this method, we can add some sort of caching so multiple calls (can happen when IsHttp is false and path is not empty) won't call to TranslatePath again.

I personally think current code is the best balance between the issues here and if there is a big "cost" when calling TranslatePath the optimization needs to be done there and not in this code block (and every other place that it get called).

Copy link
Member

Choose a reason for hiding this comment

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

unless I read the code wrong, the subpath is always needed here, because if URIUtils::isHTTP is false, the subPath still is used in the else part of this condition. So subPath has to be resolved regardless if isHTTP is true or false

Copy link
Contributor

Choose a reason for hiding this comment

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

From a performance perspective, wouldnt the empty check be better off first? Surely its quicker than ishttp (that does stack checks/special folder checks etc.

From what i can gather, the old behaviour was always just false for this check, and thats the behaviour you are after when a special subtitles path is set. So @ksooo i think the subpath is necessary, but the ordering of the statements should be least to most expensive for an early fail in the event a user has the special path set.

Applied jenkins diff patch

Update xbmc/video/dialogs/GUIDialogSubtitles.cpp

Co-authored-by: Miguel Borges de Freitas <enen92@kodi.tv>
@fuzzard fuzzard merged commit 9ae50be into xbmc:master Mar 7, 2024
2 checks passed
@hagaygo hagaygo deleted the subtitle-store-fix branch April 13, 2024 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Subtitles Type: Fix non-breaking change which fixes an issue v21 Omega
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants