DefaultPrefs.json loading and preferences modification

Hello all,

I have a question as now when I try to add preferences to a plugin I develop, I have a window with all the preferences of the server but not the plugin preferences.

Hower, I do not get any error in the log, see below:

2014-03-26 07:59:07,180 (f64) :  DEBUG (preferences:256) - Loaded preferences from DefaultPrefs.json
2014-03-26 07:59:07,181 (f64) :  DEBUG (preferences:178) - Loaded the user preferences for com.plexapp.plugins.xkcd

and on the server log:

Mar 26, 2014 07:59:07:174 [6732] DEBUG - Read configuration for [com.plexapp.plugins.xkcd], had 1 prefixes
Mar 26, 2014 07:59:07:175 [6732] DEBUG - [com.plexapp.plugins.xkcd] Sending command over HTTP (GET): /photos/xkcd
Mar 26, 2014 07:59:07:175 [6732] DEBUG - HTTP requesting to: http://127.0.0.1:49992/photos/xkcd

Any idea? Stupid mistake I would have made? Bad Spirit hauting my server?

What app are you using for testing your plugin?

To confirm whether the preferences are being read/loaded properly, you can check the XML directly by hitting:

http://localhost:32400/plugins/com.plexapp.plugins.xkcd/prefs

What app are you using for testing your plugin?

To confirm whether the preferences are being read/loaded properly, you can check the XML directly by hitting:

http://localhost:32400/plugins/com.plexapp.plugins.xkcd/prefs

I naively didn't use any app, expecting the server to put a warning if the code was calling a non existing prefs file. Seems I was wrong.

I get a 404 error attempting to get it using your method so for the server it is not accessible...

Now a good question is why?

Ok, a first answer is that it was encoded using UTF-8 without BOM. I changed it to ASCII and added a comma at the end, then it worked using http://127.0.0.1:32400/:/plugins/com.plexapp.plugins.xkcd/prefs!

I reverted back to UTF-8 and removed the comma, it still works... Oooooook! No problem!

However, I still have an issue with preferences which can't be modified using plexweb.

Bonus question: can you use localised text in preferences? (I would think it is possible but)

However, I still have an issue with preferences which can't be modified using plexweb.

Rephrase Q please.

Do you mean from the Prefs object, or if from code, look here:

https://forums.plex.tv/topic/87348-undocumented-functionality-and-tips-tricks/

/T

Rephrase Q please.

Do you mean from the Prefs object, or if from code, look here:

https://forums.plex.tv/topic/87348-undocumented-functionality-and-tips-tricks/

/T

Thanks, for the link, I really like the Reset option as I thought about how to implement this at some point ^_^.

Reformulation: I click on the button to modify prefs (see image 1) and I get this (see image 2)

They are in French, but this is totally not the prefs I was looking for.

Locate the following

/Cache, and delete the directory with the plug-in name in Q

Same for :

/Data

and then delete the .xml file in /Preferences

Then restart your PMS

With above deletions, it'll be like a new born baby, and completely reset

If above doesn't help, then post the DefaultPrefs.json from the plug-in

/T

No change, attached the DefaultPrefs.json

Hmm....Looks okay. Is this the only channel that is buggy?

/T

Not sure as I use this server only for development. I will have a look tomorrow. Thanks for the help and the tips


Envoyé de mon GT-N8010 en utilisant Tapatalk

Ok, I checked with You Tube plugin, no problem.

I really have a problem with Plex and its error management.

I will try to dig a little bit more into this. Any idea welcome!

Does your plugin code include a PrefsObject() in the MainMenu?

There was one, this may be the problem.

However, I removed every use of prefs in the plugin and I still have a problem.

What is puzzling me is that the plugin is in fact launching the main menu even when I just call preferences.

By this, I mean that I see in the log the function calls indicating the main menu is proceeding even if I see nothing.

The only think I can suspect is that I get a timeout somewhere as the main menu is long to lad the first time due to necessary caching.

I don't know if you can specify a timeout for a function call or something like this to tell plex to wait...

However, i still don't understand why the main menu would be called when you want to change the preferences.

There was one, this may be the problem.

However, I removed every use of prefs in the plugin and I still have a problem.

What is puzzling me is that the plugin is in fact launching the main menu even when I just call preferences.

By this, I mean that I see in the log the function calls indicating the main menu is proceeding even if I see nothing.

The only think I can suspect is that I get a timeout somewhere as the main menu is long to lad the first time due to necessary caching.

I don't know if you can specify a timeout for a function call or something like this to tell plex to wait...

However, i still don't understand why the main menu would be called when you want to change the preferences.

Think it's time to post a link to github for the complete code :rolleyes:

/T

Ah sorry, here you can find the link to the branch with the modifications: https://github.com/sengian/xkcd.bundle/tree/Prefs

Master is working but I don't have prefs..

Ah sorry, here you can find the link to the branch with the modifications: https://github.com/sengian/xkcd.bundle/tree/Prefs
Master is working but I don't have prefs..

On a quick review I see two issues. First and likely not the cause if your issues, your trying to assign your own viewtypes. That behaviour is no longer supported and most client apps will just ignore what you set anyway.
Second and possibly (although still unlikely to be) the cause of the problem, you're making a call to the Prefs in the ObjectContainer definition for the MainMenu. I don't _think_ that is supported although I'm not 100% sure. Since it's for the purpose of setting the view-type, I would ditch that (as mentioned above) and see if it solves your problem.

On a quick review I see two issues. First and likely not the cause if your issues, your trying to assign your own viewtypes. That behaviour is no longer supported and most client apps will just ignore what you set anyway.

Ok for trial purposes I ditched everything linked to plugin view ie:

    Plugin.AddViewGroup("InfoList", viewMode="InfoList", mediaType="items")
    Plugin.AddViewGroup("List", viewMode="List", mediaType="items")
    Plugin.AddViewGroup("Pictures", viewMode="Pictures", mediaType="photos")
ObjectContainer.view_group = "List"
Second and possibly (although still unlikely to be) the cause of the problem, you're making a call to the Prefs in the ObjectContainer definition for the MainMenu. I don't _think_ that is supported although I'm not 100% sure. Since it's for the purpose of setting the view-type, I would ditch that (as mentioned above) and see if it solves your problem.

I also removed in ObjectContainer the call to Prefs and the view. I just then call Prefs to assign it to a variable, then I clear cache.

And still the same issue... :angry:

If someone knows it, I would like to know what should be the Prefs file encoding, as it seems I had problems with that (converting to ASCII solved it but still).

Ok for trial purposes I ditched everything linked to plugin view ie:

    Plugin.AddViewGroup("InfoList", viewMode="InfoList", mediaType="items")
    Plugin.AddViewGroup("List", viewMode="List", mediaType="items")
    Plugin.AddViewGroup("Pictures", viewMode="Pictures", mediaType="photos")
ObjectContainer.view_group = "List"

I also removed in ObjectContainer the call to Prefs and the view. I just then call Prefs to assign it to a variable, then I clear cache.

And still the same issue... :angry:

If someone knows it, I would like to know what should be the Prefs file encoding, as it seems I had problems with that (converting to ASCII solved it but still).

I believe UTF-8 is the most common. I'm pretty stumped here...

you might try removing the extra lines between the pref definitions.

[
    {
        "id": "vmodemenu",
        "type": "enum",
        "label": "Main menu view mode",
        "values": ["InfoList", "List"],
        "default": "List"
    },
    {
        "id": "vmodeyear",
        "type": "enum",
        "label": "Year submenu view mode",
        "values": ["InfoList", "List"],
        "default": "List"
    },
    {
        "id": "vmodemonth",
        "type": "enum",
        "label": "Month submenu view mode",
        "values": ["InfoList", "List", "Pictures"],
        "default": "Pictures"
    }
]

rather than

[
    {
        "id": "vmodemenu",
        "type": "enum",
        "label": "Main menu view mode",
        "values": ["InfoList", "List"],
        "default": "List"
    },
{
    "id": "vmodeyear",
    "type": "enum",
    "label": "Year submenu view mode",
    "values": ["InfoList", "List"],
    "default": "List"
},

{
    "id": "vmodemonth",
    "type": "enum",
    "label": "Month submenu view mode",
    "values": ["InfoList", "List", "Pictures"],
    "default": "Pictures"
}

]

Ok, I tried, I even reduced the main menu to nothing:

@handler(PREFIX, NAME, art = ART, thumb = ICON)
def XKCDMenu():
    # view_prefs = Prefs['vmodemenu']
    oc = ObjectContainer()
    BasicInfos = GetBasicInfos()
if not BasicInfos:
    # Not able to get even basic infos, aborting
    Log.Error('Basic infos were not found, xkcd may not be available')
    return ObjectContainer(header=NAME, message=L("ErrorBasics"))

#Create yearly subdirectories
# for i in xrange(BasicInfos['first_year'], BasicInfos['last_year']+1):
    # first_nb, last_nb = GetYearNumbers(i)
    # if not first_nb:
        # continue
    # name = Locale.LocalStringWithFormat('Year_Dirname', i, first_nb, last_nb)
    # oc.add(DirectoryObject(
                        # key = Callback(YearDirectory, year=i),
                        # title= name,
                        # thumb = Callback(GetIcon, year=i)
                        # ))
return oc

Then I removed the cache, the logs everything before restarting... and it is still not working!

At this point, I will stop anyway as what I wanted to do is not really possible.

But frankly, I remember now why I really don't like to develop for Plex.

Anyway, thank you all guys for the help.

Offtopic, a last question, is there a way to launch some code running in the background when the plugin is installed?

Then I removed the cache, the logs everything before restarting... and it is still not working!

At this point, I will stop anyway as what I wanted to do is not really possible.

But frankly, I remember now why I really don't like to develop for Plex.

Anyway, thank you all guys for the help.

Sorry I couldn't be more help.

Offtopic, a last question, is there a way to launch some code running in the background when the plugin is installed?

I don't believe there's any hook that you could use to launch on install. It might be technically possible to run external code when the plugin is launched but, I don't think there are any examples of that.