Kodi Community Forum
Beta Metadata Editor - Update library + .nfo informations - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33)
+--- Forum: Add-on Support (https://forum.kodi.tv/forumdisplay.php?fid=27)
+---- Forum: Program Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=151)
+---- Thread: Beta Metadata Editor - Update library + .nfo informations (/showthread.php?tid=349035)

Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14


Metadata Editor - Update library + .nfo informations - sualfred - 2019-11-07

Image

Metadata Editor Script
Kodi script to edit basic metadata information of library items with support to automatically update the .nfo file.

Supported Kodi versions
  • Leia
  • Matrix (Untested yet, but should work out of the box.)

Where to get it
  • The most current versions are always available on my private Kodi repo
  • Once everything is 100% working it gets released on the Kodi repo

Supported .nfo types
The updating of .nfo items is only possible for video library items, because the JSON result doesn't return any path for music entries.

Supported .nfo namings:
  • %Filename%.nfo
  • tvshow.nfo
  • movie.nfo

By default the script is creating a .nfo if missing. This can be disabled in the settings.

Scrapers
The script is using TMDb (free) and OMDb.

I already have included a TMDb API key (hardcoded).

For OMDb please visit https://omdbapi.com/ and create your own API key and add it to the addon settings.
Please note that the free available OMDb API key is limited to 1.000 calls a day. I highly recommend to become a patreon of the creator of OMDb.
For $1 a month your daily limit gets increased to 100.000 calls / day. Support it and benefit.

TMDb scraper (not used for episodes, because of different global airing dates and episode orders):
  • Rating + votes
  • MPAA
  • Premiered year
  • TV show status
  • External unique IDs (IMDb, TVDb)

OMDb scraper:
  • Rotten ratings (all four of them incl. votes)
  • Metacritic (just rating, no votes available)
  • IMDb (ID + rating + votes)

Note:
There is a experimental setting available to use title + year for the OMDb call, if the IMDb ID is not available. It's disabled by default, because there is a high chance for false positive returnings and wrong fetched metadata. I do not recommend to enable it.

Running service
  • Updates the watched states in the .nfo automatically if item is played or marked/unmarked as watched (can be disabled)
  • Option to rate your movie/episode after it has been played 100% (can be disabled)

Additional features of the rating updater
  • Updates MPAA (can be disabled)
  • Updates TV show status
  • Updates missing uniqueids
  • Updates original title
You can configure the preferred MPAA rating in the addon settings.
It's also possible to skip "not rated" or to enable/disable the fallback to US ratings


Run the script / context menu
The script can be called with the context menu or RunScript() commands (useful for skinners).
A library updating task can be started by starting the addon itself.

Context menu entries:
 
  • Metadata Editor / Open Editor = editor dialog or sub menu if more options are available
  • Add/remove available genres = quickly edit the genres which the item belongs to
  • Add/remove available tags = quickly edit the tags which the item belongs to
  • Add/remove favourite tag = shortcut to toggle the library tag Watchlist. Can be used to create custom splitted favourite widgets.
  • Update .nfo = updates the .nfo
  • Update ratings = will update ratings by using the OMDb and TMDb API

RunScript calls:
  • RunScript(script.metadata.editor,dbid=$INFO[ListItem.DBID],type=$INFO[ListItem.DBType]) = opens editor
  • RunScript(script.metadata.editor,action=setuserrating,dbid=$INFO[ListItem.DBID],type=$INFO[ListItem.DBType]) = sets user rating and updates the nfo if enabled
  • RunScript(script.metadata.editor,action=setgenres,dbid=$INFO[ListItem.DBID],type=$INFO[ListItem.DBType]) = opens genre selector
  • RunScript(script.metadata.editor,action=settags,dbid=$INFO[ListItem.DBID],type=$INFO[ListItem.DBType]) = opens tags selector
  • RunScript(script.metadata.editor,action=togglewatchlist,dbid=$INFO[ListItem.DBID],type=$INFO[ListItem.DBType]) = toggle watchlist tag
  • RunScript(script.metadata.editor,action=updatenfo,dbid=$INFO[ListItem.DBID],type=$INFO[ListItem.DBType]) = updates the .nfo

RunScript calls for updating ratings:
  • RunScript(script.metadata.editor) = Shows select dialog to update movies, shows and episodes or all of them
  • RunScript(script.metadata.editor,action=updaterating,dbid=$INFO[ListItem.DBID],type=$INFO[ListItem.DBType]) = Updates rating for the requested item
  • RunScript(script.metadata.editor,action=updaterating,content=movies) = Updates all ratings for movies (combination of available TMDb, TVDb, IMDb IDs)
  • RunScript(script.metadata.editor,action=updaterating,content=tvshows) = Updates all ratings for TV shows (combination of available TMDb, TVDb, IMDb IDs)
  • RunScript(script.metadata.editor,action=updaterating,content=episodes) = Updates all ratings for TV shows (only if IMDb is available)
  • RunScript(script.metadata.editor,action=updaterating,content=movies+tvshows+episodes) = Updates all ratings for provided content. Values are splitted by '+'

