Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corrupted thumbnail images #59

Closed
HDebeuf opened this issue Oct 2, 2021 · 1 comment
Closed

Corrupted thumbnail images #59

HDebeuf opened this issue Oct 2, 2021 · 1 comment

Comments

@HDebeuf
Copy link

HDebeuf commented Oct 2, 2021

Describe the Bug
I've got corrupted (empty) images being displayed in the media cards.

The Error
No error in the front end since the image files exist and they are retrieved with a HTTP 200 code.

Indicate if you followed all steps in the troubleshooting doc
Yes, I followed the steps.

What data does the sensor display if any?
All correct data.

What displays when visiting the API URL from the troubleshooting guide?
Correct paths to the images.

Does the default Home Assistant Plex component work for you?
Yes, this issue concerns only the Plex integration.

Home Assistant Version
HA 2021.9.7

Additional Context
My use case is a Plex media server remotely setup with a Let'sEncrypt enabled reverse proxy on port 443.
Due to this if I call manually my photo transcoder with the domain name I set encoded, I get a 404 error.
Still, the module will download an empty image without throwing the error.

More detailed analysis
It appears the image_url() function encodes a full url to send to the transcoder.
Someone who has setup Plex locally won't encounter the issue since the transcoder works with a local ip as url parameter.
Someone who has it remotely setup, won't be able to transcode with a remote host encoded as url parameter.
Someone who has it remotely setup, will be able to transcode if the local ip address is encoded as url parameter.

+ http(s)://local_host:local_port/photo/:/transcode?width=XX&height=XX&minSize=1&url=local_host:local_port%2Flibrary%2Fmetadata%2F1234%2Fthumb%1234567890&X-Plex-Token=XXXXXXXX
- http(s)://remote_host:remote_port/photo/:/transcode?width=XX&height=XX&minSize=1&url=remote_host:remote_port%2Flibrary%2Fmetadata%2F1234%2Fthumb%1234567890&X-Plex-Token=XXXXXXXX
+ http(s)://remote_host:remote_port/photo/:/transcode?width=XX&height=XX&minSize=1&url=local_host:local_port%2Flibrary%2Fmetadata%2F1234%2Fthumb%1234567890&X-Plex-Token=XXXXXXXX

How I sorted the issue in my HA instance
By inspecting what the actual plex.tv dashboard does, it appears the encoded url parameter a relative path to the image file is.
So the following works perfectly.

+ http(s)://remote_host:remote_port/photo/:/transcode?width=XX&height=XX&minSize=1&url=%2Flibrary%2Fmetadata%2F1234%2Fthumb%1234567890&X-Plex-Token=XXXXXXXX

So, I've replaced in the image_url() function of the sensor.py file:
encoded = quote('http{0}://{1}:{2}{3}?X-Plex-Token={4}'.format(ssl, local, port, img,token), safe='')
with
encoded = quote(img), safe='')
and it worked like a charm.
I don't know if it could work with a locally setup Plex Server, but it might make the job easier.

Best regards,

hdebeuf

@mkanet
Copy link
Collaborator

mkanet commented May 30, 2024

The latest versions of Plex have full support for plex instances behind an NGINX reverse proxy on port 443.

@mkanet mkanet closed this as completed May 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants