Kodi Community Forum
Export <userrating> to .nfo - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33)
+--- Forum: General Support (https://forum.kodi.tv/forumdisplay.php?fid=111)
+---- Forum: OS independent / Other (https://forum.kodi.tv/forumdisplay.php?fid=228)
+---- Thread: Export <userrating> to .nfo (/showthread.php?tid=349615)

Export <userrating> to .nfo - firewater - 2019-11-27

How can I export the
that I create with 
to the movie.nfo of said item? The closest I can find is how to export to .nfo, but doing it adds a lot of <> values that I don't use, whereas I just need to write that one line.

I constantly lose the <userrating> of movies because of moving the database around for various reasons. If I could get it written to the .nfo, then it would be perfect.

RE: Export <userrating> to .nfo - Karellen - 2019-11-27

Simply saving a single tag and value to an nfo file and then expect to scan it back to the library won't work with Kodi.

RE: Export <userrating> to .nfo - DaVu - 2019-11-27

If a userrating was set via GUI from the movie information screen and if you then export the movie(s) to nfo file(s), then this will be exported as well. Just tested that.

All the other tags are also needed if you import the nfo file again. Kodi doesn't scrape parts of the nfo only. So you need all the information. The other tags inside this nfo file are coming from the scraper which are written into your database. By exporting all the entries (title, plot, mpaa rating, user rating and what not) are read from the database and written to the nfo file.

RE: Export <userrating> to .nfo - firewater - 2019-11-28

Thanks for the quick response. To be clear what I'd like is <userrating> be written "to" the .nfo file, not "as", the .nfo file. My .nfo files look like this:

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
        <title>2001: A Space Odyssey</title>
        <sorttitle>2001: A Space Odyssey</sorttitle>
        <plot>Humanity finds a mysterious object buried beneath the lunar surface and sets off to find its origins with the help of HAL 9000, the world's most advanced super computer.</plot>
        <director>Stanley Kubrick</director>
        <country>United Kingdom</country>
        <country>United States</country>
        <genre>Science fiction</genre>
        <tag>Psychological drama</tag>

Here, I'd like the <userrating> line be written just before </movie>

I work all the database metadata manually with .nfo files created and edited by myself. As you can see, I only include the lines I personally use, otherwise it becomes complicated for me when I go through it (in order to find the individual lines I want to edit), which is why I'd like <top250> and similar not be written at all.

RE: Export <userrating> to .nfo - DaVu - 2019-11-28

If that is what is only in your db, then overwriting your existing nfo with the given user rating should work. I would test that before doing a mass-overwrite. If your complete database was imported by those small nfo files, then there shouldn't be much more in the database itself. Probably something like resumepoints and watched counts, stream details. The general informations (title, year, plot etc) should stay the same by overwriting.

The other tags which might be added (resume points, watched counts and such) won't harm at all.  I can test that if you want in some test envinronment if @Karellen doesn't beat me to it Wink

RE: Export <userrating> to .nfo - firewater - 2019-11-28

My problem then is that exporting .nfo files with Kodi names them not "movie.nfo", but "2001 - A Space Odyssey.nfo", and that it appends the aforementioned empty tags. I can live with the second, but the first complicates my setup.

I'm now looking for to how to create a python script that writes a line (<userrating>NUMBER</userrating>) to the movie.nfo of the selected item. The line can be entirely static, it doesn't have to actually read the userrating because I will call it with different keymaps (keymap 1 will write <userrating>1</userrating>, keymap 2 will write <userrating>2</userrating>, and so on). Hoping someone can guide me here...

edit: rewrote it all

RE: Export <userrating> to .nfo - DaVu - 2019-11-28

ok, if you can't deal with the fact that Kodi uses "<moviename>.nfo" instead of what you want, then I can't help you anymway. Generally I woudn't use "movie.nfo" as I like to know which nfo belongs to which movie by its name. Sure, they are separated in subfolders, but still.

But that's ofc your decision then

RE: Export <userrating> to .nfo - Karellen - 2019-11-28

Maybe this might be of help... https://forum.kodi.tv/showthread.php?tid=349035

Also, don't use <year> as it is depracted. Use <premiered>yyyy-mm-dd</premiered>

RE: Export <userrating> to .nfo - firewater - 2019-12-02

(2019-11-28, 10:38)DaVu Wrote: ok, if you can't deal with the fact that Kodi uses "<moviename>.nfo" instead of what you want, then I can't help you anymway. Generally I woudn't use "movie.nfo" as I like to know which nfo belongs to which movie by its name. Sure, they are separated in subfolders, but still.

But that's ofc your decision then
I prefer movie.nfo as a catch-all term, but it's just a small personal preference. I can live with it, but it's overkill to export my whole library's (100+ videos) nfo every time I rate just one. It actually freezes Kodi for some time after I rate something. And, I'm having trouble actually having the rating stick after I implemented the line <onclick>exportlibrary(video,true,false,true,false)</onclick>, for some reason the rating disappears after being reimported... even though it's there on the nfo. So it feels like I'm dealing with a lot of inconveniences for something that isn't even working for me, which I admit can be entirely my fault. It's just I'm lost on how to do this, I thought there'd be a simple way to just write one line to an .nfo.

I don't know how to quote another, but thanks for the tip on <premiered>, and the recommended addon which seems promising... I'll update here if I can manage it from there.

RE: Export <userrating> to .nfo - Karellen - 2019-12-02

(2019-12-02, 00:42)firewater Wrote: I don't know how to quote another,

RE: Export <userrating> to .nfo - scott967 - 2019-12-03

As far as saving a rating to file, it seems to me better to change the rating in Kodi, then export the library value.  Since you don't want to export the whole library (I often do it when exiting Kodi and at least for 500 movies I don't find it that time consuming), yes you could create a private addon that you could invoke for the current playing movie or current focused item in a movie library list.  The general approach I considered is to get the media path from Kodi and open the movie.nfo file using the Elementree Module features in Python.  If movie.nfo doesn't exist I would maybe just exit with a notification.  If it does exist I would look for existing <userrating> in the file and update it, or add the <userrating> if it doesn't exist, then save the file.  Getting into more details probably need to determine if it is for Leia (Python 2) or Matrix (Python 3).

scott s.

RE: Export <userrating> to .nfo - firewater - 2019-12-03

Thanks for taking the time to think about it. I think the most promising lead, from the addon thread previously mentioned, is that (I believe) the developer is working on a function that would update individual .nfo fields through a command. Could have far greater use than my niche petition... hope it happens.

This forum uses Lukasz Tkacz MyBB addons.