Help to translate the script into your language!
Translate on TransiFex


Donations
Free beer or money for the tip jar of my daughter is welcome and helps me to stay motivated Smile
Please click here to donate


Screenshot
Image


Moderator Edit
The original author @sualfred has not been active for a couple of years.
A forked version for v20 by @HeresJohnny can be found here... https://forum.kodi.tv/showthread.php?tid=349035&pid=3109732#pid3109732





RE: Metadata Editor - Update library + .nfo informations - sualfred - 2019-11-07

@nessus @bsoriano 
For future discussions please use this thread.


RE: Metadata Editor - Update library + .nfo informations - Karellen - 2019-11-07

@sualfred

Fantastic!! A feature of Kodi that has been long missing.

I tested and works as expected. I have a few comments...

Movies
1. Do you intend to include editing of Actors?
2. Two types of Rating and Votes tags are written to the nfo file. This one is not used by Kodi...
xml:
<rating>9.9</rating>
<votes>1000</votes>
3. Two types of UniqueID's are written to the nfo file. This one is not used by Kodi...
xml:
<imdbid>tt2304933</imdbid>


TV Shows
1. Status- Will not accept an entry, but it does update the DB with the entry. Why does it say missing Kodi feature?
2. A bit of wishful thinking... would be nice if you could edit the <episodeguide> URL. Offer either TMDB or TVDB template and the user just adds the ID value


Episodes
You allow changing of Season and Episode numbers, but this is incorrect. While it will temporarily accept the new Season and episode numbering, the next rescrape, rescan or rebuild of the library and it will be lost as that information comes from the file name not the nfo file tags.

Do you think this thread would be better suited in Metadata Scrapers forum?


RE: Metadata Editor - Update library + .nfo informations - sualfred - 2019-11-07

Movies:
1. Actors are little pita but doable. Because of the thumbnail url. On my list for later.
2+3. I know, but Emby uses it. It's just to cover the compatiblity.

TV Shows:
1. JSON RPC is not able to return the field, but to be set. Created a REQ thread a few days ago.
2. Will be added

Episodes:
What do you suggest? Also rename the file or just drop it completely?

Edit:
Regarding the cast. To get the best integration I would require something like VideoLibrary.GetActors that would return all locally known actors with the thumbnail(s) location. It's really a pain that Kodi is handling the actor per item in the item folder and not globally. It always feels like storage wasting. I mean.... do you know the black guy in the movie *place random movie here*? It's Samual Jackson. No need to have 10000 copies of the same actor thumbnail Wink


RE: Metadata Editor - Update library + .nfo informations - Karellen - 2019-11-07

(2019-11-07, 11:27)sualfred Wrote: Movies:
1. Actors are little pita but doable. Because of the thumbnail url. On my list for later.
2+3. I know, but Emby uses it. It's just to cover the compatiblity.
Ok, understood.

(2019-11-07, 11:27)sualfred Wrote: 1. JSON RPC is not able to return the field, but to be set. Created a REQ thread a few days ago.
Ok, must have missed that.

(2019-11-07, 11:27)sualfred Wrote: 2. Will be added
Great. TVDB uses v2 API which can be found here... https://forum.kodi.tv/showthread.php?tid=323588 under "What if I'm using NFO files?"
TMDB I'll have to dig it up if you need it.

(2019-11-07, 11:27)sualfred Wrote: What do you suggest? Also rename the file or just drop it completely?
If you rename the file, then Kodi loses the path to the file and it becomes unplayable, unless you are also updating the path? If you cannot update the path, then I would recommend dropping the Season and Episode edit as it will lead users astray and cause a bit of confusion. I can already imagine all the posts about losing their episode sorting after rebuilding their library.


RE: Metadata Editor - Update library + .nfo informations - sualfred - 2019-11-07

@Karellen 
Quote:TMDB I'll have to dig it up if you need it.

Yes, please. I do not find the correct URL anywhere.
Quote:If you rename the file, then Kodi loses the path to the file and it becomes unplayable, unless you are also updating the path? If you cannot update the path, then I would recommend dropping the Season and Episode edit as it will lead users astray and cause a bit of confusion. I can already imagine all the posts about losing their episode sorting after rebuilding their library.
Ok, thanks. I guess I'll drop it. Renaming would not be an issue, but if there are other episodes with the same episode index...  and the different naming schemes ... na,  I don't want a rainy storm of s**t over my head.


RE: Metadata Editor - Update library + .nfo informations - Karellen - 2019-11-07

