Description
When a plugin sets requestModifier on a VideoUrlSource or HLSSource, GrayJay sets requiresCustomDatasource = true (in JSSource.kt), which switches to JSHttpDataSource using Java's HttpURLConnection. This breaks OK.ru's CDN (okcdn.ru) which rejects or mishandles requests from HttpURLConnection.
This means:
- Adding
requestModifier with headers breaks local playback entirely
- Using
impersonateTarget (curl-impersonate) also triggers JSHttpDataSource if httpimp is available on the device
- The only way to make OK.ru work is to NOT use
requestModifier at all (like YouTube plugin does)
- But without
requestModifier, Cast doesn't work because Chromecast needs the Referer header
Expected behavior
requestModifier should not force JSHttpDataSource for all requests. Local playback should continue using the default HTTP client, while only Cast proxy requests should use the custom datasource. Or provide an option like requiresCustomDatasource = false on the source.
Steps to reproduce
- Use any OK.ru plugin with
requestModifier on sources
- Local playback breaks (CDN returns 403 or connection fails)
- Remove
requestModifier → local playback works but Cast fails
Analysis
In JSSource.kt: requiresCustomDatasource = hasRequestModifier || hasRequestExecutor. This is too aggressive — it should only apply the custom datasource for Cast proxy, not for local playback.
Suggestion
- Option A: Only use
JSHttpDataSource for Cast proxy, not local playback
- Option B: Add a
useCustomDataSourceOnlyForCast flag
- Option C: Allow plugins to set
requiresCustomDatasource = false explicitly
Plugin affected
OK.ru plugin (unofficial) and any other plugin where CDN requires headers but HttpURLConnection breaks the connection.
Description
When a plugin sets
requestModifieron aVideoUrlSourceorHLSSource, GrayJay setsrequiresCustomDatasource = true(inJSSource.kt), which switches toJSHttpDataSourceusing Java'sHttpURLConnection. This breaks OK.ru's CDN (okcdn.ru) which rejects or mishandles requests fromHttpURLConnection.This means:
requestModifierwith headers breaks local playback entirelyimpersonateTarget(curl-impersonate) also triggersJSHttpDataSourceifhttpimpis available on the devicerequestModifierat all (like YouTube plugin does)requestModifier, Cast doesn't work because Chromecast needs the Referer headerExpected behavior
requestModifiershould not forceJSHttpDataSourcefor all requests. Local playback should continue using the default HTTP client, while only Cast proxy requests should use the custom datasource. Or provide an option likerequiresCustomDatasource = falseon the source.Steps to reproduce
requestModifieron sourcesrequestModifier→ local playback works but Cast failsAnalysis
In
JSSource.kt:requiresCustomDatasource = hasRequestModifier || hasRequestExecutor. This is too aggressive — it should only apply the custom datasource for Cast proxy, not for local playback.Suggestion
JSHttpDataSourcefor Cast proxy, not local playbackuseCustomDataSourceOnlyForCastflagrequiresCustomDatasource = falseexplicitlyPlugin affected
OK.ru plugin (unofficial) and any other plugin where CDN requires headers but
HttpURLConnectionbreaks the connection.