Closed jojobrogess closed 3 years ago
nvm got it. But thank god you stole a little bit of your own code and kept updating it for xbmcbackup
Glad you found what you were looking for. The Backup addon is way more up to date since it's actually in the Kodi repo. I had a feeling the encode()
function was no longer needed in Python3 but looks like that line confirms it.
P.S. If you get it working on Matrix please send over a PR and I'll merge it in!
If I can do it, it'll probably take me a while.
Which is a good thing for me because in doing this I hope to be able to learn how to create an addon for myself. But the learning curve on this is a little more than what I expected, especially considering I don't know how to code python. Just can read it, slightly.
As far as I can tell, this code looks like it's from Frodo/Gotham days. Kodi 12 and 13 respectively. I thought it was at least Jarvis(16), Krypton(17), or Leia(18).
There's been a considerable amount of changes since then and like I stated above, I have no idea what I'm doing lol. but I did just update the strings to the new localized standard, but that's an easy task comparatively.
As of right now, I can't get any of the functions to work correctly: Add element/child element, change value, delete, or rename. As well as some hierarchical problems, the videolibrary art type section displays the correct amount of file types but they all display as "landscape" instead of their individual types.
I suspect it has something do with key changes to how Kodi now operates, plus old function calling. But since this is made for such an old version of kodi, I think updating it is going to be a little slow for me.
If you can help me out by telling me a few things about the addon, that would be great! Like what do minidom and expaterror do in correlation to script? Can you remember any major changes that have happened over the years in Kodi that you are pretty sure you never made to this code? Like eg: the Kodi getString function is depeciated people use the $LOCALIZE process now or this functions name is now this.
Literally any piece of information could help, atm I'm stabbing in the dark lol I don't know python, I'm new to kodi, and I can barely code lol And google is yelling at me to enter captcha's ever 30 minutes because of all the nonsense I'm searching up.
I think you're right - this hasn't been touched in a while. Prior to the Kodi migration to Python3 that probably wasn't too much of an issue but I can imagine it's not running quite right anymore. The good news is that the format of the advanced settings file hasn't seemed to have really changed over the years so that's a plus!
I took a quick pass through the code again so hopefully I can answer some of your questions. The minidom import is the Python library that actually parses the advancedsettings.xml
file and reads, adds, or removes the information there. By default the GUI portion of the program just pulls in the top level xml nodes and displays them. Clicking a node will bring you in to that node tree, or display the text value if it's just a single tag. If you compare your advancedsettings.xml
file to what is being read in you can visualize how it's parsing the tree.
That being said, I'm sure some settings display a bit odd. It's because this addon is generic enough that it doesn't care what the actual format of the file looks like, it just reads the file. The video extensions node you mentioned is a good example. This could be filled with tons of extensions and they will just be displayed as one big string value since they're part of the same xml node. You could add some logic to use a line break after each |
character in situations like that; but it's more a consequence of how the file is structured.
A few places that might help:
The Cron For Kodi addon has been updated for Matrix. This has more up to date UI code and might help in that area.
Kodi Python Docs - I'm sure stuff like the xbmcgui.Dialog()
calls have changed, these will be located here
Any errors or specific things feel free to reach out.
Alright I'm making headway. But I'm having a problem with the write function. I've been trying to isolate the issue by deleting my advancedsettings.xml file, so I can start over and try to see what's going on.
This is the function:
def _writeFile(self): file = xbmcvfs.File(self.as_file,'w') file.write(str(self.doc.toxml())) file.close()
And it outputs <?xml version="1.0" ?><advancedsettings/>
in the first line of the file.
I've been able to remove it by adding:
def _writeFile(self): file = xbmcvfs.File(self.as_file,'w') file.write(str(self.doc.toxml().replace('<?xml version="1.0" ?>
', ' \n '))) file.close()
It seems to stop it from adding that line when the file is created, but with every write after it re-adds <?xml version="1.0" ?>
to front of the file.
And I have no idea why. I suspect it has to do with the formatting of these two lines:
file = xbmcvfs.File(self.as_file,'w') file.write(str(self.doc.toxml()))
Also it seems that the write function writes linearly(flattens the directory to one line). but I'm not 100% sure that even matters, since the user can't see it and I assume as long as the elements are in the correct placement, like within the <advancedsettings>
</advancedsettings>
tags and it's corresponding tags it shoudn't matter about how it looks just that it works correctly, but with the icon.png you supplied I assume that's how it saves them.
BUT since I've never ran this while it was working correctly, I don't know. Did this used to save things in advanced settings like this:
or
Cuz if it did........ I also don't know why that's happening. lol
I've been using the Kodi Documemtation Library website you supplied, which has been an absolute help and a complete cheat sheet when it comes to updating calling things within Kodi. Seriously thank you for that one!
I also have xbmcbackup and cronxbmc github pages bookmarked so I can sift through all of your commits, and see what and how you've changed the code over the years.
But a couple of these things are little too out of my element, or maybe I just haven't caught it yet. If you could shed some light on this, it would help out a lot!
I'm also pretty sure everything should function correctly after the write function gets fixed.
This was my momentary solution to having the value of the node on the element's name, just so it's easier to read:
but it displays it everywhere:
I was thinking of cleaning it up with something like," elementname
's value = value
" which might look better than my crude solution. And maybe on the other " elenmentname
's tree
" or something similar.
Doing it this way does burn the select to view value feature, but that could be changed to select to change value. Probably would also want to remove it from context menu, since the default selection method for elements without a child would then be to "change value" so it wouldn't be needed, but that doesn't really matter necessarily.
Since this is your script and I do want to submit an updated Matrix PR for this, I thought I'd get your suggestions. What do you think would look/work best?
Nice work, glad those resources are useful. I like the changes of adding setting = value
for the ones that aren't the start of a tree of values. Just makes it easier to read. I agree clicking on the value should then either bring up the context menu or just go straight to changing the value. No reason for an additional screen. I kind of like how you have it in the second picture the best. If something has a folder icon and no =
then it's pretty easy to tell it's the start of a tree. Since modifying this file is kind of an advanced thing anyway these visual queues should be enough in my opinion.
Regarding the XML declaration statement (<?xml version ....
) is Kodi not reading the file correctly if this exists? Having that top line to declare that this is an XML file type is part of the document standard; however I know some parsers (written incorrectly I suspect) will throw a fit if it's there. Your solution to remove it works if you have to but it probably shouldn't cause any harm to be there. I did run across a method in the Minidom documentation called toprettyxml()
that will write out the file with the correct newlines and indents. My guess is that I never went this far with it but it does add some viewability for users (or you when testing!). You could even add a setting for the addon to toggle "pretty" xml vs just the one line output. That's probably going a bit overboard but people like options!
Based on the comments sounds like it's going pretty good so far. Looking forward to seeing the end result.
I found this today when trying to research how to create my own addon to edit a fan config file. I can't seem to find any information on how to do that, so I figured the best bet was to find an addon as close as to what I'm trying to accomplish and mess around with it to see how it works.
Thankfully I came across this because it's extremely close to the addon that I'm trying to create. But sadly this doesn't work for the latest version of Kodi(v19 matrix) so I've been trying to port it over.
When doing that, I ran into this error:
From the information I can gather it looks like it's sending the wrong type of information? It's expecting character(s) and it's getting sent number(s)?
As you can see, I don't know what I'm doing or how this exactly operates, yet. Can you help me understand this better? Or point me anywhere I can get a better grasp on this whole process.
I forked your repo and you can check out the changes I've made here, but they were all basic changes just to get it to install: https://github.com/jojobrogess/script.advanced.settings.editor