Skip to content
Open
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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ Platform | Description

## Configuration is done in the UI

You can configure a custom gPodder server URL in the integration setup (e.g., https://gpodder.net or your self-hosted instance).

## Contributions are welcome!

If you want to contribute to this please read the [Contribution guidelines](CONTRIBUTING.md)
Expand Down
22 changes: 19 additions & 3 deletions custom_components/gpodder/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import podcastparser
from homeassistant.exceptions import ConfigEntryNotReady
from mygpoclient import api
from urllib.parse import urlparse

from custom_components.gpodder.const import (
CONF_DEVICE,
Expand All @@ -21,6 +22,8 @@
DOMAIN,
REQUEST_HEADERS,
STARTUP,
CONF_BASE_URL,
DEFAULT_BASE_URL,
)

UPDATE_INTERVAL = timedelta(minutes=30)
Expand All @@ -43,8 +46,11 @@ async def async_setup_entry(hass, entry):
password = entry.data.get(CONF_PASSWORD)
device = entry.data.get(CONF_DEVICE)
name = entry.data.get(CONF_NAME)
base_url = entry.data.get(CONF_BASE_URL, DEFAULT_BASE_URL)

coordinator = GpodderDataUpdateCoordinator(hass, username, password, device, name)
coordinator = GpodderDataUpdateCoordinator(
hass, username, password, device, name, base_url
)
await coordinator.async_refresh()

if not coordinator.last_update_success:
Expand Down Expand Up @@ -119,11 +125,21 @@ def update_using_feedservice(urls):
class GpodderDataUpdateCoordinator(DataUpdateCoordinator):
"""Class to manage fetching data from the API."""

def __init__(self, hass, username, password, device, name):
def __init__(self, hass, username, password, device, name, base_url):
"""Initialize."""
self.hass = hass
self.name = name
self.api = api.MygPodderClient(username, password)
# Parse base_url to derive host and SSL settings
try:
if "://" not in base_url:
base_url = f"https://{base_url}"
parsed = urlparse(base_url)
host = parsed.netloc or parsed.path
use_ssl = (parsed.scheme or "https").lower() != "http"
# Construct client with custom server and SSL preference
self.api = api.MygPodderClient(username, password, host, use_ssl)
except Exception: # Fallback to default behavior if parsing fails
self.api = api.MygPodderClient(username, password)
self.device = device

super().__init__(hass, _LOGGER, name=DOMAIN, update_interval=UPDATE_INTERVAL)
Expand Down
3 changes: 3 additions & 0 deletions custom_components/gpodder/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
CONF_PASSWORD,
CONF_USERNAME,
CONF_DEVICE,
CONF_BASE_URL,
DEFAULT_NAME,
DEFAULT_BASE_URL,
DOMAIN,
)

Expand Down Expand Up @@ -42,6 +44,7 @@ async def _show_config_form(self, user_input):
vol.Required(CONF_PASSWORD): str,
vol.Required(CONF_DEVICE): str,
vol.Required(CONF_NAME, default=DEFAULT_NAME): str,
vol.Required(CONF_BASE_URL, default=DEFAULT_BASE_URL): str,
}
),
errors=self._errors,
Expand Down
2 changes: 2 additions & 0 deletions custom_components/gpodder/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
CONF_USERNAME = "username"
CONF_PASSWORD = "password"
CONF_DEVICE = "device"
CONF_BASE_URL = "base_url"

# Defaults
DEFAULT_NAME = DOMAIN
DEFAULT_BASE_URL = "https://gpodder.net"
5 changes: 3 additions & 2 deletions custom_components/gpodder/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
"username": "Username",
"password": "Password",
"device": "Device",
"name": "Name"
"name": "Name",
"base_url": "Server URL (e.g., https://gpodder.net)"
}
}
}
}
}
}