forked from aniyomiorg/aniyomi-extensions
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
167 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
ext { | ||
extName = 'Animenix' | ||
extClass = '.Animenix' | ||
themePkg = 'dooplay' | ||
baseUrl = 'https://animenix.com' | ||
overrideVersionCode = 1 | ||
} | ||
|
||
apply from: "$rootDir/common.gradle" | ||
|
||
dependencies { | ||
implementation(project(":lib:filemoon-extractor")) | ||
implementation(project(":lib:streamwish-extractor")) | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
153 changes: 153 additions & 0 deletions
153
src/es/animenix/src/eu/kanade/tachiyomi/animeextension/es/animenix/Animenix.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
package eu.kanade.tachiyomi.animeextension.es.animenix | ||
|
||
import androidx.preference.CheckBoxPreference | ||
import androidx.preference.ListPreference | ||
import androidx.preference.PreferenceScreen | ||
import eu.kanade.tachiyomi.animesource.model.Video | ||
import eu.kanade.tachiyomi.lib.filemoonextractor.FilemoonExtractor | ||
import eu.kanade.tachiyomi.lib.streamwishextractor.StreamWishExtractor | ||
import eu.kanade.tachiyomi.multisrc.dooplay.DooPlay | ||
import eu.kanade.tachiyomi.network.GET | ||
import eu.kanade.tachiyomi.network.POST | ||
import eu.kanade.tachiyomi.util.asJsoup | ||
import okhttp3.FormBody | ||
import okhttp3.Response | ||
import org.jsoup.nodes.Document | ||
import org.jsoup.nodes.Element | ||
|
||
class Animenix : DooPlay( | ||
"es", | ||
"Animenix", | ||
"https://animenix.com", | ||
) { | ||
|
||
// ============================== Popular =============================== | ||
override fun popularAnimeRequest(page: Int) = GET("$baseUrl/ratings/$page") | ||
|
||
override fun popularAnimeSelector() = latestUpdatesSelector() | ||
|
||
override fun popularAnimeNextPageSelector() = latestUpdatesNextPageSelector() | ||
|
||
// =============================== Search =============================== | ||
|
||
// ============================== Episodes ============================== | ||
override val episodeMovieText = "Película" | ||
|
||
override fun videoListParse(response: Response): List<Video> { | ||
val players = response.asJsoup().select("li.dooplay_player_option") | ||
return players.flatMap { player -> | ||
runCatching { | ||
val link = getPlayerUrl(player) | ||
getPlayerVideos(link, player, setOf("filemoon", "streamwish", "swdyu")) | ||
}.getOrElse { emptyList() } | ||
} | ||
} | ||
|
||
private fun getPlayerUrl(player: Element): String { | ||
val body = FormBody.Builder() | ||
.add("action", "doo_player_ajax") | ||
.add("post", player.attr("data-post")) | ||
.add("nume", player.attr("data-nume")) | ||
.add("type", player.attr("data-type")) | ||
.build() | ||
return client.newCall(POST("$baseUrl/wp-admin/admin-ajax.php", headers, body)) | ||
.execute() | ||
.let { response -> | ||
response.body.string() | ||
.substringAfter("\"embed_url\":\"") | ||
.substringBefore("\",") | ||
.replace("\\", "") | ||
} | ||
} | ||
|
||
private val filemoonExtractor by lazy { FilemoonExtractor(client) } | ||
private val streamWishExtractor by lazy { StreamWishExtractor(headers = headers, client = client) } | ||
|
||
private fun getPlayerVideos(link: String, element: Element, hosterSelection: Set<String>): List<Video> { | ||
return when { | ||
link.contains("filemoon") -> filemoonExtractor.videosFromUrl(link) | ||
link.contains("swdyu") -> streamWishExtractor.videosFromUrl(link) | ||
|
||
else -> null | ||
}.orEmpty() | ||
} | ||
|
||
// =========================== Anime Details ============================ | ||
override fun Document.getDescription(): String { | ||
return select("$additionalInfoSelector div.wp-content p") | ||
.eachText() | ||
.joinToString("\n") | ||
} | ||
|
||
override val additionalInfoItems = listOf("Título", "Temporadas", "Episodios", "Duración media") | ||
|
||
// =============================== Latest =============================== | ||
|
||
override fun latestUpdatesRequest(page: Int) = GET("$baseUrl/ver/page/$page", headers) | ||
|
||
override fun latestUpdatesNextPageSelector() = "div.pagination > *:last-child:not(span):not(.current)" | ||
|
||
// ============================== Filters =============================== | ||
override val fetchGenres = false | ||
|
||
// ============================== Settings ============================== | ||
override fun setupPreferenceScreen(screen: PreferenceScreen) { | ||
super.setupPreferenceScreen(screen) // Quality preference | ||
|
||
val langPref = ListPreference(screen.context).apply { | ||
key = PREF_LANG_KEY | ||
title = PREF_LANG_TITLE | ||
entries = PREF_LANG_ENTRIES | ||
entryValues = PREF_LANG_VALUES | ||
setDefaultValue(PREF_LANG_DEFAULT) | ||
summary = "%s" | ||
|
||
setOnPreferenceChangeListener { _, newValue -> | ||
val selected = newValue as String | ||
val index = findIndexOfValue(selected) | ||
val entry = entryValues[index] as String | ||
preferences.edit().putString(key, entry).commit() | ||
} | ||
} | ||
|
||
val vrfIterceptPref = CheckBoxPreference(screen.context).apply { | ||
key = PREF_VRF_INTERCEPT_KEY | ||
title = PREF_VRF_INTERCEPT_TITLE | ||
summary = PREF_VRF_INTERCEPT_SUMMARY | ||
setDefaultValue(PREF_VRF_INTERCEPT_DEFAULT) | ||
} | ||
|
||
screen.addPreference(vrfIterceptPref) | ||
screen.addPreference(langPref) | ||
} | ||
|
||
// ============================= Utilities ============================== | ||
override fun String.toDate() = 0L | ||
|
||
override fun List<Video>.sort(): List<Video> { | ||
val quality = preferences.getString(prefQualityKey, prefQualityDefault)!! | ||
val lang = preferences.getString(PREF_LANG_KEY, PREF_LANG_DEFAULT)!! | ||
return sortedWith( | ||
compareBy( | ||
{ it.quality.contains(lang) }, | ||
{ it.quality.contains(quality) }, | ||
), | ||
).reversed() | ||
} | ||
|
||
override val prefQualityValues = arrayOf("480p", "720p", "1080p") | ||
override val prefQualityEntries = prefQualityValues | ||
|
||
companion object { | ||
private const val PREF_LANG_KEY = "preferred_lang" | ||
private const val PREF_LANG_TITLE = "Preferred language" | ||
private const val PREF_LANG_DEFAULT = "SUB" | ||
private val PREF_LANG_ENTRIES = arrayOf("SUB", "All", "ES", "LAT") | ||
private val PREF_LANG_VALUES = arrayOf("SUB", "", "ES", "LAT") | ||
|
||
private const val PREF_VRF_INTERCEPT_KEY = "vrf_intercept" | ||
private const val PREF_VRF_INTERCEPT_TITLE = "Intercept VRF links (Requiere Reiniciar)" | ||
private const val PREF_VRF_INTERCEPT_SUMMARY = "Intercept VRF links and open them in the browser" | ||
private const val PREF_VRF_INTERCEPT_DEFAULT = false | ||
} | ||
} |