Skip to content

Commit

Permalink
fix: response bodies weren't closed
Browse files Browse the repository at this point in the history
  • Loading branch information
rhenwinch committed Feb 5, 2024
1 parent f5301b2 commit 97a468b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class FlixHQ(client: OkHttpClient) : Provider(client) {
)
).execute()

response.body?.charStream().asString()?.let { data ->
response.body?.string()?.let { data ->
val doc = Jsoup.parse(data)
val navSelector = "div.pre-pagination:nth-child(3) > nav:nth-child(1) > ul:nth-child(1)"
searchResult = searchResult.copy(
Expand Down Expand Up @@ -93,7 +93,7 @@ class FlixHQ(client: OkHttpClient) : Provider(client) {
)

val response = client.newCall(GET(filmIdToUse)).execute()
val data = response.body?.charStream().asString()
val data = response.body?.string()

if (data != null) {
val doc = Jsoup.parse(data)
Expand Down Expand Up @@ -143,7 +143,7 @@ class FlixHQ(client: OkHttpClient) : Provider(client) {
if (tvCacheData.seasons == null || !isSameId) {
val responseSeasons =
client.newCall(GET(ajaxReqUrl(filmIdToUse, "tv", true))).execute()
val dataSeasons = responseSeasons.body?.charStream().asString()
val dataSeasons = responseSeasons.body?.string()
?: throw Exception("Failed to fetch season data from provider")

val seasonsDoc = Jsoup.parse(dataSeasons)
Expand Down Expand Up @@ -209,7 +209,7 @@ class FlixHQ(client: OkHttpClient) : Provider(client) {
}

val response = client.newCall(GET(fetchServerUrl)).execute()
val data = response.body?.charStream().asString()
val data = response.body?.string()

if (data != null) {
val doc = Jsoup.parse(data)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import com.flixclusive.core.util.coroutines.asyncCalls
import com.flixclusive.core.util.film.FilmType
import com.flixclusive.core.util.json.fromJson
import com.flixclusive.core.util.network.GET
import com.flixclusive.core.util.network.asString
import com.flixclusive.model.provider.SourceLink
import com.flixclusive.model.provider.Subtitle
import com.flixclusive.model.provider.SubtitleSource
Expand Down Expand Up @@ -37,8 +36,7 @@ class LookMovie(client: OkHttpClient) : Provider(client) {

val data = client.newCall(uri).execute()
.body
?.charStream()
?.asString()
?.string()
?: throw Exception("Error searching on LookMovie")

return fromJson<LookMovieSearchResponse>(data).toSearchResponse()
Expand Down Expand Up @@ -75,8 +73,7 @@ class LookMovie(client: OkHttpClient) : Provider(client) {
)
).execute()
.body
?.charStream()
?.asString()
?.string()
?: throw Exception("Error getting $mediaIdToUse data from LookMovie")

val data = fromJson<LookMovieMediaDetail>(response)
Expand Down Expand Up @@ -110,8 +107,7 @@ class LookMovie(client: OkHttpClient) : Provider(client) {
)
).execute()
.body
?.charStream()
?.asString()
?.string()
?: throw Exception("Error getting $mediaId from LookMovie")

return fromJson<LookMovieMediaDetail>(data)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import com.flixclusive.core.util.film.FilmType
import com.flixclusive.core.util.json.fromJson
import com.flixclusive.core.util.network.CryptographyUtil.base64Encode
import com.flixclusive.core.util.network.POST
import com.flixclusive.core.util.network.asString
import com.flixclusive.model.provider.SourceLink
import com.flixclusive.model.provider.Subtitle
import com.flixclusive.model.provider.SubtitleSource
Expand Down Expand Up @@ -93,8 +92,7 @@ class SuperStream(

val responseBody = response
.body
?.charStream()
?.asString()
?.string()
?: throw Exception(errorMessage + " [${response.code} - ${response.message}]")

if(
Expand Down

0 comments on commit 97a468b

Please sign in to comment.