-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
Conversation
@fuzzard : IMO this should go in for v21 as well. |
@hagaygo please apply jenkins changes |
c9def4e
to
7c3ebd8
Compare
@CastagnaIT |
when you merge the 2 commits in a single one then will be ok |
7c3ebd8
to
12364f8
Compare
@CastagnaIT jenkins4kodi popped a message again about coding style although the previous fix seems to be in.
So i guess it is a false positive or something like that. Thanks for your patience. |
yes was the previous check, when jenkins will have finish should disappear |
fd3fd8b
to
a80128e
Compare
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, 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.
const std::string subPath = CSpecialProtocol::TranslatePath("special://subtitles"); | ||
|
||
if (URIUtils::IsHTTP(strCurrentFile) && subPath.empty()) |
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.
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.
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.
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).
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.
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
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.
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>
a80128e
to
32cab38
Compare
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
Checklist: