Skip to content

Fix Xtream API 403 errors by adding a fallback User-Agent (#274)#411

Open
CoderBoxer wants to merge 1 commit intolinuxmint:masterfrom
CoderBoxer:feature/xtream-user-agent
Open

Fix Xtream API 403 errors by adding a fallback User-Agent (#274)#411
CoderBoxer wants to merge 1 commit intolinuxmint:masterfrom
CoderBoxer:feature/xtream-user-agent

Conversation

@CoderBoxer
Copy link
Copy Markdown

Overview

This pull request addresses issue #274, where Hypnotix fails to authenticate with certain Xtream API providers because the server rejects requests lacking a standard web browser User-Agent header with a 403 Forbidden error.

Changes

  • Added a module-level fallback HEADERS dictionary containing a standard Chrome/Linux User-Agent string.
  • Implemented a _get_headers() helper method inside the Xtream class.
  • Refactored authenticate() and _get_request() to route through this helper.
  • Safety Mechanism: The logic explicitly checks if self.user_agent is populated. If a user has defined a custom User-Agent via the Hypnotix preferences GUI, that preference is strictly respected. The fallback Chrome header is only applied if the custom setting is empty, preventing the application from sending a default python-requests header and triggering a 403.

Closes #274

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Xtream API - Error 403 (Forbidden) if requests sent without user-agent [with solution]

1 participant