(2019-11-07, 11:57)sualfred Wrote: Yes, please. I do not find the correct URL anywhere.
In the below example, the number "1402" in two locations is the ID for the show that is replaced
xml:
<url cache="tmdb-1402-en.json">http://api.themoviedb.org/3/tv/1402?api_key=6a5be4999abf74eba1f9a8311294c267&amp;language=en</url>

(2019-11-07, 11:57)sualfred Wrote: Ok, thanks. I guess I'll drop it. Renaming would not be an issue, but if there are other episodes with the same episode index...  and the different naming schemes ... na,  I don't want a rainy storm of s**t over my head.
Yea, probably best. Too many variables to go wrong.


RE: Metadata Editor - Update library + .nfo informations - Karellen - 2019-11-07

(2019-11-07, 11:27)sualfred Wrote: Regarding the cast. To get the best integration I would require something like VideoLibrary.GetActors that would return all locally known actors with the thumbnail(s) location. It's really a pain that Kodi is handling the actor per item in the item folder and not globally. It always feels like storage wasting. I mean.... do you know the black guy in the movie *place random movie here*? It's Samual Jackson. No need to have 10000 copies of the same actor thumbnail
It would be nice to have centralised Actors folder, like Movie Set Artwork folder. But developers are scarce at the moment, and no-one has shown interest in coding the change and lots of other more important jobs to do.


RE: Metadata Editor - Update library + .nfo informations - sualfred - 2019-11-07

@Karellen 

Thanks. Is the url different if the user has configured a different language?

Examples
Code:

<url cache="tmdb-1402-en.json">http://api.themoviedb.org/3/tv/1402?api_key=6a5be4999abf74eba1f9a8311294c267&amp;language=en</url>
<url cache="tmdb-1402-de.json">http://api.themoviedb.org/3/tv/1402?api_key=6a5be4999abf74eba1f9a8311294c267&amp;language=de</url>
<url cache="tmdb-1402-pt_PT.json">http://api.themoviedb.org/3/tv/1402?api_key=6a5be4999abf74eba1f9a8311294c267&amp;language=pt_PT</url>
<url cache="tmdb-1402-pt_BR.json">http://api.themoviedb.org/3/tv/1402?api_key=6a5be4999abf74eba1f9a8311294c267&amp;language=pt_BR</url>
....

edit:
And if yes, are pt_PT in lowercase or is the region in uppercase?


RE: Metadata Editor - Update library + .nfo informations - Karellen - 2019-11-07

Ah, yes I did not think of the language. Might be a bit more difficult than I first thought. Not sure how to advise there. Might be too difficult to cover the language variable.


Also, Last Played and PlayCount. Are you able to include these as editable items?


RE: Metadata Editor - Update library + .nfo informations - sualfred - 2019-11-07

Getting the language is not big deal. And even if not, I can add an addon setting for it. I just need to know if it differs from setting to setting Smile

Yes. But if I remember it correctly, the new Playcount value was ignored even if JSON returned "OK". Will take a look at it again. 
Edit: Works, just takes up to 30s until the container information gets updated for this value.


RE: Metadata Editor - Update library + .nfo informations - nessus - 2019-11-07

Hi sualfred

All working fine. I've tested and had no issues.
Excellent approach on updating rating and votes. Is it possible to add a separate script call for a bunch update of all movies or tv shows?
Also very nice addition the Fav. tag feature although IMO you should rename it to Watchlist so to not be confused with Kodi favorites.

Great work man... as always!!!

Cheers
Nessus


RE: Metadata Editor - Update library + .nfo informations - sualfred - 2019-11-07

@Karellen 
Created a dummy db and it is honored. Will add a solution for it.
Code:
<episodeguide><url cache="tmdb-1402-pt-br.json">http://api.themoviedb.org/3/tv/1402?api_key=6a5be4999abf74eba1f9a8311294c267&amp;language=pt-br</url></episodeguide>

Regarding the cast again:
The videodb has all actors + thumb location already stored in the videodb file in a own table. If you guys add an JSON call for receive it it would be awesome. 
Do you know if it's against the rules to directly access the sqllite file to get those values? Without writing of course, just reading the table. 

But hmmm.... it also contains directors, writers, etc. That means a return of thousand of items for a bigger database. 

@nessus 
Yeah, watchlist makes sense. Will rename it.


RE: Metadata Editor - Update library + .nfo informations - nessus - 2019-11-07

Quote:@nessus 
Yeah, watchlist makes sense. Will rename it.
Wink
 
(2019-11-07, 13:55)nessus Wrote: Is it possible to add a separate script call for a bunch update of all movies or tv shows?



RE: Metadata Editor - Update library + .nfo informations - sualfred - 2019-11-07

Example scenario?