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

Revert "convert host + port to url to support https" #9

Merged
merged 1 commit into from
Feb 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions custom_components/mediarr/server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

from homeassistant.const import (
CONF_URL,
CONF_HOST,
CONF_PORT,
CONF_TOKEN,
)
import homeassistant.helpers.config_validation as cv
Expand Down
12 changes: 7 additions & 5 deletions custom_components/mediarr/server/jellyfin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,22 @@
import async_timeout
import voluptuous as vol
from pathlib import Path
from homeassistant.const import CONF_TOKEN, CONF_URL
from homeassistant.const import CONF_TOKEN, CONF_HOST, CONF_PORT
import homeassistant.helpers.config_validation as cv
from ..common.const import CONF_MAX_ITEMS, DEFAULT_MAX_ITEMS
from ..common.tmdb_sensor import TMDBMediaSensor
from homeassistant.helpers.aiohttp_client import async_get_clientsession

_LOGGER = logging.getLogger(__name__)

DEFAULT_URL = 'http://localhost:8096'
DEFAULT_HOST = 'localhost'
DEFAULT_PORT = 8096

JELLYFIN_SCHEMA = {
vol.Required(CONF_TOKEN): cv.string,
vol.Required('tmdb_api_key'): cv.string,
vol.Optional(CONF_URL, default=DEFAULT_URL): cv.string,
vol.Optional(CONF_HOST, default=DEFAULT_HOST): cv.string,
vol.Optional(CONF_PORT, default=DEFAULT_PORT): cv.port,
vol.Optional(CONF_MAX_ITEMS, default=DEFAULT_MAX_ITEMS): cv.positive_int,
}

Expand All @@ -27,7 +29,7 @@ class JellyfinMediarrSensor(TMDBMediaSensor):
def __init__(self, session, config, user_id):
"""Initialize the sensor."""
super().__init__(session, config['tmdb_api_key'])
self._base_url = config[CONF_URL]
self._base_url = f"http://{config[CONF_HOST]}:{config[CONF_PORT]}"
self._jellyfin_token = config[CONF_TOKEN]
self._max_items = config[CONF_MAX_ITEMS]
self._name = "Jellyfin Mediarr"
Expand Down Expand Up @@ -316,7 +318,7 @@ async def async_update(self):
async def create_sensors(cls, hass, config):
"""Create a single Jellyfin sensor for all libraries."""
try:
base_url = config[CONF_URL]
base_url = f"http://{config[CONF_HOST]}:{config[CONF_PORT]}"
token = config[CONF_TOKEN]

headers = {
Expand Down
12 changes: 7 additions & 5 deletions custom_components/mediarr/server/plex.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,22 @@
import aiohttp
import async_timeout
import voluptuous as vol
from homeassistant.const import CONF_TOKEN, CONF_URL
from homeassistant.const import CONF_TOKEN, CONF_HOST, CONF_PORT
import homeassistant.helpers.config_validation as cv
from ..common.const import CONF_MAX_ITEMS, DEFAULT_MAX_ITEMS
from ..common.tmdb_sensor import TMDBMediaSensor
from homeassistant.helpers.aiohttp_client import async_get_clientsession

_LOGGER = logging.getLogger(__name__)

DEFAULT_URL = 'http://localhost:32400'
DEFAULT_HOST = 'localhost'
DEFAULT_PORT = 32400

PLEX_SCHEMA = {
vol.Required(CONF_TOKEN): cv.string,
vol.Required('tmdb_api_key'): cv.string,
vol.Optional(CONF_URL, default=DEFAULT_URL): cv.string,
vol.Optional(CONF_HOST, default=DEFAULT_HOST): cv.string,
vol.Optional(CONF_PORT, default=DEFAULT_PORT): cv.port,
vol.Optional(CONF_MAX_ITEMS, default=DEFAULT_MAX_ITEMS): cv.positive_int,
}

Expand All @@ -27,7 +29,7 @@ class PlexMediarrSensor(TMDBMediaSensor):
def __init__(self, session, config, sections):
"""Initialize the sensor."""
super().__init__(session, config['tmdb_api_key'])
self._base_url = config[CONF_URL]
self._base_url = f"http://{config[CONF_HOST]}:{config[CONF_PORT]}"
self._token = config[CONF_TOKEN]
self._max_items = config[CONF_MAX_ITEMS]
self._name = "Plex Mediarr"
Expand Down Expand Up @@ -238,7 +240,7 @@ async def async_update(self):
async def create_sensors(cls, hass, config):
"""Create a single Plex sensor for all sections."""
try:
base_url = config[CONF_URL]
base_url = f"http://{config[CONF_HOST]}:{config[CONF_PORT]}"
token = config[CONF_TOKEN]

# Fetch sections
Expand Down