Revert back from using Session Id to Anime Id (#564)
* Improve KwikExtractor Decrypt Function - Optimize and improve performance of KwikExtractor decrypt functionality * Fix issue #550 * Update version * Improve solution for #550 - Revert back to using Anime Id instead of Session Id - Improve `fetchSession` by resolving anime using Anime Id only * Fix lint error
This commit is contained in:
parent
5b33d95e03
commit
b954417a98
3 changed files with 25 additions and 10 deletions
|
@ -1,7 +1,7 @@
|
||||||
ext {
|
ext {
|
||||||
extName = 'AnimePahe'
|
extName = 'AnimePahe'
|
||||||
extClass = '.AnimePahe'
|
extClass = '.AnimePahe'
|
||||||
extVersionCode = 28
|
extVersionCode = 29
|
||||||
}
|
}
|
||||||
|
|
||||||
apply from: "$rootDir/common.gradle"
|
apply from: "$rootDir/common.gradle"
|
||||||
|
|
|
@ -19,6 +19,9 @@ import eu.kanade.tachiyomi.animesource.online.AnimeHttpSource
|
||||||
import eu.kanade.tachiyomi.network.GET
|
import eu.kanade.tachiyomi.network.GET
|
||||||
import eu.kanade.tachiyomi.util.asJsoup
|
import eu.kanade.tachiyomi.util.asJsoup
|
||||||
import eu.kanade.tachiyomi.util.parseAs
|
import eu.kanade.tachiyomi.util.parseAs
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.runBlocking
|
||||||
|
import kotlinx.coroutines.withContext
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
import okhttp3.Headers
|
import okhttp3.Headers
|
||||||
import okhttp3.Request
|
import okhttp3.Request
|
||||||
|
@ -64,7 +67,15 @@ class AnimePahe : ConfigurableAnimeSource, AnimeHttpSource() {
|
||||||
* @see episodeListRequest
|
* @see episodeListRequest
|
||||||
*/
|
*/
|
||||||
override fun animeDetailsRequest(anime: SAnime): Request {
|
override fun animeDetailsRequest(anime: SAnime): Request {
|
||||||
val session = anime.getSession()
|
val animeId = anime.getId()
|
||||||
|
// We're using coroutines here to run it inside another thread and
|
||||||
|
// prevent android.os.NetworkOnMainThreadException when trying to open
|
||||||
|
// webview or share it.
|
||||||
|
val session = runBlocking {
|
||||||
|
withContext(Dispatchers.IO) {
|
||||||
|
fetchSession(animeId)
|
||||||
|
}
|
||||||
|
}
|
||||||
return GET("$baseUrl/anime/$session")
|
return GET("$baseUrl/anime/$session")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,8 +106,8 @@ class AnimePahe : ConfigurableAnimeSource, AnimeHttpSource() {
|
||||||
SAnime.create().apply {
|
SAnime.create().apply {
|
||||||
title = anime.title
|
title = anime.title
|
||||||
thumbnail_url = anime.snapshot
|
thumbnail_url = anime.snapshot
|
||||||
val sessionId = anime.anime_session
|
val animeId = anime.id
|
||||||
setUrlWithoutDomain("/anime/?session_id=$sessionId")
|
setUrlWithoutDomain("/anime/?anime_id=$animeId")
|
||||||
artist = anime.fansub
|
artist = anime.fansub
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,8 +124,8 @@ class AnimePahe : ConfigurableAnimeSource, AnimeHttpSource() {
|
||||||
SAnime.create().apply {
|
SAnime.create().apply {
|
||||||
title = anime.title
|
title = anime.title
|
||||||
thumbnail_url = anime.poster
|
thumbnail_url = anime.poster
|
||||||
val sessionId = anime.session
|
val animeId = anime.id
|
||||||
setUrlWithoutDomain("/anime/?session_id=$sessionId")
|
setUrlWithoutDomain("/anime/?anime_id=$animeId")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return AnimesPage(animeList, false)
|
return AnimesPage(animeList, false)
|
||||||
|
@ -135,7 +146,7 @@ class AnimePahe : ConfigurableAnimeSource, AnimeHttpSource() {
|
||||||
* @see animeDetailsRequest
|
* @see animeDetailsRequest
|
||||||
*/
|
*/
|
||||||
override fun episodeListRequest(anime: SAnime): Request {
|
override fun episodeListRequest(anime: SAnime): Request {
|
||||||
val session = anime.getSession()
|
val session = fetchSession(anime.getId())
|
||||||
return GET("$baseUrl/api?m=release&id=$session&sort=episode_desc&page=1")
|
return GET("$baseUrl/api?m=release&id=$session&sort=episode_desc&page=1")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -299,6 +310,12 @@ class AnimePahe : ConfigurableAnimeSource, AnimeHttpSource() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================= Utilities ==============================
|
// ============================= Utilities ==============================
|
||||||
|
private fun fetchSession(animeId: String): String {
|
||||||
|
val resolveAnimeRequest = client.newCall(GET("$baseUrl/a/$animeId")).execute()
|
||||||
|
val sessionId = resolveAnimeRequest.request.url.pathSegments.last()
|
||||||
|
return sessionId
|
||||||
|
}
|
||||||
|
|
||||||
private fun parseStatus(statusString: String): Int {
|
private fun parseStatus(statusString: String): Int {
|
||||||
return when (statusString) {
|
return when (statusString) {
|
||||||
"Currently Airing" -> SAnime.ONGOING
|
"Currently Airing" -> SAnime.ONGOING
|
||||||
|
@ -307,7 +324,7 @@ class AnimePahe : ConfigurableAnimeSource, AnimeHttpSource() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun SAnime.getSession() = url.substringAfterLast("?session_id=").substringBefore("\"")
|
private fun SAnime.getId() = url.substringAfterLast("?anime_id=").substringBefore("\"")
|
||||||
|
|
||||||
private fun String.toDate(): Long {
|
private fun String.toDate(): Long {
|
||||||
return runCatching {
|
return runCatching {
|
||||||
|
|
|
@ -23,7 +23,6 @@ data class LatestAnimeDto(
|
||||||
@SerialName("anime_id")
|
@SerialName("anime_id")
|
||||||
val id: Int,
|
val id: Int,
|
||||||
val fansub: String,
|
val fansub: String,
|
||||||
val anime_session: String,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
|
@ -31,7 +30,6 @@ data class SearchResultDto(
|
||||||
val title: String,
|
val title: String,
|
||||||
val poster: String,
|
val poster: String,
|
||||||
val id: Int,
|
val id: Int,
|
||||||
val session: String,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue