diff --git a/tag_artist.py b/tag_artist.py index da0f4d9..afe5b3b 100755 --- a/tag_artist.py +++ b/tag_artist.py @@ -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():