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
[JSON-RPC] Adding support for plugin based video source inside json-rpc command GetFileDetails #16087
[JSON-RPC] Adding support for plugin based video source inside json-rpc command GetFileDetails #16087
Conversation
…pc command GetFileDetails
|
||
std::string path = URIUtils::GetDirectory(file); | ||
if (!URIUtils::IsUPnP(file)) |
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.
The indentation seems a little off here.
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.
I replaces tabs with spaces;
Now it should look better;
@thebrid any chance you could approve/review this ? I would love to start using it |
@bigretromike I don't have merge access. |
oh, thanks anyway. Will wait then. |
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.
This should not be in the JSON-RPC layer.
It looks like just skipping the CFile::Exists
check should get the basics working, but the better solution is a new CPluginFile
from CFileFactory
to match CPluginDirectory
, and implement the "existence" check described in #14210.
I do still feel strongly that this shouldn't be an extra code path in the JSON-RPC layer, though. I tried a patch that just skipped the "exists" check for plugins and a path like This particular function works by listing a directory and then picking the requested item out of that list, which means plugins need to present like a basic file system: listing the parent directory should include the requested path. |
@rmrector Strange because when adding also with this code skipped:
I get InvalidParams error because this code throw it:
But yes, when asking for |
Also the issue is you are unable to ask "database" about additional information:
return:
Even when
And the fact that I 'watched' that one file is also on Kodi main window 'In progress TV shows' Which shows that you cannot ask database for Also when you adding content from Plugin Source you add it to db, when you play it you save metadata in db so it is logical that I want to access that data somehow and read it from DB not from plugin. |
@bigretromike that's all you need: AkariDN@6d5d048 |
Wait, no, this doesn't sound right. This method is about file details first and I think it should only return info if the file can be accessed; it's not just a way to find database info by file path. Plugins get to determine what "can be accessed" means. Or maybe more accurately the plugin layer: |
@rmrector I don't know where you came to that conclusion but @AkariDN Would you mind pushing your fix as PR? As the author/creator of this awesome feature you already pave the way. I just tried to make this work as best I was able to without any experience while trying my best to not break ANY legacy code - looks like it was not enough, and being not able to get dbid from already added items without hacks like mapping service/hooking to player is a waste. I don't mind if my PR will be closed without merge, the important part is to make the feature usable so people can start using it without waiting next 2 version to anything to be added. |
Based on function name I think the main goal is to return file's information, especially when "media=video". In this case call to plugin is a bad idea. If this function should check plugin url "existence" it can be done in "media=file" mode via plugin call. If this function should always call a plugin, then it is not suitable for author's purposes. Could you please point to json-rpc function that can return dbid by plugin url (path) without calling a plugin?
I can make a PR, but I have no time to support it. Sorry. I'm not a json-rpc expert. |
It's right in the name,
There isn't such thing exactly. The closest we've got now is I appreciate that you need something more, but it needs to be designed differently. Plugins are not special here. Maybe a new method to look up library info by path like Akari's patch, but not limited to plugins. This functionality could be just as useful to other file sources. |
@bigretromike If rmrector insist that
|
A general point - when changing the internal functionality of JSON methods a bump of patch version is also needed (so |API consumers know that something has changed). But before we get to that I have to say I have hesitations about this modifcation to Also if the items is scraped into the library why are you using GetFileDetails at all (that is for files not in the library)?
Yeap, I think I agree with @rmrector. No doubt there is some new fucntionality you need, and happy to help work that out, but not convinced this is the right approach. Far too much is already done at JSON level that should be down in core (and thus common to GUI, Python and JSON intefaces) and results in different implementation of things depending on route through the code which is not good. |
Like I mention before, when adding item to VideoLibrary via new feature which is Source=Plugin currently there is no way to retrieve DBID of that item, the only JSON-RPC I found in Kodi Documentation was
The issue here is that without modification Kodi code treat plugin source diffrently - it does not see any added file, while VideoLibrary is proper populated. So doing nothing would make tread it diffrently. Also without support for
As I would be super happy I also know how this could end, you would like to have this in core - maybe on python level, and while its super super no one will be willing to do this right now. Quick fix for one function is a Probably adding anything exclusive to Plugins in json-rpc would be also a TL;DR; I wanted to fix the only function that needed to be fix Maybe this is all not needed, maybe there is a way? Just need to know this:
|
I didn't saw your response there. |
Ok - I understand that noone want to approve this - nothing strange, it just a "quick way to fix new problem". It took me few days to be able to make this work, and I don't think it was a waste of time because it did worked in the end - maybe not by standards that this open source project needed by in fact did work and did not break anything is enough for me. I understand that it would be even better if there would be a different commands/json-rpc/python/etc endpoint that would support this (somehow)... and I hope that some day it will be needed ... but Im unable to help with it, because the point of complication in this project is our of my league and I admit it. So if there is nothing more I can do please close this PR, because I have not clue how to make a new function in other place or use pointers - it was miracle that I was manage to copy-past those there. And I just wish that someone, someday will need this function and will be willing to write code that will be worthy being merged. TL;DR; I was hoping that lack my poor quality code would be fixed by someone that knew what to do and merge in the end, maybe next time... |
The only thing I insist on here is that plugins don't get special treatment in the JSON-RPC layer. I suppose I am presenting other ideas, but that is the one thing I'd like now.
Both will get as much info as possible from the file system and the database - the plugin file system is just designed to return library-level data in the initial listing.
@bigretromike The IDs are available in many library methods, and the library list methods can be filtered on several fields. If you want to sync libraries use |
@rmrector you are totally right about The only unknown for me is still why you think I wan't to treat plugins special ? From my perspective I tried to make it same for files and plugin, because when you do json-rpc for file info you don't play that file, why would you do that for plugin. Do you assume I treat them differently because I used code do build Edit1: Also going back to your recommendation about using Edit2: Looks like its not possible to Filter Episode by its |
@AkariDN Could the issue with JSON-RPC is result of a bug when VideoLibrary is populated with plugin-source based files? Because for some reasons in Because when you look for them using |
using |
This is Kodi plugin parenting rules (see
|
It's not about what you want, the code you are adding literally treats plugins differently from all other paths in the JSON-RPC layer. Their behavior should be adjusted where it differs in the first place, don't add another place where their behavior differs. |
I appreciate your effort here but the fix for #15897 will need to work a different way. As you've noted you won't be able to help code-wise I will go ahead and close this PR, but this is useful information for future changes. |
That What about Kodi logging this:
So Kodi has a call I am the first person to cheer for internal consistency and good naming standards when designing a framework, but if the naming of internal functions was too limited from the start, please don't use it as a design decision, because you are dragging everything down the wrong path with it. IMO |
@rmrector can this be reconsidered? The only workaround that is possible now is to manually modify the database of Kodi directly, and that's something that should be avoided IMO. |
Nope. Merging incorrect (and mostly unnecessary) code changes is not healthy for the project.
In my testing works just as well as this PR, but the author declined. Yes, a change is needed to support plugin paths, which has been noted with #15897, but this PR is not the solution. Discussion on the forum about a more thorough implementation is welcome, or submit another PR with a more thorough implementation. |
I submitted a new PR with a fix that hopefully meets all Kodi team requirements. #17202 |
Description
My code change only touch one function of JSON-RPC, it check if the item that we asked for is based on plugin. Next it try to access that plugin and get items from it, like the old way but I adapted it to the way the creator did with video source (using PluginDirectory). I rearange old code so if its non plugin content it works exactly the same as it did and if its plugin source it try to extract the proper url for it because without extracting the proper url this would end up with playing the while trying to match it. DB saves the url for file and we check against plugin, thats why It tries to get the url thats ends with
/
because we need to execute the plugin to get the ListItems for that file.Motivation and Context
From Kodi 18.2 you can use video plugins as video library source, this is awesome feature, but not everything support this source. For example the JSON-RPC that could return information about file and ID from db. With current code the function return INVALID Parameters which is other way of saying
Not supported
instead ofyou used wrong parameters
.This fix issue that I posted some time ago: #15897
Also I would love this being backported to 18.x - this code should be compatible with it because I started on 18.x and then upgraded to 19.x
How Has This Been Tested?
This code only touch one function of JSON-RPC call for item inside db, as before
plugin://
wan't avaiable to be inside video library this code does not break any compatibility.I coded/compiled/run this code on Win10Pro with VisualStudio2017, I added few normal files to video library and I added
plugin.video.nakamori
as source test, I then executed JSON-RPC GetFileDetails with full url from DB to get ID to verify it working - it did return proper ids. I run JSOn-RPC GetFileDetails on normal (file) objects from db and the results was proper ids.Types of change
Checklist: