Giter VIP home page Giter VIP logo

Comments (6)

maykar avatar maykar commented on July 22, 2024

If you follow the steps in the troubleshooting doc are you able to connect to the API? If not, this isn't something that can be fixed and would explain why the HA plex component doesn't work for you as well.

from sensor.plex_recently_added.

ljpaff avatar ljpaff commented on July 22, 2024

I try to explain.

When you do:

https://plex.tv/api/servers.xml?X-Plex-Token=xxxxxxxxxxxxxgYE <--- My Login Token

I receive:
<?xml version="1.0" encoding="UTF-8"?> <MediaContainer friendlyName="myPlex" identifier="com.plexapp.plugins.myplex" machineIdentifier="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" size="1"> <Server accessToken="xxxxxxxxxxxxxx9jY4" name="xxxxxxxxxxx" address="xxxxxxx" port="32400" version="1.16.3.1402-22929c8a2" scheme="http" host="xxxxxxx" localAddresses="" machineIdentifier="xxxxxxxxxxx" createdAt="1549384857" updatedAt="1565904197" owned="0" synced="0" sourceTitle="xxxxxxx" ownerId="xxxxxxxx" home="0"/> </MediaContainer>

If you see the Tokens are distinct and of course localAddresses is not used because is not at your location.

Regards

from sensor.plex_recently_added.

maykar avatar maykar commented on July 22, 2024

Have you tried the host/port option instead of the server_name option?

from sensor.plex_recently_added.

ljpaff avatar ljpaff commented on July 22, 2024

@maykar It is being thought that all servers within an account are the property of the person being authenticated, and this is not the case.

A part of the code uses the variable "localAddresses" that returns the xml, when this variable is only reported by Plex when the server is local (You belong) not remote (has been shared with you by someone).

It is also assumed that the access token is the same as the user token when as you can see in the XML example this is not the case.

I'll paste the lines where the problem is:

Line 298

def image_url(url_elements, cert_check, img):
"""Plex can resize images with a long & partially % encoded url."""
from urllib.parse import quote
ssl, host, local, port, token, self_cert, dl_images = url_elements
if not cert_check and not self_cert:
ssl = ''
if dl_images:
host = local
encoded = quote('http{0}://{1}:{2}{3}?X-Plex-Token={4}'.format(ssl,
local,
port,
img,
token),
safe='')
url = ('http{0}://{1}:{2}/photo/:/transcode?width=200&height=200'
'&minSize=1&url={3}&X-Plex-Token={4}').format(ssl, host, port,
encoded, token)
"""Check if image exists"""
if not self_cert:
r = requests.head(url, verify=False)
else:
r = requests.head(url)
if r.status_code == 200:
return url
else:
return False

And using the same token for all the code. You must use "host" or "address" instead for image download, and add a new variable for each server that is a token. If there is no token then use the one provided by the user in its configuration.

from sensor.plex_recently_added.

maykar avatar maykar commented on July 22, 2024

I understand. A while back I removed server_name from the readme as that option created more problems than it solved, with user confusion and plex API changes. It's still in the code to avoid a breaking change for the people who are using it successfully. As such, I don't think I'll expand that feature, it should be considered depreciated.

Are you able to connect to the server using host/port instead of server_name? The code you are pointing to is only used when using server_name.

from sensor.plex_recently_added.

maykar avatar maykar commented on July 22, 2024

Closing this issue as stale and because the server_name option is depreciated and this should be possible by using host/port. If you are unable to connect with host/port, please reopen this issue or create a new one.

from sensor.plex_recently_added.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.