HTTP.SetPassword Error

Receiving error in log
Hi. I'm trying to use HTTP.Request to get some info from a website. I read some other threads about people trying to make plugins to manage torrent downloads from within the PLEX interface but decided to give it a go myself. The HTTP request will just be returning some info that I will use to populate a list, not media to play. Here's the small code I have now:

##################################################<br />
<br />
VIDEO_PREFIX = "/video/ptp"<br />
<br />
NAME = "Pass The Popcorn"<br />
<br />
ART = 'art-default.jpg'<br />
ICON = 'icon-default.png'<br />
<br />
##################################################<br />
<br />
def Start():<br />
<br />
	Plugin.AddPrefixHandler(VIDEO_PREFIX, MainMenu, NAME, ICON, ART)<br />
	Plugin.AddViewGroup("List", viewMode = "List", mediaType = "items")<br />
	<br />
	MediaContainer.art = R(ART)<br />
	MediaContainer.title1 = NAME<br />
	MediaContainer.viewGroup = "List"<br />
	DirectoryItem.thumb = R(ICON)<br />
	<br />
def MainMenu():<br />
	<br />
	dir = MediaContainer(viewMode="List")<br />
	dir.Append(Function(DirectoryItem(MostRecent, "Most Recent")))<br />
	dir.Append(PrefsItem(L('Preferences'), thumb=R('icon-default.png')))<br />
	<br />
	return dir<br />
	<br />
def MostRecent(sender):<br />
	<br />
	u = Prefs['username']<br />
	p = Prefs['password']<br />
	<br />
	req = HTTP.Request('http://passthepopcorn.me/torrents.php')<br />
	HTTP.SetPassword('http://passthepopcorn.me', u, p)<br />
	req.load()<br />
	res = req.content<br />
	<br />
	Log(res)<br />
	<br />
	return MessageContainer('Result', L(res))



Right now I'm kinda just hacking around and sending the result of the HTTP.Request to a MessageContainer to see if it worked. This works when I DO NOT include the line to HTTP.SetPassword, but when I do include that line, I receive an error in my log. Here's the line in the log that is of note:


2012-12-11 02:14:41,676 (-4faed000) :  CRITICAL (sandbox:303) - Exception when calling function 'MostRecent' (most recent call last):<br />
  File "/Users/thorson/Library/Application Support/Plex Media Server/Plug-ins/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/code/sandbox.py", line 294, in call_named_function<br />
    result = f(*args, **kwargs)<br />
  File "/Users/thorson/Library/Application Support/Plex Media Server/Plug-ins/passThePopcorn.bundle/Contents/Code/__init__.py", line 38, in MostRecent<br />
    HTTP.SetPassword('http://passthepopcorn.me', u, p)<br />
  File "/Users/thorson/Library/Application Support/Plex Media Server/Plug-ins/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/api/base.py", line 55, in func<br />
    return f(self, *args, **kwargs)<br />
  File "/Users/thorson/Library/Application Support/Plex Media Server/Plug-ins/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/api/networkkit.py", line 218, in SetPassword<br />
    return self._core.networking.set_http_password(url, username, password, realm)<br />
  File "/Users/thorson/Library/Application Support/Plex Media Server/Plug-ins/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/components/networking.py", line 420, in set_http_password<br />
    if _global_http_auth_enabled:<br />
NameError: global name '_global_http_auth_enabled' is not defined



Let me know if you have any ideas or if I'm going about this all wrong. Thanks in advance for any assistance, I really appreciate it.

Ok I was definitely going about it the wrong way. I think HTTP.SetPassword method is for password protected web directories maybe(?), I needed to actually POST my username and password in order to login to this website. I checked out the Vimeo plugin example on GitHub and found some good direction there.



I know it’s been mentioned around here before, but for others that are looking for a good way to visualize network traffic/requests/responses, Charles Proxy is an absolutely invaluable tool.

I'm getting this error, and I actually DO need to use HTTP auth. Anyone have any thoughts?

Figured it out... minor coding error in  ~/Library/Application Support/Plex Media Server/Plug-ins/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/components/networking.py

In the set_http_password function, it has

 
    if _global_http_auth_enabled:
 
That needs to be:
 
    if self._global_http_auth_enabled:
 
Endeavoring to file a bug report...

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