From 262c5b0e0d42794946cd63504925c96b050c1f13 Mon Sep 17 00:00:00 2001 From: "Michael K. Avanessian" Date: Wed, 22 May 2024 18:07:54 -0700 Subject: [PATCH 1/4] Correct manifest.json to version 0.4.3 --- custom_components/plex_recently_added/manifest.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/custom_components/plex_recently_added/manifest.json b/custom_components/plex_recently_added/manifest.json index 725c012..9897097 100644 --- a/custom_components/plex_recently_added/manifest.json +++ b/custom_components/plex_recently_added/manifest.json @@ -1,12 +1,13 @@ { "domain": "plex_recently_added", "name": "Plex Recently Added", + "after_dependencies": ["http"], "codeowners": ["@maykar"], "config_flow": true, - "dependencies": ["http"], + "dependencies": [], "documentation": "https://github.com/custom-components/sensor.plex_recently_added", "iot_class": "local_polling", "issue_tracker": "https://github.com/custom-components/sensor.plex_recently_added/issues", "requirements": [], - "version": "0.4.2" + "version": "0.4.3" } From d9b5e38e24b3584548330e85377c8f1d57028e63 Mon Sep 17 00:00:00 2001 From: Makhuta Date: Fri, 24 May 2024 10:29:10 +0200 Subject: [PATCH 2/4] Fix - ssl issue with HomeAssistant redirect (from secured HA to unsecured Plex) --- custom_components/plex_recently_added/redirect.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/custom_components/plex_recently_added/redirect.py b/custom_components/plex_recently_added/redirect.py index 9328783..b59070f 100644 --- a/custom_components/plex_recently_added/redirect.py +++ b/custom_components/plex_recently_added/redirect.py @@ -8,7 +8,6 @@ CONF_NAME, CONF_HOST, CONF_PORT, - CONF_SSL ) from .const import DOMAIN @@ -19,7 +18,7 @@ class ImagesRedirect(HomeAssistantView): def __init__(self, config_entry: ConfigEntry): super().__init__() self._token = config_entry.data[CONF_API_KEY] - self._base_url = f'http{'s' if config_entry.data[CONF_SSL] else ''}://{config_entry.data[CONF_HOST]}:{config_entry.data[CONF_PORT]}' + self._base_url = f'https://{config_entry.data[CONF_HOST]}:{config_entry.data[CONF_PORT]}' self.name = f'{self._token}_Plex_Recently_Added' self.url = f'/{config_entry.data[CONF_NAME].lower() + "_" if len(config_entry.data[CONF_NAME]) > 0 else ""}plex_recently_added' From 797a5efae780dda9cafbf2645ed40ed7b5375840 Mon Sep 17 00:00:00 2001 From: Makhuta Date: Fri, 24 May 2024 15:20:52 +0200 Subject: [PATCH 3/4] Fix - hopefully that time it is gonna work --- custom_components/plex_recently_added/redirect.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/custom_components/plex_recently_added/redirect.py b/custom_components/plex_recently_added/redirect.py index b59070f..7785fef 100644 --- a/custom_components/plex_recently_added/redirect.py +++ b/custom_components/plex_recently_added/redirect.py @@ -1,6 +1,6 @@ from homeassistant.components.http import HomeAssistantView from homeassistant.config_entries import ConfigEntry -from aiohttp import web +from aiohttp import web, ClientSession import requests from homeassistant.const import ( @@ -8,6 +8,7 @@ CONF_NAME, CONF_HOST, CONF_PORT, + CONF_SSL ) from .const import DOMAIN @@ -18,12 +19,18 @@ class ImagesRedirect(HomeAssistantView): def __init__(self, config_entry: ConfigEntry): super().__init__() self._token = config_entry.data[CONF_API_KEY] - self._base_url = f'https://{config_entry.data[CONF_HOST]}:{config_entry.data[CONF_PORT]}' + self._base_url = f'http{'s' if config_entry.data[CONF_SSL] else ''}://{config_entry.data[CONF_HOST]}:{config_entry.data[CONF_PORT]}' self.name = f'{self._token}_Plex_Recently_Added' self.url = f'/{config_entry.data[CONF_NAME].lower() + "_" if len(config_entry.data[CONF_NAME]) > 0 else ""}plex_recently_added' async def get(self, request): path = request.query.get("path", "") url = f'{self._base_url}{path}?X-Plex-Token={self._token}' - return web.HTTPFound(url) + async with ClientSession() as session: + async with session.get(url) as res: + if res.ok: + content = await res.read() + return web.Response(body=content, content_type=res.content_type) + + return web.HTTPNotFound() From c58bc4b83c44461df44e3114602b180c1638e77a Mon Sep 17 00:00:00 2001 From: "Michael K. Avanessian" Date: Fri, 24 May 2024 08:54:38 -0700 Subject: [PATCH 4/4] Update version to 0.4.4 --- custom_components/plex_recently_added/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/plex_recently_added/manifest.json b/custom_components/plex_recently_added/manifest.json index 9897097..4da6665 100644 --- a/custom_components/plex_recently_added/manifest.json +++ b/custom_components/plex_recently_added/manifest.json @@ -9,5 +9,5 @@ "iot_class": "local_polling", "issue_tracker": "https://github.com/custom-components/sensor.plex_recently_added/issues", "requirements": [], - "version": "0.4.3" + "version": "0.4.4" }