# DefaultPrefs.json

**URL:** <https://forums.plex.tv/t/defaultprefs-json/1526>\
**Category:** Dev/API Corner\
**Tags:** plugin-dev\
**Created:** [April 18, 2009, 6:47pm UTC](https://forums.plex.tv/t/defaultprefs-json/1526 "2009-04-18T18:47:27Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![synackle](https://avatars.discourse-cdn.com/v4/letter/s/a9a28c/32.png) [@synackle](https://forums.plex.tv/u/synackle)\
**Post date:** [April 18, 2009, 6:47pm UTC](https://forums.plex.tv/t/defaultprefs-json/1526/1 "2009-04-18T18:47:27Z")

</div>

How do I use DefaultPrefs.json?  
  
Could someone post an example format of the file.  
  
  
  
Am I right in thinking that this will do the hard work of managing user inputted preferences?  
  
  
  
Thanks in advance  
  
  
  
EDIT:  
  
I’m still struggling with preferences…  
  
It looks like the \_\_container method of Prefs should automatically build the menus?  
  
here’s the code i have:  
  
[codebox]from PMS import \*  
  
from PMS.Objects import \*  
  
from PMS.Shortcuts import \*  
  
  
  
Plugin.\_\_logFilePath = “nzb.log”  
  
  
  
def Start():  
  
# Add the MainMenu prefix handler  
  
Plugin.AddPrefixHandler("/video/nzblockbuster/", MainMenu, L(“nzblockbuster”))  
  
  
  
# Set up view groups  
  
Plugin.AddViewGroup(“List”, viewMode=“List”, mediaType=“items”)  
  
Plugin.AddViewGroup(“Info”, viewMode=“InfoList”, mediaType=“items”)  
  
  
  
# Set the default MediaContainer attributes  
  
MediaContainer.title1 = L(“nzblockbuster”)  
  
MediaContainer.viewGroup = “List”  
  
MediaContainer.art = R(“art-default.png”)  
  
  
  
  
  
def MainMenu():  
  
dir = MediaContainer()  
  
dir.Append(Function(DirectoryItem(Movies, title=L(“movies”))))  
  
dir.Append(Function(DirectoryItem(Sabnzbd, title=L(“sabnzbd”))))  
  
dir.Append(Function(DirectoryItem(Preferences, title=L(“preferences”))))  
  
return dir  
  
  
  
def Movies(sender):  
  
dir = MediaContainer(title2=L(“movies”), viewGroup=“Info”)  
  
return dir  
  
  
  
def Sabnzbd(sender):  
  
dir = MediaContainer(title2=L(“sabnzbd”), viewGroup=“Info”)  
  
return dir  
  
  
  
def Preferences(sender):  
  
return Prefs.\_\_container()[/codebox]  
  
and my DefaultPrefs.json:  
  
[codebox][  
  
{id:“1”, type:“string”, default:“1”, label:“1”, value:“1”},  
  
{id:“2”, type:“string”, default:“2”, label:“2”, values:“2|3”}  
  
][/codebox]  
  
  
  
I’m stumped! Have i missed the point completely or should this work? Help! 🙂  
  
Cheers

---

<div class="post-metadata">

**Author:** ![synackle](https://avatars.discourse-cdn.com/v4/letter/s/a9a28c/32.png) [@synackle](https://forums.plex.tv/u/synackle)\
**Post date:** [April 27, 2009, 6:07pm UTC](https://forums.plex.tv/t/defaultprefs-json/1526/2 "2009-04-27T18:07:44Z")

</div>

sorry if it’s rude to bump like this but i edited my original post with more pleas for help, see above 🙂

---

<div class="post-metadata">

**Author:** ![jam](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/jam/32/186050_2.png) [@jam](https://forums.plex.tv/u/jam)\
**Post date:** [April 27, 2009, 7:06pm UTC](https://forums.plex.tv/t/defaultprefs-json/1526/3 "2009-04-27T19:06:27Z")

</div>

Hey! Sorry for the delayed response, your original post must’ve slipped under the radar 🙂  
  
  
  
The good news is that you’re almost there. The format of the file is correct (it’s an array of dictionaries). For the second preference, if you want to give the user a list of options to choose from, the type should be “enum” not “string”.  
  
  
  
The main thing you’re missing is how to display the preference dialog - any functions within the framework starting with “\_\_” aren’t meant to be called by the developer, they’re just for use internally.  
  
  
  
To add an item that displays the preferences dialog, just append a PrefsItem to the MediaContainer. The constructor accepts the standard DirectoryItem attributes, excluding the key, e.g. dir.Append(PrefsItem(title=L(“preferences”))).  
  
  
  
Hopefully that should work 🙂 Let us know if you have any other questions, we’ll try & respond faster next time!

---

<div class="post-metadata">

**Author:** ![synackle](https://avatars.discourse-cdn.com/v4/letter/s/a9a28c/32.png) [@synackle](https://forums.plex.tv/u/synackle)\
**Post date:** [April 27, 2009, 8:02pm UTC](https://forums.plex.tv/t/defaultprefs-json/1526/4 "2009-04-27T20:02:59Z")

</div>

Excellent, the pane is showing up a treat. 🙂  
  
  
  
Not sure about my DefaultPrefs.json yet tho, only the enums are showing up, with some strange values.  
  
I’ll have a play around and might quiz you again  
  
  
  
Cheers  
  
  
  
EDIT:  
  
OK now my enums work great with the following json, but my strings don’t show up at all:  
  
[codebox]  
  
[  
  
{id:“pref1”, type:“string”, default:“one”, label:“Pref One”, value:“one”},  
  
{id:“pref2”, type:“string”, default:“two”, label:“Pref Two”, value:“two”},  
  
{id:“pref3”, type:“enum”, default:“three”, label:“Pref Three”, values:“three|four”},  
  
{id:“pref4”, type:“enum”, default:“four”, label:“Pref Four”, values:“three|four”}  
  
]  
  
[/codebox]  
  
  
  
And I get a full plex crash when trying to save the prefs - are there any other files i need or could this be related to the dodgy strings?  
  
Thanks again

---

<div class="post-metadata">

**Author:** ![jam](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/jam/32/186050_2.png) [@jam](https://forums.plex.tv/u/jam)\
**Post date:** [April 28, 2009, 12:05pm UTC](https://forums.plex.tv/t/defaultprefs-json/1526/5 "2009-04-28T12:05:43Z")

</div>

Try changing “string” to “text”. Also, don’t set the “value” property in the defaults file, just the “default” one.  
  
  
  
I can’t think what could be causing the crash - could you post the Plex.log file if it happens again? Thanks 🙂

---

<div class="post-metadata">

**Author:** ![synackle](https://avatars.discourse-cdn.com/v4/letter/s/a9a28c/32.png) [@synackle](https://forums.plex.tv/u/synackle)\
**Post date:** [April 28, 2009, 5:31pm UTC](https://forums.plex.tv/t/defaultprefs-json/1526/6 "2009-04-28T17:31:12Z")

</div>

> [@](#):
>
> Try changing “string” to “text”. Also, don’t set the “value” property in the defaults file, just the “default” one.  
>   
>   
>   
> I can’t think what could be causing the crash - could you post the Plex.log file if it happens again? Thanks 🙂

  
  
Changing from string to text worked great, and no more crashes on save :D  
I discovered the bool type too which is handy - is there a password type, i.e. text that shows up as asterisks etc? Not essential but would be a nice touch  
  
Thanks for your help

---

<div class="post-metadata">

**Author:** ![jam](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/jam/32/186050_2.png) [@jam](https://forums.plex.tv/u/jam)\
**Post date:** [April 28, 2009, 6:00pm UTC](https://forums.plex.tv/t/defaultprefs-json/1526/7 "2009-04-28T18:00:31Z")

</div>

No problem! Happy to help 🙂 Things will be easier once all the documentation is complete. For passwords, use the text type, then add an extra property called “options” to the preference & set the value to “hidden”.

---

<div class="post-metadata">

**Author:** ![synackle](https://avatars.discourse-cdn.com/v4/letter/s/a9a28c/32.png) [@synackle](https://forums.plex.tv/u/synackle)\
**Post date:** [April 28, 2009, 6:11pm UTC](https://forums.plex.tv/t/defaultprefs-json/1526/8 "2009-04-28T18:11:31Z")

</div>

> [@](#):
>
> No problem! Happy to help 🙂 Things will be easier once all the documentation is complete. For passwords, use the text type, then add an extra property called “options” to the preference & set the value to “hidden”.

  
  
Awesome stuff option:"hidden" works great.  
  
I have yet another question about URL encoding, one of my prefs is a URL and plex seems to be url encoding it before it saves it, but does not urldecode when it displays it, so every time you view the pref it gets double urlencoded then double double urlencoded and so on... Is there an easy fix for this? another option or another datatype maybe?  
  
Cheers

---

<div class="post-metadata">

**Author:** ![jam](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/jam/32/186050_2.png) [@jam](https://forums.plex.tv/u/jam)\
**Post date:** [April 28, 2009, 7:28pm UTC](https://forums.plex.tv/t/defaultprefs-json/1526/9 "2009-04-28T19:28:02Z")

</div>

No, that would be a framework bug 🙂 I’ll look in to it & try to get a fix pushed later tonight. I’ll let you know when I’ve made some progress.

---

<div class="post-metadata">

**Author:** ![synackle](https://avatars.discourse-cdn.com/v4/letter/s/a9a28c/32.png) [@synackle](https://forums.plex.tv/u/synackle)\
**Post date:** [April 28, 2009, 8:53pm UTC](https://forums.plex.tv/t/defaultprefs-json/1526/10 "2009-04-28T20:53:09Z")

</div>

> [@](#):
>
> No, that would be a framework bug 🙂 I’ll look in to it & try to get a fix pushed later tonight. I’ll let you know when I’ve made some progress.

  
  
Ta :)

---

<div class="post-metadata">

**Author:** ![synackle](https://avatars.discourse-cdn.com/v4/letter/s/a9a28c/32.png) [@synackle](https://forums.plex.tv/u/synackle)\
**Post date:** [May 4, 2009, 8:10pm UTC](https://forums.plex.tv/t/defaultprefs-json/1526/11 "2009-05-04T20:10:30Z")

</div>

> [@](#):
>
> No, that would be a framework bug 🙂 I’ll look in to it & try to get a fix pushed later tonight. I’ll let you know when I’ve made some progress.

  
  
Any news?  
Cheers

---

<div class="post-metadata">

**Author:** ![jam](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/jam/32/186050_2.png) [@jam](https://forums.plex.tv/u/jam)\
**Post date:** [May 4, 2009, 8:40pm UTC](https://forums.plex.tv/t/defaultprefs-json/1526/12 "2009-05-04T20:40:53Z")

</div>

Sorry for not getting back to you sooner. Check your App Store update history - you might already have the fix. If not, you can manually update 🙂

---

<div class="post-metadata">

**Author:** ![synackle](https://avatars.discourse-cdn.com/v4/letter/s/a9a28c/32.png) [@synackle](https://forums.plex.tv/u/synackle)\
**Post date:** [May 6, 2009, 5:35pm UTC](https://forums.plex.tv/t/defaultprefs-json/1526/13 "2009-05-06T17:35:27Z")

</div>

> [@](#):
>
> Sorry for not getting back to you sooner. Check your App Store update history - you might already have the fix. If not, you can manually update 🙂

  
  
All looks good now, lovely job :)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/plex/original/3X/2/a/2acb9765406f63293d357b4ec509ec39aa28f2ad.png) [@system](https://forums.plex.tv/u/system)\
**Post date:** [December 20, 2019, 8:25pm UTC](https://forums.plex.tv/t/defaultprefs-json/1526/14 "2019-12-20T20:25:19Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
