I have written a plug-in (MythRecordings - see elsewhere on this forum) with an __init__.py file that works fine. Now I want to add a search service - and I've got a lot of code I want to share between the two.
But I cannot figure that out - and I suspect it's because I've structured my directories wrong.
Here's my best shot at a directory tree - the channel (__init__.py) runs, it uses the SharedCodeService to access the shared code (plexmythlib.pys), which can get hold of the shared resource (somedata.json):
+ MythRecordings.bundle
+ Contents
Info.plist
+ Code
__init__.py
+ Services
ServiceInfo.plist
+ Search
+ MythRecordings
ServiceCode.pys
+ Shared Code
plexmythlib.pys
+ Resources
somedata.json
I've registered my services as folllows in ServiceInfo.plist:
<?xml version="1.0" encoding="UTF-8"?>
Search
MythRecordings
Identifier
dk.schaumburg-it.plexapp.mythrecordings
But I cannot get Plex to recognize my search service - looking at the error message, it seems to expect to find that code under
MythRecordings.bundle/Contents/Search Services/MythRecordings/ServiceCode.pys
instead of
MythRecordings.bundle/Contents/Services/Search/MythRecordings/ServiceCode.pys
But if I rename Services/Search => Search Services, my __init__.py cannot find the shared code anymore. And if I just move the ServiceCode.pys to the expected location, and leave the shared code where it is, the ServiceCode.pys cannot find the shared code in plexmythlib.pys.
Whenever I move things around, one thing starts working, and another stops.
Gaaarh - I'm confused!
Edit:
Specifically, if I try to load the shared code as follows (from the ServiceCode.pys):
GetMythTVRecordings = SharedCodeService.plexmythlib.GetMythTVRecordings
def Search(query):
oc = ObjectContainer(title1=‘Myth Search service results – Contents/Services/Search/MythRecordings/ServiceCode.pys’, title2=‘Search Results’)
return oc
I get
FrameworkException: ('No shared code object named "%s" was found.', 'plexmythlib')