Trying to create a channel, but don’t understand why all functions are called twice. I don’t understand why it’s happening.
Simple Plugin just to demonstrate
def Start():
Log("== Start ==")
HTTP.CacheTime = 0
HTTP.Headers['User-agent']="Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:55.0) Gecko/20100101 Firefox/55.0"
ObjectContainer.title1 = TITLE
ObjectContainer.art = R(ART)
DirectoryObject.thumb = R(ICON)
DirectoryObject.art = R(ART)
EpisodeObject.thumb = R(ICON)
EpisodeObject.art = R(ART)
VideoClipObject.thumb = R(ICON)
VideoClipObject.art = R(ART)
@handler(PREFIX, TITLE, art=ART, thumb=ICON)
def MainMenu():
Log("== Main Menu ==")
randomNumber = str(random.random())
Log(randomNumber)
oc = ObjectContainer()
oc.add(DirectoryObject(key=Callback(SubLevel, title=randomNumber), title=randomNumber))
return oc
def SubLevel(title):
Log("== SubLevel (%s) ==" %title)
return ObjectContainer(header="Empty", message=title)
I’m using an android phone to browse the channel and I see this in the logs. I open the channel and click the item.
2018-03-03 09:00:34,865 (8b4) : INFO (logkit:16) - == Main Menu ==
2018-03-03 09:00:34,865 (8b4) : INFO (logkit:16) - 0.48122084455
2018-03-03 09:00:34,865 (8b4) : WARNING (runtime:1065) - Generating a callback path for a function with no route: <function SubLevel at 0x057B6A30>
2018-03-03 09:00:34,867 (8b4) : DEBUG (base:117) - Checking if com.plexapp.plugins.xmtest is broken
2018-03-03 09:00:34,868 (8b4) : DEBUG (networking:166) - Requesting 'http://127.0.0.1:32400/:/plugins/com.plexapp.system/messaging/function/X1N0b3JlU2VydmljZTpJc0NoYW5uZWxCcm9rZW4_/Y2VyZWFsMQoxCmxpc3QKMApyMAo_/Y2VyZWFsMQoxCmRpY3QKMQpzMjYKY29tLnBsZXhhcHAucGx1Z2lucy54bXRlc3RzMTAKaWRlbnRpZmllcnIwCg__'
2018-03-03 09:00:34,892 (8b4) : DEBUG (runtime:88) - Sending packed state data (107 bytes)
2018-03-03 09:00:34,892 (8b4) : DEBUG (runtime:924) - Response: [200] MediaContainer, 609 bytes
2018-03-03 09:00:35,365 (81c) : DEBUG (runtime:717) - Handling request GET /video/xmtest
2018-03-03 09:00:35,371 (81c) : DEBUG (runtime:49) - Received packed state data (80 bytes)
2018-03-03 09:00:35,374 (81c) : DEBUG (runtime:814) - Found route matching /video/xmtest
2018-03-03 09:00:35,375 (81c) : INFO (logkit:16) - == Main Menu ==
2018-03-03 09:00:35,377 (81c) : INFO (logkit:16) - 0.682650233191
2018-03-03 09:00:35,378 (81c) : WARNING (runtime:1065) - Generating a callback path for a function with no route: <function SubLevel at 0x057B6A30>
2018-03-03 09:00:35,378 (81c) : DEBUG (base:117) - Checking if com.plexapp.plugins.xmtest is broken
2018-03-03 09:00:35,381 (81c) : DEBUG (networking:166) - Requesting 'http://127.0.0.1:32400/:/plugins/com.plexapp.system/messaging/function/X1N0b3JlU2VydmljZTpJc0NoYW5uZWxCcm9rZW4_/Y2VyZWFsMQoxCmxpc3QKMApyMAo_/Y2VyZWFsMQoxCmRpY3QKMQpzMjYKY29tLnBsZXhhcHAucGx1Z2lucy54bXRlc3RzMTAKaWRlbnRpZmllcnIwCg__'
2018-03-03 09:00:35,407 (81c) : DEBUG (runtime:88) - Sending packed state data (107 bytes)
2018-03-03 09:00:35,408 (81c) : DEBUG (runtime:924) - Response: [200] MediaContainer, 614 bytes
2018-03-03 09:01:18,052 (392c) : DEBUG (runtime:717) - Handling request GET /video/xmtest/:/function/SubLevel?function_args=Y2VyZWFsMQoxCmRpY3QKMQpzMTQKMC42ODI2NTAyMzMxOTFzNQp0aXRsZXIwCg__
2018-03-03 09:01:18,052 (392c) : DEBUG (runtime:49) - Received packed state data (80 bytes)
2018-03-03 09:01:18,066 (392c) : DEBUG (runtime:814) - Found route matching /video/xmtest/:/function/SubLevel
2018-03-03 09:01:18,068 (392c) : DEBUG (runtime:125) - Calling function 'SubLevel'
2018-03-03 09:01:18,068 (392c) : INFO (logkit:16) - == SubLevel (0.682650233191) ==
2018-03-03 09:01:18,069 (392c) : DEBUG (runtime:88) - Sending packed state data (107 bytes)
2018-03-03 09:01:18,069 (392c) : DEBUG (runtime:924) - Response: [200] MediaContainer, 311 bytes
2018-03-03 09:01:18,174 (35b8) : DEBUG (runtime:717) - Handling request GET /video/xmtest/:/function/SubLevel?function_args=Y2VyZWFsMQoxCmRpY3QKMQpzMTQKMC42ODI2NTAyMzMxOTFzNQp0aXRsZXIwCg__
2018-03-03 09:01:18,178 (35b8) : DEBUG (runtime:49) - Received packed state data (80 bytes)
2018-03-03 09:01:18,181 (35b8) : DEBUG (runtime:814) - Found route matching /video/xmtest/:/function/SubLevel
2018-03-03 09:01:18,183 (35b8) : DEBUG (runtime:125) - Calling function 'SubLevel'
2018-03-03 09:01:18,184 (35b8) : INFO (logkit:16) - == SubLevel (0.682650233191) ==
2018-03-03 09:01:18,190 (35b8) : DEBUG (runtime:88) - Sending packed state data (107 bytes)
2018-03-03 09:01:18,190 (35b8) : DEBUG (runtime:924) - Response: [200] MediaContainer, 311 bytes
You can see the main menu was called twice and then sublevel was called twice. I have a random number generator in the main menu just to prove it is actually being called twice and not just double up in the logs. The android client displayed the 2nd random number (0.682650233191) and not the first.