From 8de23eec35057e4c0620b7fa3cb6149126df47dc Mon Sep 17 00:00:00 2001 From: None Date: Thu, 5 Feb 2026 20:55:52 -0600 Subject: [PATCH] Fix XC URL sub-path handling in profile refresh and EPG creation - Fix credential extraction in get_transformed_credentials() using negative indices anchored to the known tail structure instead of hardcoded indices that break when server URLs contain sub-paths - Fix EPG URL construction in M3U form to normalize server URL to origin before appending xmltv.php endpoint XC accounts with sub-paths in their server URL (e.g., http://server.com/portal/a/) caused two failures: profile refresh extracted wrong credentials from the URL path due to hardcoded array indices, and EPG auto-creation appended xmltv.php under the sub-path instead of at the domain root. Both fixes normalize away the sub-path using the same approach the backend's XCClient already uses for API calls. --- apps/m3u/tasks.py | 10 ++++++---- frontend/src/components/forms/M3U.jsx | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/apps/m3u/tasks.py b/apps/m3u/tasks.py index f929a208..0b035702 100644 --- a/apps/m3u/tasks.py +++ b/apps/m3u/tasks.py @@ -2305,10 +2305,12 @@ def get_transformed_credentials(account, profile=None): parsed_url = urllib.parse.urlparse(transformed_complete_url) path_parts = [part for part in parsed_url.path.split('/') if part] - if len(path_parts) >= 2: - # Extract username and password from path - transformed_username = path_parts[1] - transformed_password = path_parts[2] + if len(path_parts) >= 4 and path_parts[-1] == '1234.ts': + # Extract username and password from the known structure: + # .../{live}/{username}/{password}/1234.ts + # Using negative indices so sub-paths in the server URL don't shift extraction + transformed_username = path_parts[-3] + transformed_password = path_parts[-2] # Rebuild server URL without the username/password path transformed_url = f"{parsed_url.scheme}://{parsed_url.netloc}" diff --git a/frontend/src/components/forms/M3U.jsx b/frontend/src/components/forms/M3U.jsx index a13f4fef..c92ce823 100644 --- a/frontend/src/components/forms/M3U.jsx +++ b/frontend/src/components/forms/M3U.jsx @@ -148,7 +148,7 @@ const M3U = ({ API.addEPG({ name: values.name, source_type: 'xmltv', - url: `${values.server_url}/xmltv.php?username=${values.username}&password=${values.password}`, + url: `${new URL(values.server_url).origin}/xmltv.php?username=${values.username}&password=${values.password}`, api_key: '', is_active: true, refresh_interval: 24,