Kodi Community Forum

Full Version: How i can wipe/clear sets like "art","uniqueid" or "ratings"
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi

I try to wipe/clear sets like "art","uniqueid" or "ratings" via JSON, e.g. ratings for an episode. If I sync a bunch of ratings like
json:
{"episodeid":37,"ratings":{"imdb":{"rating":8.5,"votes":44444},"themoviedb":{"rating":7.7,"votes":20}}}
new ratings will be added and already existing will be overwritten, but all the others who not are in the "new" list will not be removed.

I have not found a way to delete existing rating entries. For uniqueid it works if I send a "null" value like
json:
{"episodeid":37,"uniqueid":{"imdb":null,"themoviedb":"45578"}}
but for that first I've to get a list of all existing entries via "GetEpisodeDetails", then I've to add the not in new list existing entries with a "null" value only to clean no longer valid IDs from that list. Same for "art" entries.

IMO existing entires should be removed automatically with each new "SetXYDetails" JSON command if a set has an entry. Also it should be possible to clean a whole set without reading existing entries.
That is the way to unset these values. I prefer it the way it is; the proposed change means that it isn't possible to add a value without first reading existing entries, which happens more often than "cleaning".

The current behavior makes sense to me: if "title" isn't specified then it stays the same, it isn't removed, so why should art or ratings or IDs?
I partially understand your arguments. And yes, it's correct to don't remove entires if you don't specify it in a command, e.g. this only set the plot to empty, all other entries and link tables will be untouched:
json:
{"episodeid":37,"plot":""}

But the methode calls "Set" episode details and set usually means "SET / =" like in SQL. So if I use
json:
{"episodeid":37,"ratings":{"imdb":{"rating":8.5,"votes":44444},"themoviedb":{"rating":7.7,"votes":20}}}
it should remove all existing ratings and add only the new submitted. The command actually says "ratings are X & Y" and not "ADD (or CHANGE)".

My point also is that you use
json:
{"episodeid":37,"writer":{"Hans Brot","Paul Zopf"}}
then all existing writers will be removed and replaced only with the new list. This is so with all other lists as directors, genres or countries, so why it should be different for art, ratings, uniqueid and maybe other fields/tables? It's inconsistent to replace it once and once only to add.

In my application (Ember Media Manager) I want to sync/send my data as a complete set whitout clean up some "special" tables at first. As I have already said it looks like it's impossible to remove an existing rating, it tried it with
json:
{"episodeid":37,"ratings":null
json:
{"episodeid":37,"ratings":{}
json:
{"episodeid":37,"ratings":{null}
json:
{"episodeid":37,"ratings":{"imdb":{"rating":null}}}
json:
{"episodeid":37,"ratings":{"imdb":{"rating":0}}}
json:
{"episodeid":37,"ratings":{"imdb":{"rating":-1}}}
json:
{"episodeid":37,"ratings":{"imdb":{}}
json:
{"episodeid":37,"ratings":{"imdb":null}}
and some others, but no one works.

My proposition is to add an additional JSON methode to "ADD" entries to an existing list to return the original method to the function it is named after.

And for the moment i need a workaround to clear the ratings. So if you know the correct JSON command i will be happy for the moment Smile
I definitely do not agree that the existing functions should change behavior to match your exceptional use case. They make perfect sense from another perspective*. The solution to your use case is to get the existing values and then null each of them**.


* Read {"episodeid":37,"ratings":{"imdb":{"rating":5, "votes":123}}} as "Setting the IMDB rating to 5", not setting all the ratings. This is how to set a value in an object graph without passing in the whole new object graph, which is what is wanted in the general case. I could maybe see adding a new method to flat replace all details of an item, something like "Overwrite*Details" or "Replace*Details".


** Though I can confirm it currently (recent-ish nightly) doesn't work for episodes, but it does for movies and TV shows. {"episodeid":37,"ratings":{"imdb":null}} would be the way to remove the 'imdb' rating.
(2019-04-03, 06:43)rmrector Wrote: [ -> ]I definitely do not agree that the existing functions should change behavior to match your exceptional use case.
I can understand that.
(2019-04-03, 06:43)rmrector Wrote: [ -> ]They make perfect sense from another perspective*.
I agree with you too.
(2019-04-03, 06:43)rmrector Wrote: [ -> ]The solution to your use case is to get the existing values and then null each of them**.
Also no problem, I have enough space to write additional code ;-)
(2019-04-03, 06:43)rmrector Wrote: [ -> ]I could maybe see adding a new method to flat replace all details of an item, something like "Overwrite*Details" or "Replace*Details".
I do not necessarily need that, but the idea is certainly not wrong. As I said, the current behavior of "SETxyDetails" was just illogical for me.
(2019-04-03, 06:43)rmrector Wrote: [ -> ]Though I can confirm it currently (recent-ish nightly) doesn't work for episodes, but it does for movies and TV shows. {"episodeid":37,"ratings":{"imdb":null}} would be the way to remove the 'imdb' rating.
Thank you for the test and the feedback. Of course I only tried episodes.