Skip to content

Commit f620b24

Browse files
Allow user to watch restricted stream (#553)
* Allow user to watch restricted stream * fixes --------- Co-authored-by: vadym <)> Co-authored-by: crackededed <[email protected]>
1 parent 95c40b8 commit f620b24

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

app/src/main/java/com/github/andreyasadchy/xtra/repository/PlayerRepository.kt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,11 @@ class PlayerRepository @Inject constructor(
5858
}
5959

6060
suspend fun loadStreamPlaylistUrl(gqlHeaders: Map<String, String>, channelLogin: String, randomDeviceId: Boolean?, xDeviceId: String?, playerType: String?, supportedCodecs: String?, proxyPlaybackAccessToken: Boolean, proxyHost: String?, proxyPort: Int?, proxyUser: String?, proxyPassword: String?, enableIntegrity: Boolean): String = withContext(Dispatchers.IO) {
61-
val accessToken = loadStreamPlaybackAccessToken(gqlHeaders, channelLogin, randomDeviceId, xDeviceId, playerType, proxyPlaybackAccessToken, proxyHost, proxyPort, proxyUser, proxyPassword, enableIntegrity)?.data?.streamPlaybackAccessToken
61+
val accessToken = loadStreamPlaybackAccessToken(gqlHeaders, channelLogin, randomDeviceId, xDeviceId, playerType, proxyPlaybackAccessToken, proxyHost, proxyPort, proxyUser, proxyPassword, enableIntegrity)?.data?.streamPlaybackAccessToken?.let { token ->
62+
if (token.value?.contains("\"forbidden\":true") == true && !gqlHeaders[C.HEADER_TOKEN].isNullOrBlank()) {
63+
loadStreamPlaybackAccessToken(gqlHeaders.filterNot { it.key == C.HEADER_TOKEN }, channelLogin, randomDeviceId, xDeviceId, playerType, proxyPlaybackAccessToken, proxyHost, proxyPort, proxyUser, proxyPassword, enableIntegrity)?.data?.streamPlaybackAccessToken
64+
} else token
65+
}
6266
buildUrl(
6367
"https://usher.ttvnw.net/api/channel/hls/$channelLogin.m3u8?",
6468
"allow_source", "true",
@@ -73,7 +77,11 @@ class PlayerRepository @Inject constructor(
7377
}
7478

7579
suspend fun loadStreamPlaylist(gqlHeaders: Map<String, String>, channelLogin: String, randomDeviceId: Boolean?, xDeviceId: String?, playerType: String?, supportedCodecs: String?, enableIntegrity: Boolean): String? = withContext(Dispatchers.IO) {
76-
val accessToken = loadStreamPlaybackAccessToken(gqlHeaders, channelLogin, randomDeviceId, xDeviceId, playerType, false, null, null, null, null, enableIntegrity)?.data?.streamPlaybackAccessToken
80+
val accessToken = loadStreamPlaybackAccessToken(gqlHeaders, channelLogin, randomDeviceId, xDeviceId, playerType, false, null, null, null, null, enableIntegrity)?.data?.streamPlaybackAccessToken?.let { token ->
81+
if (token.value?.contains("\"forbidden\":true") == true && !gqlHeaders[C.HEADER_TOKEN].isNullOrBlank()) {
82+
loadStreamPlaybackAccessToken(gqlHeaders.filterNot { it.key == C.HEADER_TOKEN }, channelLogin, randomDeviceId, xDeviceId, playerType, false, null, null, null, null, enableIntegrity)?.data?.streamPlaybackAccessToken
83+
} else token
84+
}
7785
val playlistQueryOptions = HashMap<String, String>().apply {
7886
put("allow_source", "true")
7987
put("allow_audio_only", "true")

0 commit comments

Comments
 (0)