Skip to content

Commit

Permalink
fix: Fix base64 decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
Claudemirovsky committed Oct 29, 2023
1 parent 8a43c74 commit 0a4fef4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 58 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package eu.kanade.tachiyomi.animeextension.ar.arabanime

import android.app.Application
import android.util.Base64
import androidx.preference.ListPreference
import androidx.preference.PreferenceScreen
import eu.kanade.tachiyomi.animeextension.ar.arabanime.dto.AnimeItem
Expand Down Expand Up @@ -48,13 +49,15 @@ class ArabAnime : ConfigurableAnimeSource, AnimeHttpSource() {
// ============================== Popular ===============================
override fun popularAnimeParse(response: Response): AnimesPage {
val responseJson = json.decodeFromString<PopularAnimeResponse>(response.body.string())
val animeList = responseJson.Shows.map {
val animeJson = json.decodeFromString<AnimeItem>(it.decodeBase64())
SAnime.create().apply {
setUrlWithoutDomain(animeJson.info_src)
title = animeJson.anime_name
thumbnail_url = animeJson.anime_cover_image_url
}
val animeList = responseJson.Shows.mapNotNull {
runCatching {
val animeJson = json.decodeFromString<AnimeItem>(it.decodeBase64())
SAnime.create().apply {
setUrlWithoutDomain(animeJson.info_src)
title = animeJson.anime_name
thumbnail_url = animeJson.anime_cover_image_url
}
}.getOrNull()
}
val hasNextPage = responseJson.current_page < responseJson.last_page
return AnimesPage(animeList, hasNextPage)
Expand Down Expand Up @@ -246,6 +249,8 @@ class ArabAnime : ConfigurableAnimeSource, AnimeHttpSource() {
screen.addPreference(videoQualityPref)
}

private fun String.decodeBase64() = String(Base64.decode(this, Base64.DEFAULT))

companion object {
private const val PREF_QUALITY_KEY = "preferred_quality"
private const val PREF_QUALITY_TITLE = "Preferred quality"
Expand Down

This file was deleted.

0 comments on commit 0a4fef4

Please sign in to comment.