Help with plugin code

Unable to find JSON.DictFromURL
Hi,

Another newbie question : For some reason my plugin is unable to locate JSON.DictFromURL object, even though I have imported JSON... ("from PMS import Log, HTTP, JSON, Plugin, XML") - what am I missing?

Here is the console log:

6/7/10 5:48:56 PM [0x0-0xd2cd2c].com.yourcompany.Plex_Media_Server[60720] 17:48:56.468116: com.plexapp.plugins.btv : (Framework) An exception happened:
6/7/10 5:48:56 PM [0x0-0xd2cd2c].com.yourcompany.Plex_Media_Server[60720] Traceback (most recent call last):
6/7/10 5:48:56 PM [0x0-0xd2cd2c].com.yourcompany.Plex_Media_Server[60720] File "/Volumes/Home/madduluri/Library/Application Support/Plex Media Server/Plug-ins/Framework.bundle/Contents/Resources/Versions/1/Python/PMS/Plugin.py", line 640, in __call
6/7/10 5:48:56 PM [0x0-0xd2cd2c].com.yourcompany.Plex_Media_Server[60720] return function(*args, **kwargs)
6/7/10 5:48:56 PM [0x0-0xd2cd2c].com.yourcompany.Plex_Media_Server[60720] File "/Volumes/Home/mad/Library/Application Support/Plex Media Server/Plug-ins/bTV.bundle/Contents/Code/__init__.py", line 177, in menumovies
6/7/10 5:48:56 PM [0x0-0xd2cd2c].com.yourcompany.Plex_Media_Server[60720] dict = JSON.DictFromURL(data2, "Latin-1")
6/7/10 5:48:56 PM [0x0-0xd2cd2c].com.yourcompany.Plex_Media_Server[60720] AttributeError: 'module' object has no attribute 'DictFromURL'

Thanks in advance!

-- Bapatla

it’s JSON.ObjectFromURL, not Dict. see the docs: http://dev.plexapp.com/docs/mod_JSON.html



I see the object being present in Framework.bundle/Contents/Resources/Versions/0/Python/PMS/JSON.py ... Why isn't my code finding this, even though I included JSON?


Billy Joe is probably more familiar with the Framework, but I think that in v1 you only need:


from PMS import *<br />
from PMS.Objects import *<br />
from PMS.Shortcuts import *



Not to declare each import explicitly.

Good luck,
Dbl_A

yeah you dont need to import the json module specifically in v1, “from PMS import *” gets it, and please dont use v0 if you can avoid it, it really sucks, use framework version 1.



My code has these statements.. I tried importing others, hoping that these would fix the problem...
import os, hashlib, sys
import httplib, urllib
import string, time
import demjson as json
from PMS import *
from PMS.Objects import *
from PMS.Shortcuts import *
# from PMS import Log, HTTP, JSON, Plugin, Thread, Utils, XML, DB
from PMS import Log, HTTP, JSON, Plugin, XML

import htmlentitydefs
import time
import re
from datetime import datetime, timedelta
from urlparse import urlparse

Just to hammer home the issue, you were looking in version 0 of the PMS framework. See the ‘0’ in the py path:



Framework.bundle/Contents/Resources/Versions/0/Python/PMS/JSON.py



If you want to browse the code (at it is a useful place for info) look in Framework.bundle/Contents/Resources/Versions/1



Jonny



I did look in Framework.bundle/Contents/Resources/Versions/1/... DictFromURL and DictFromString are no longer there... does it mean that they have been deprecated? If so, how else can I construct a dictionary from a JSON object?

in version 1, its JSON.ObjectFromURL and JSON.ObjectFromString

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