Kodi Community Forum

Full Version: [AppleTV4] Skin won't show my manually copied custom nodes?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Note: no debug log available, I've tried to use the log uploader but the url the uploader is linking to is just an empty page.

I'm trying to add custom nodes to Kodi 17.6 running on AppleTV but the Aeon Nox 6.1.0 skin won't show them. 

I have a manually created a set of custom nodes (both parent and root nodes) that work perfectly when running Kodi on OSX using the same Kodi and skin version. I've tried to copy them to the AppleTV by copying them to "/userdata/library/video" using the file manager.

The files are copied and if I browse to Videos in Kodi all my custom nodes are listed as they should. But when I try to setup the home window main menu and set the select action on a menu item my custom nodes are not listed in "Select action > Video Library >" so I can't link to them. On OSX all my custom nodes are listed there but not on the AppleTV. Also, on the AppleTV, the custom nodes that are created through the Library Node Editor are visible and selectable, it's just my copied nodes that doesn't show.

There is no difference in folder structure or format between the custom nodes that are added using the Library Node Editor and the ones that I copy to the AppleTV using the file manager and they are both placed in "/userdata/library/video".

I even tried to create a node using the Library Node Editor (that is visible), copied it, changed its name, and then copied it back using the file manager and it didn't show either. So it's definitely something different between nodes that are copied vs. nodes that are created through the editor.


So what could be the issue? Why isn't the skin picking up my manually copied custom nodes when it can see the nodes created using the Library Node Editor?


If I try to replace a node XML file I've created using the Library Node Editor with an edited one, the file is not replaced. Instead the file manager will show two copies of the XML file, the one I've edited and the one from the Library Node Editor. So it doesn't look like they have the same location in the AppleTV file system even if the Kodi file manager list them in the same folder.
Try looking in
/private/var/mobile/Library/Preferences/Kodi/temp/
or
/Users/<your_user_name>/Library/Application Support/temp/
folder, you may find the kodi.log there and upload it manually.

I'm not sure what the exact folder structure is on a ATV4.
I managed to upload the kodi.log using the uploader today: http://paste.kodi.tv/azefudefam

In the log above I tried to copy the node "barn/index.html" using the file manager. 

Haven't made any real progress or discovered anything new. I will probably just rebuild all the nodes using the Library Node Editor even if it will take me a while, or I'll see if I can update the nodes in the app container and replace it using Xcode.


But this is what I've discovered so far:

- When the app container is copied using Xcode, AppData/Library/Caches/home/userdata/library/ contains all the copied parent node folders and the nodes folders created using Library Node Editor. But only the ones created using the Library Node Editor contain XML files. The folders for the copied nodes are there but are empty. 

- When I open the "select action" dialog for the skin Kodi prints this for each parent node that I've copied in the log:
Code:
ERROR: IOError: [Errno 2] No such file or directory: '/var/mobile/Containers/Data/Application/9802A947-B04E-42FA-9FE1-2C6894C57F14/Library/Caches/home/userdata/library/video/[node name]/index.xml'
- When I copy a node using the file manager Kodi prints this in the log: 
Code:
DEBUG: CSMBFile::Open - opened smb://[network path]/library/video/[node name]/index.xml, fd=10000
DEBUG: NSUSerDefaults: compressed /userdata/library/video/[node name]/index.xml from 117 to 126
DEBUG: CSMBFile::Close closing fd 10000

If I remember correctly it's been stated before that the NSUserDefaults is used to store userdata files on the AppleTV but I don't remember the details. But if this is the case, perhaps the problem is that the file manager just copies the files to the NSUserDefaults, but the files are never copied to the actual /userdata/library/ folder where the skin settings expect them to be when loading the "select action" dialog?
All xml files are stored in nsuserdefaults because this is the only permanent storage on the appletv. It’s size is limited to 500kb per app. That’s why we only Store xml files there (because those might be mission critical settings).

I guess the problems you have are related to that fact. Kodi and the internal file manager handle those nsuserdefaults with no problem. But in your case it might be that some other instance (an addon?) reads those XMLs and has no idea about nsuserdefaults and also doesn’t make use of Kodis VFS (which would handle nsuserdefaults without the addon knowing).
Thanks for pointing me in the right direction. 

Python is really out of my domain, but after some trial-and-error I was able to correct the faulty add-on. It was the Skin Shortcuts add-on that populated the skin's select action dialogue. As suggested, it was trying to read/parse the XMLs using filesystem paths directly. I replaced the reading of files so it read the files through xbmcvfs and now all the nodes I copy through the file manager show up.
Wow great work. You could inform the author of that addon about that. There might be other reasons using the kodi vfs is better then direct access (reasons that are not predictable like the tvOS one here Wink )
Hi,

I have the same issue.
Could you please explain us which part of the code you modified to make this work?

Thanks
(2019-12-29, 12:05)Ravens28 Wrote: [ -> ]Hi,

I have the same issue.
Could you please explain us which part of the code you modified to make this work?

Thanks

I did a quick compare and I made changes to xmlfunctions.pydatafunctions.pynodefunctions.pynodefunctions.pylibrary.py.

I basically replaced all the places in the addon-n where an xml is to either parsed or written to. Looks like it's at 5-20 different locations in each file above or something like that. I think I you did a search for .parse and .write to find all the places that needed updating.

Examples:

xmlfunctions.py, line 177, parsing file:
python:
addon = xmltree.parse( addonpath )
replaced with:
python:
f = xbmcvfs.File(addonpath)
xmlString = f.read()
f.close()
addon = xmltree.ElementTree(xmltree.fromstring(xmlString)


xmlfunctions.py, line 680, writing file:
python:
tree.write( path, encoding="UTF-8" )
replaced with:
python:
writefile = xbmcvfs.File( path , 'w' )
writefile.write( xmltree.tostring(tree.getroot(), encoding='UTF-8', method='xml') )
writefile.close()
I did a fork on mikesilvo164's python3 fork and added the VFS parts, I haven't been able to test it fully so not sure if all cases are working. But perhaps it's still useful for someone to download or look at. So this fork in the branch 'python_3_vfs' contains python3 with added VFS.

https://github.com/mwhrtin/script.skinsh...thon_3_vfs