Fix authentication for Jellyfin 10.12 and false success reports

- Use the standard "Authorization: MediaBrowser ..., Token=..." header
  instead of the legacy X-Emby-Authorization / X-Emby-Token headers,
  which are no longer accepted by Jellyfin 10.12.
- _make_request now returns True on empty successful responses (204)
  and None only on errors, so failed tag updates are reported as failures.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-10 21:32:00 +02:00
co-authored by Claude Opus 5.5
parent 908f4b3bdb
commit 5c46cc539f
+16 -7
View File
@@ -51,15 +51,23 @@ class JellyfinTagger:
self.user_id = None
self.access_token = None
# Set up headers
# Set up headers (Jellyfin 10.12+ only accepts the standard Authorization header,
# the legacy X-Emby-* headers are no longer supported)
self.session.headers.update({
'Content-Type': 'application/json',
'X-Emby-Authorization': 'MediaBrowser Client="SimpleTagger", Device="Python Script", DeviceId="simple-tagger", Version="1.0.0"'
'Authorization': self._auth_header()
})
# Authenticate
self._authenticate()
def _auth_header(self) -> str:
"""Build the MediaBrowser Authorization header, including the token once authenticated."""
header = 'MediaBrowser Client="SimpleTagger", Device="Python Script", DeviceId="simple-tagger", Version="1.0.0"'
if self.access_token:
header += f', Token="{self.access_token}"'
return header
def _authenticate(self):
"""Authenticate with Jellyfin using username and password."""
auth_url = f"{self.server_url}/Users/AuthenticateByName"
@@ -78,7 +86,7 @@ class JellyfinTagger:
# Update headers with access token
self.session.headers.update({
'X-Emby-Token': self.access_token
'Authorization': self._auth_header()
})
except requests.exceptions.RequestException as e:
@@ -95,7 +103,8 @@ class JellyfinTagger:
if response.content:
return response.json()
return None
# Success without body (e.g. 204 No Content); None is reserved for errors
return True
except requests.exceptions.HTTPError as e:
print(f"❌ HTTP error {e.response.status_code}: {e}")
@@ -192,8 +201,8 @@ class JellyfinTagger:
json=update_data,
params=update_params)
# Consider it successful if we get any response (including 204 No Content)
return result is not False
# _make_request returns None on any error, True on 204 No Content
return result is not None
def main():