Export <userrating> to .nfo
#1
How can I export the
<userrating>
that I create with 
<r>RunScript("script.user.rating")</r>
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.
Reply
#2
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.
My Signature
Links to : Forum rules (wiki) | Banned_Add-ons (wiki) | Debug Log (wiki)  
Links to : HOW-TO:Create_Music_Library (wiki) | HOW-TO:Create_Video_Library (wiki)  ||  Artwork (wiki) | Basic controls (wiki) | Import-export library (wiki) | Movie sets (wiki) | Movie universe (wiki) | NFO files (wiki) | Quick start guide (wiki)
Reply
#3
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.
Reply
#4
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" ?>
    <movie>
        <originaltitle></originaltitle>
        <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>
        <year>1968</year>
        <country>United Kingdom</country>
        <country>United States</country>
        <genre>Science fiction</genre>
        <tag>Psychological drama</tag>
    </movie>

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.
Reply
#5
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
Reply
#6
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
Reply
#7
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
Reply
#8
Maybe this might be of help... 349035 (thread)

Also, don't use <year> as it is depracted. Use <premiered>yyyy-mm-dd</premiered>
My Signature
Links to : Forum rules (wiki) | Banned_Add-ons (wiki) | Debug Log (wiki)  
Links to : HOW-TO:Create_Music_Library (wiki) | HOW-TO:Create_Video_Library (wiki)  ||  Artwork (wiki) | Basic controls (wiki) | Import-export library (wiki) | Movie sets (wiki) | Movie universe (wiki) | NFO files (wiki) | Quick start guide (wiki)
Reply
#9
(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.
Reply
#10
(2019-12-02, 00:42)firewater Wrote: I don't know how to quote another,
Image
My Signature
Links to : Forum rules (wiki) | Banned_Add-ons (wiki) | Debug Log (wiki)  
Links to : HOW-TO:Create_Music_Library (wiki) | HOW-TO:Create_Video_Library (wiki)  ||  Artwork (wiki) | Basic controls (wiki) | Import-export library (wiki) | Movie sets (wiki) | Movie universe (wiki) | NFO files (wiki) | Quick start guide (wiki)
Reply
#11
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.
.
maintainer of skin  Aeon MQ5 mods for post-Gotham Kodi releases:
Krypton
Leia
Reply
#12
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.
Reply
 
Thread Rating:
  • 0 Vote(s) - 0 Average



Logout Mark Read Team Forum Stats Members Help
Export <userrating> to .nfo00