Welcome to our forums! Please take a few moments to read through our Community Guidelines (also conveniently linked in the header at the top of each page). There, you'll find guidelines on conduct, tips on getting the help you may be searching for, and more!

Unauthorized getting local media details

psycikpsycik Members, Plex Pass Posts: 392 Plex Pass

I have a metadata agent that's based on the NFO one as it reads an XML file generated by a PVR application.

I've been trying to diagnose a issue with it where it's not been firing. Now it seems to be but there's a call to get the media tree item from plex, so that it can be updated. But I seem to be getting a unauthorised.

2017-07-09 21:49:59,540 (1cd4) :  DEBUG (networking:166) - Requesting 'http://localhost:32400/library/metadata/184889/tree'
2017-07-09 21:50:00,546 (1cd4) :  ERROR (networking:219) - Error opening URL 'http://localhost:32400/library/metadata/184889/tree'
2017-07-09 21:50:00,548 (1cd4) :  CRITICAL (core:574) - Exception in the search function of agent named 'NPVR TV .xml Importer', called with keyword arguments {'openSubtitlesHash': '276ccc72bac9e1f5', 'episode': '0708', 'name': '0708', 'episodic': '1', 'show': 'Britains Got Talent', 'released_at': '2017-07-08', 'season': '2017', 'filename': 'P%3A%5CServerFolders%5CRecordings%5CBritains%20Got%20Talent%5CBritains%20Got%20Talent_20170708_19002000%2Ets', 'plexHash': '9d59d89b7a9813932d80a195a1a759f1febac1a6', 'duration': '5697838', 'id': '184889'} (most recent call last):
  File "C:\Program Files (x86)\Plex\Plex Media Server\Resources\Plug-ins-313f93718\Framework.bundle\Contents\Resources\Versions\2\Python\Framework\api\agentkit.py", line 1007, in _search
    agent.search(*f_args, **f_kwargs)
  File "C:\Plex\Plex Media Server\Plug-ins\NPVRxmlTV.bundle\Contents\Code\__init__.py", line 38, in search
    Log(XML.ElementFromURL(pageUrl).xpath('//MediaContainer/MetadataItem/MetadataItem/MetadataItem/MetadataItem'))
  File "C:\Program Files (x86)\Plex\Plex Media Server\Resources\Plug-ins-313f93718\Framework.bundle\Contents\Resources\Versions\2\Python\Framework\api\parsekit.py", line 344, in ElementFromURL
    method=method,
  File "C:\Program Files (x86)\Plex\Plex Media Server\Resources\Plug-ins-313f93718\Framework.bundle\Contents\Resources\Versions\2\Python\Framework\api\networkkit.py", line 67, in _http_request
    req = self._core.networking.http_request(url, *args, **kwargs)
  File "C:\Program Files (x86)\Plex\Plex Media Server\Resources\Plug-ins-313f93718\Framework.bundle\Contents\Resources\Versions\2\Python\Framework\components\networking.py", line 370, in http_request
    return HTTPRequest(self._core, url, data, h, url_cache, encoding, errors, timeout, immediate, sleep, opener, follow_redirects, method)
  File "C:\Program Files (x86)\Plex\Plex Media Server\Resources\Plug-ins-313f93718\Framework.bundle\Contents\Resources\Versions\2\Python\Framework\components\networking.py", line 141, in __init__
    self.load()
  File "C:\Program Files (x86)\Plex\Plex Media Server\Resources\Plug-ins-313f93718\Framework.bundle\Contents\Resources\Versions\2\Python\Framework\components\networking.py", line 181, in load
    f = self._opener.open(req, timeout=self._timeout)
  File "C:\Program Files (x86)\Plex\Plex Media Server\python27.zip\urllib2.py", line 435, in open
    response = meth(req, response)
  File "C:\Program Files (x86)\Plex\Plex Media Server\python27.zip\urllib2.py", line 548, in http_response
    'http', request, response, code, msg, hdrs)
  File "C:\Program Files (x86)\Plex\Plex Media Server\python27.zip\urllib2.py", line 473, in error
    return self._call_chain(*args)
  File "C:\Program Files (x86)\Plex\Plex Media Server\python27.zip\urllib2.py", line 407, in _call_chain
    result = func(*args)
  File "C:\Program Files (x86)\Plex\Plex Media Server\python27.zip\urllib2.py", line 556, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
HTTPError: HTTP Error 401: Unauthorized

2017-07-09 21:50:00,548 (1cd4) :  DEBUG (runtime:88) - Sending packed state data (107 bytes)

I can confirm that trying to access http://localhost:32400/library/metadata/184889/tree from the local machine does get me an unauthorised until I add ?X-plex-token=plex token here, then I get details.

How is a metadata agent supposed to do this?

Plex for IOS, PlexConnect, Roku3 and NextPVR Channel

Plex PMS on AMD A10 for movies and TV, and Plex PMS on AMD A8 with NextPVR custom scanner and Agent

Sign In or Register to comment.