Skip to content

Commit

Permalink
Fix: Removed myvi, added vido and vk players
Browse files Browse the repository at this point in the history
  • Loading branch information
hollowshiroyuki committed Oct 28, 2023
1 parent 99276a0 commit fbac669
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
5 changes: 3 additions & 2 deletions src/fr/franime/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ ext {
extName = 'FrAnime'
pkgNameSuffix = 'fr.franime'
extClass = '.FrAnime'
extVersionCode = 8
extVersionCode = 9
libVersion = '13'
containsNsfw = true
}

dependencies {
implementation(project(':lib-mytv-extractor'))
implementation(project(':lib-vido-extractor'))
implementation(project(':lib-vk-extractor'))
implementation(project(':lib-sendvid-extractor'))
implementation(project(':lib-sibnet-extractor'))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ import eu.kanade.tachiyomi.animesource.model.SAnime
import eu.kanade.tachiyomi.animesource.model.SEpisode
import eu.kanade.tachiyomi.animesource.model.Video
import eu.kanade.tachiyomi.animesource.online.AnimeHttpSource
import eu.kanade.tachiyomi.lib.mytvextractor.MytvExtractor
import eu.kanade.tachiyomi.lib.sendvidextractor.SendvidExtractor
import eu.kanade.tachiyomi.lib.sibnetextractor.SibnetExtractor
import eu.kanade.tachiyomi.lib.vkextractor.VkExtractor
import eu.kanade.tachiyomi.network.GET
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
import kotlinx.coroutines.awaitAll
import kotlinx.coroutines.runBlocking
import kotlinx.serialization.json.Json
import okhttp3.HttpUrl.Companion.toHttpUrl
import okhttp3.OkHttpClient
Expand Down Expand Up @@ -126,22 +130,26 @@ class FrAnime : AnimeHttpSource() {

val players = if (episodeLang == "vo") episodeData.languages.vo.players else episodeData.languages.vf.players

val videos = players.flatMapIndexed { index, playerName ->
val videos = players.parallelCatchingFlatMapIndexed { index, playerName ->
val apiUrl = "$videoBaseUrl/$episodeLang/$index"
val playerUrl = client.newCall(GET(apiUrl, headers)).execute().body.string()
when (playerName) {
"franime_myvi" -> listOf(Video(playerUrl, "FRAnime", playerUrl))
"myvi" -> MytvExtractor(client).videosFromUrl(playerUrl)
"vido" -> listOf(Video(playerUrl, "FRAnime (Vido)", playerUrl))
"sendvid" -> SendvidExtractor(client, headers).videosFromUrl(playerUrl)
"sibnet" -> SibnetExtractor(client).videosFromUrl(playerUrl)
"vk" -> VkExtractor(client, headers).videosFromUrl(playerUrl)
else -> emptyList()
}
}

return Observable.just(videos)
}

// ============================= Utilities ==============================
private inline fun <A, B> Iterable<A>.parallelCatchingFlatMapIndexed(crossinline f: suspend (Int, A) -> Iterable<B>): List<B> =
runBlocking {
mapIndexed { index, it -> async(Dispatchers.Default) { runCatching { f(index, it) }.getOrElse { emptyList() } } }.awaitAll().flatten()
}

private fun pagesToAnimesPage(pages: List<Anime>, page: Int): Observable<AnimesPage> {
val chunks = pages.chunked(50)
val hasNextPage = chunks.size > page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ private object BigIntegerSerializer : KSerializer<BigInteger> {

@Serializable
data class Anime(
@SerialName("themes") val genres: Array<String>,
@SerialName("saisons") val seasons: Array<Season>,
@SerialName("themes") val genres: List<String>,
@SerialName("saisons") val seasons: List<Season>,
@SerialName("_id") val uid: String?,
@SerialName("id") val id: BigIntegerJson,
@SerialName("source_url") val sourceUrl: String,
Expand All @@ -63,7 +63,7 @@ data class Anime(
@Serializable
data class Season(
@SerialName("title") val title: String,
@SerialName("episodes") val episodes: Array<Episode>,
@SerialName("episodes") val episodes: List<Episode>,
)

@Serializable
Expand All @@ -80,7 +80,7 @@ data class EpisodeLanguages(

@Serializable
data class EpisodeLanguage(
@SerialName("lecteurs") val players: Array<String>,
@SerialName("lecteurs") val players: List<String>,
)

@Serializable
Expand Down

0 comments on commit fbac669

Please sign in to comment.