• 1
  • 10
  • 11
  • 12
  • 13
  • 14(current)
Beta Metadata Editor - Update library + .nfo informations
Hello.
There is a bug in the way Metadata Editor writes the .nfo files.
In the XML declaration line, the encoding shows

Code:
<?xml version='1.0' encoding='UTF8'?>

This is not quite correct. The proper encoding should be 'UTF-8'. If the encoding is UTF8 without the dash, when using python ElementTree.Parse(filename) and the file actually contains non-ascii unicode characters, the Parse() method will error with 

"not well-formed (invalid token): line x, column y"

This encoding error is documented in footnote 1 at the bottom of the page:    https://docs.python.org/3/library/xml.etree.elementtree.html

The fix is a one liner, but may also be problematic. It uses syntax only available in Python 3.8+. I know it will work for Kodi Nexus 20.x but not sure for previous versions.

In the file "script.metadata.editor\resources\lib\nfo_updater.py" in method "write_file()" change the line (currently line 111):

Code:
content = ET.tostring(self.root, encoding='UTF8', method='xml').decode()

to:
Code:
content = ET.tostring(self.root, encoding='UTF-8', method='xml', xml_declaration = True).decode("UTF-8")

So why is xml_declaration required? Because if you just change the encoding to UTF-8, the xml declaration line is not written to the output .nfo. This is due to a "feature" of the default Python XML processor that will not write an XML declaration line if the encoding is ascii or unicode. And if the XML declaration line is not written, ET.Parse(file) assumes ascii (or maybe system default codepage)

This has another possible fix, but xbmvfs.File() would have to be enhanced to accept an encoding= parameter (e.g. xbmcvfs.File(filename,'w',encoding="UTF-8")). The current file encoding I think is system (I am en-US and it shows OEM-US as the file encoding for the .nfo output files)

Sorry for the long winded explanation, but hope this can be fixed.

Thank you!
Reply
Hi At2010,
Thank you very much for all the info, before I make the change and test, I have a couple questions.
I am not a coder so I am not sure what is meant by
in method "write_file()" in your description.

I am on OSX and can change the lines in the code via text edit or directly in path finder as well.
I just want to be sure I am not missing something by overlooking in method "write_file()" in your description:
In the file "script.metadata.editor\resources\lib\nfo_updater.py" in method "write_file()" change the line (currently line 111):

In file nfo_updater.py
Around line 111, I see the following:

        if PYTHON3:
            content = ET.tostring(self.root).decode()
        else:
            content = ET.tostring(self.root, encoding='UTF-8', method='xml')


Your instructions has the word .decode()  at the end of the line... I do not see it.
content = ET.tostring(self.root, encoding='UTF8', method='xml').decode()
my line just reads:
content = ET.tostring(self.root, encoding='UTF8', method='xml')

So, just to double check, should I replace line..

content = ET.tostring(self.root, encoding='UTF-8', method='xml')
with new line:
content = ET.tostring(self.root, encoding='UTF-8', method='xml', xml_declaration = True).decode("UTF-8")

Thanks again for your time and I look forward to trying it out.
Reply
BTW... I would just update to kodi 20+ but I can not because my TV box is using the TV version of Android 11.
With this version I am unable to install addons within kodi 20+ .. I can only update if I use kodi 18.9 or lower.

At this time I dont know of any way around this.
Thanks again..
Reply
@acevideo
You're looking in the right place, and in your case, the line is correct. So if the .nfo files it creates are proper for you, then there's nothing to fix. If the XML declaration line is missing, and you need it, then you could update the code to:

Code:
        if PYTHON3:
            content = ET.tostring(self.root).decode()
        else:
            content = ET.tostring(self.root, encoding='UTF-8', method='xml')
            if not content.startswith(r'<?xml'):
                  content = '<?xml version="1.0" encoding="UTF-8" ?>\n' + content
* Note the above code should only be used for Kodi Leia 18.x using python 2.x

@all
My original post will only work for Kodi Nexus 20.x but the following code will work for both Kodi Matrix 19.x and Nexus. Substitute the 1 line for these 3:

Code:
       content = ET.tostring(self.root, encoding='UTF-8', method='xml').decode()
       if not content.startswith(r'<?xml'):
            content = '<?xml version="1.0" encoding="UTF-8" ?>\n' + content

Regards,
at2010
Reply
If I could just add a quick request also, Can you put in a "Save .nfo and exit" option in the Metadata editor menu.
At this point, Once you load Metadata editor and then select edit data. You can change everything fine, then you have to rsc to exit the editor, load metadata editor back up and select update .nfo
A menu selection when you have finished making changes to update nfo and exit would be so much simpler and less Hassell.
Thanks for listening.
Oz
Reply
I've no idea how I missed this addon for all these years but now I've found it, I have a question.

I'm not a huge fan of NFO files, unless I'm doing an export for the purposes of a full library rebuild, so I disabled the option to create/update NFOs, added my Patreon Omdb API key and set it off updating some movie ratings.  It works great, and I see the Rotten Tomatoes ratings and so on appearing in Kodi clients for movies the addon has touched.  What I can't work out is where this info is stored with the NFO option disabled.  I use a central MySQL database and as RT ratings are showing up on other clients, I can only assume it's written them to the MySQL db somewhere but having looked at every table and searched the db, I can't work out where.

So where does this addon write the ratings info to when NFO generation/updating is disabled?
Reply
(2023-11-14, 13:27)acevideo Wrote: BTW... I would just update to kodi 20+ but I can not because my TV box is using the TV version of Android 11.
With this version I am unable to install addons within kodi 20+ .. I can only update if I use kodi 18.9 or lower.

At this time I dont know of any way around this.
Thanks again..

I have a TV with Android 7 and even there I can update... I recommend installing the Programm Add-on "Kodi Android Installer" and update Kodi from there. Please don't reply to this as it doesn't have anything to do with the Metadata Editor.
Reply
Like Universal Movie Scraper, Metadata Editor does not download and update Rotten Tomatoes and Mc ratings.
Can we expect any fix?
Reply
Quick question - how is the create NFO process actually triggered in scenarios where it is missing? I have noticed NFOs created for episodes that I’ve watched, but it doesn’t seem to operate for new additions to the library that I’ve not yet watched. Do I need to watch each episode for the NFO creation process to be triggered, or is there another way?
Reply
(2024-01-08, 17:42)LadyBananas Wrote: Quick question - how is the create NFO process actually triggered in scenarios where it is missing? I have noticed NFOs created for episodes that I’ve watched, but it doesn’t seem to operate for new additions to the library that I’ve not yet watched. Do I need to watch each episode for the NFO creation process to be triggered, or is there another way?

To create the missing .nfo's you can do a Library Backup.
Settings > Media > Export Library
Backup to separate files. Follow the prompts and Kodi will save each TV, Movie, MTV etc's data to an .nfo file, plus backup all your artwork etc.
Hope that helps.
OZ
Reply
Ok but that’s a separate process to metadata editor, yes? What does the setting in metadata editor to “create NFO if missing” actually change? The backup process creates new NFOs for every single item in my library, including overwriting old ones. I have my entire library backed up to a second server, and new NFOs for every item means thousands of NFOS to sync. I just want new ones created where they don’t already exist.
Reply
(2024-01-09, 04:01)LadyBananas Wrote: Ok but that’s a separate process to metadata editor, yes? What does the setting in metadata editor to “create NFO if missing” actually change? The backup process creates new NFOs for every single item in my library, including overwriting old ones. I have my entire library backed up to a second server, and new NFOs for every item means thousands of NFOS to sync. I just want new ones created where they don’t already exist.
It certainly is separate to the Metadata editor, and I'm not sure on the create .nfo if missing, I would guess if you went to, say a movie, with no .nfo and tried to edit metadata it would create the .nfo if missing.

The Backup process will only create what it needs to if you select Do not overwrite existing data, when you run the backup. Then when the backup spots an .nfo already in the folder it moves on to the next movie. So it should do exactly as you want.

Cheers

Oz
Reply
  • 1
  • 10
  • 11
  • 12
  • 13
  • 14(current)

Logout Mark Read Team Forum Stats Members Help
Metadata Editor - Update library + .nfo informations0