Skip to content

IINA's OpenSubtitles integration fails with "Invalid domain" error due to improper redirect handling #3

@opensubtitlesdev

Description

@opensubtitlesdev

Description:

IINA's built-in OpenSubtitles integration is failing to retrieve subtitles when logged in as a VIP user, producing an "Invalid domain" (401) error.

Root Cause:

The OpenSubtitles API enforces alphabetical ordering of query parameters and returns a 301 redirect when they're out of order. IINA's HTTP client either:

  1. Does not follow redirects, OR
  2. Follows redirects but loses authentication headers or changes the domain incorrectly

Steps to Reproduce:

  1. Log into OpenSubtitles with a VIP account in IINA
  2. Play any video file
  3. Trigger automatic subtitle search
  4. Check Console logs

Actual Behavior:

[opensubapi][d] Request: {
"url" : "https://vip-api.opensubtitles.com/api/v1/subtitles?languages=en&moviehash=413142fb64bcd269&query=Frozen.2013.1080p.BluRay.x264.YIFY",
"httpMethod" : "GET"
}
[opensubapi][d] HTTP response status code: 401 unauthorized
[opensubapi][d] Response: {
"errors" : ["Invalid domain"],
"status" : 401
}

Expected Behavior:

The request should either:

  1. Send parameters in strict alphabetical order (case-insensitive) to avoid the redirect, OR
  2. Follow the 301 redirect while preserving all headers (especially Authorization and Api-Key)

Technical Details:

Testing with curl confirms the issue:

Without following redirects (fails):
curl -v 'https://vip-api.opensubtitles.com/api/v1/subtitles?query=frozen&moviehash=abc123'
--header 'Api-Key: xxx'
--header 'Authorization: Bearer xxx'

Returns: HTTP/2 301

Location: /api/v1/subtitles?moviehash=abc123&query=frozen

(parameters reordered alphabetically)

With redirect following (works):
curl -L 'https://vip-api.opensubtitles.com/api/v1/subtitles?query=frozen&moviehash=abc123'
--header 'Api-Key: xxx'
--header 'Authorization: Bearer xxx'

Returns: HTTP/2 200 (success)

Proposed Solutions:

  1. Best practice: Sort query parameters alphabetically (case-insensitive) before making the request to avoid redirects entirely
  2. Fallback: Ensure IINA's HTTP client follows 301/302 redirects while preserving all headers

Environment:

  • IINA version: 1.4.1
  • macOS version: 26.0.1
  • OpenSubtitles account: VIP member

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions