iina / iina/plugin-opensub

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

Open
#3 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Vue
Stars
20
Forks
8
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating the OpenSubtitles subtitle-search request used during automatic subtitle search and inspect how its query parameters and redirects are handled. Reproduce the supplied curl requests, then verify that the IINA request avoids the redirect or follows it while preserving the Api-Key and Authorization headers.

Written by the indexing model from the issue text.

Assessment

Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.