How is the metadata library file system structure laid out
I've been working on an app that cleans up records in the plugins library database that don't seem to go away or are mismatched. Now that I have most of that in working order (to my satisfaction) I thought it would be nice to add a feature to override image data in the bundles in the Metadata folders (albums, artists, movies) of the file system that are occasionally wrong too. I see where the user thumb/art URI references are in the metadata_items table for artists and albums, and can do lengthy file name searches to locate the associations using that data, but that's a HORRIBLE approach. Is there a mapping file or database that I'm just not seeing? Maybe some other piece of code I could reference to understand how they filesystem structure is laid out based on some algorithm? Maybe a web service I can call?
Appreciate any guidance that can be provided.