forked from AlmightyHak/extensions-source
Merge pull request #277 from Dark25/pinoymoviepedia
Feat(src/en): Add New Source PinoyMoviePedia
This commit is contained in:
commit
402979a37d
8 changed files with 257 additions and 0 deletions
15
src/en/pinoymoviepedia/build.gradle
Normal file
15
src/en/pinoymoviepedia/build.gradle
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
ext {
|
||||||
|
extName = 'PinoyMoviePedia'
|
||||||
|
extClass = '.PinoyMoviePedia'
|
||||||
|
themePkg = 'dooplay'
|
||||||
|
baseUrl = 'https://pinoymoviepedia.ru'
|
||||||
|
overrideVersionCode = 0
|
||||||
|
isNsfw = true
|
||||||
|
}
|
||||||
|
|
||||||
|
apply from: "$rootDir/common.gradle"
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation(project(':lib:mixdrop-extractor'))
|
||||||
|
implementation(project(':lib:dood-extractor'))
|
||||||
|
}
|
BIN
src/en/pinoymoviepedia/res/mipmap-hdpi/ic_launcher.webp
Normal file
BIN
src/en/pinoymoviepedia/res/mipmap-hdpi/ic_launcher.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 6 KiB |
BIN
src/en/pinoymoviepedia/res/mipmap-mdpi/ic_launcher.webp
Normal file
BIN
src/en/pinoymoviepedia/res/mipmap-mdpi/ic_launcher.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.3 KiB |
BIN
src/en/pinoymoviepedia/res/mipmap-xhdpi/ic_launcher.webp
Normal file
BIN
src/en/pinoymoviepedia/res/mipmap-xhdpi/ic_launcher.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.1 KiB |
BIN
src/en/pinoymoviepedia/res/mipmap-xxhdpi/ic_launcher.webp
Normal file
BIN
src/en/pinoymoviepedia/res/mipmap-xxhdpi/ic_launcher.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
BIN
src/en/pinoymoviepedia/res/mipmap-xxxhdpi/ic_launcher.webp
Normal file
BIN
src/en/pinoymoviepedia/res/mipmap-xxxhdpi/ic_launcher.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 25 KiB |
|
@ -0,0 +1,156 @@
|
||||||
|
package eu.kanade.tachiyomi.animeextension.th.pinoymoviepedia
|
||||||
|
|
||||||
|
import androidx.preference.ListPreference
|
||||||
|
import androidx.preference.PreferenceScreen
|
||||||
|
import eu.kanade.tachiyomi.animesource.model.AnimeFilterList
|
||||||
|
import eu.kanade.tachiyomi.animesource.model.Video
|
||||||
|
import eu.kanade.tachiyomi.lib.doodextractor.DoodExtractor
|
||||||
|
import eu.kanade.tachiyomi.lib.mixdropextractor.MixDropExtractor
|
||||||
|
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 eu.kanade.tachiyomi.util.parallelFlatMapBlocking
|
||||||
|
import okhttp3.FormBody
|
||||||
|
import okhttp3.Request
|
||||||
|
import okhttp3.Response
|
||||||
|
import org.jsoup.nodes.Element
|
||||||
|
|
||||||
|
class PinoyMoviePedia : DooPlay(
|
||||||
|
"en",
|
||||||
|
"PinoyMoviePedia",
|
||||||
|
"https://pinoymoviepedia.ru",
|
||||||
|
) {
|
||||||
|
override val supportsLatest = false
|
||||||
|
|
||||||
|
// ============================== Popular ===============================
|
||||||
|
override fun popularAnimeRequest(page: Int) = GET("$baseUrl/ratings/$page")
|
||||||
|
|
||||||
|
override fun popularAnimeSelector() = latestUpdatesSelector()
|
||||||
|
|
||||||
|
override fun popularAnimeNextPageSelector() = latestUpdatesNextPageSelector()
|
||||||
|
|
||||||
|
override fun latestUpdatesRequest(page: Int) = GET("$baseUrl/ano/2024/page/$page", headers)
|
||||||
|
|
||||||
|
override fun videoListSelector() = "li.dooplay_player_option" // ul#playeroptionsul
|
||||||
|
|
||||||
|
override val episodeMovieText = "Movie"
|
||||||
|
|
||||||
|
override val episodeSeasonPrefix = "Season"
|
||||||
|
override val prefQualityTitle = "Preferred quality"
|
||||||
|
|
||||||
|
private val doodExtractor by lazy { DoodExtractor(client) }
|
||||||
|
private val mixDropExtractor by lazy { MixDropExtractor(client) }
|
||||||
|
|
||||||
|
// ============================ Video Links =============================
|
||||||
|
override fun videoListParse(response: Response): List<Video> {
|
||||||
|
val document = response.asJsoup()
|
||||||
|
val players = document.select("ul#playeroptionsul li")
|
||||||
|
return players.parallelFlatMapBlocking { player ->
|
||||||
|
val name = player.selectFirst("span.title")!!.text()
|
||||||
|
val url = getPlayerUrl(player)
|
||||||
|
?: return@parallelFlatMapBlocking emptyList<Video>()
|
||||||
|
extractVideos(url, name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun extractVideos(url: String, lang: String): List<Video> {
|
||||||
|
return when {
|
||||||
|
"dood" in url -> doodExtractor.videosFromUrl(url, lang)
|
||||||
|
"mixdrop" in url -> mixDropExtractor.videosFromUrl(url, lang)
|
||||||
|
else -> null
|
||||||
|
} ?: 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().body.string()
|
||||||
|
.substringAfter("\"embed_url\":\"")
|
||||||
|
.substringBefore("\",")
|
||||||
|
.replace("\\", "")
|
||||||
|
.takeIf(String::isNotBlank)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============================== Filters ===============================
|
||||||
|
override val fetchGenres = false
|
||||||
|
|
||||||
|
override fun getFilterList() = PinoyMoviePediaFilters.FILTER_LIST
|
||||||
|
|
||||||
|
override fun searchAnimeRequest(page: Int, query: String, filters: AnimeFilterList): Request {
|
||||||
|
val params = PinoyMoviePediaFilters.getSearchParameters(filters)
|
||||||
|
val path = when {
|
||||||
|
params.genre.isNotBlank() -> {
|
||||||
|
if (params.genre in listOf("ratings")) {
|
||||||
|
"/${params.genre}"
|
||||||
|
} else {
|
||||||
|
"/genre/${params.genre}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else -> buildString {
|
||||||
|
append(
|
||||||
|
when {
|
||||||
|
query.isNotBlank() -> "/?s=$query"
|
||||||
|
else -> "/"
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return if (path.startsWith("/?s=")) {
|
||||||
|
GET("$baseUrl/page/$page$path")
|
||||||
|
} else {
|
||||||
|
GET("$baseUrl$path/page/$page")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun setupPreferenceScreen(screen: PreferenceScreen) {
|
||||||
|
super.setupPreferenceScreen(screen) // Quality preference
|
||||||
|
|
||||||
|
ListPreference(screen.context).apply {
|
||||||
|
key = PREF_SERVER_KEY
|
||||||
|
title = "Preferred server"
|
||||||
|
entries = SERVER_LIST
|
||||||
|
entryValues = SERVER_LIST
|
||||||
|
setDefaultValue(PREF_SERVER_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()
|
||||||
|
}
|
||||||
|
}.also(screen::addPreference)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============================= Utilities ==============================
|
||||||
|
override fun String.toDate() = 0L
|
||||||
|
|
||||||
|
override fun List<Video>.sort(): List<Video> {
|
||||||
|
val quality = preferences.getString(prefQualityKey, prefQualityDefault)!!
|
||||||
|
val server = preferences.getString(PREF_SERVER_KEY, PREF_SERVER_DEFAULT)!!
|
||||||
|
return sortedWith(
|
||||||
|
compareBy(
|
||||||
|
{ it.quality.contains(lang) },
|
||||||
|
{ it.quality.contains(server, true) },
|
||||||
|
{ it.quality.contains(quality) },
|
||||||
|
),
|
||||||
|
).reversed()
|
||||||
|
}
|
||||||
|
|
||||||
|
override val prefQualityValues = arrayOf("480p", "720p", "1080p")
|
||||||
|
override val prefQualityEntries = prefQualityValues
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private const val PREF_SERVER_KEY = "preferred_server"
|
||||||
|
private const val PREF_SERVER_DEFAULT = "DoodStream"
|
||||||
|
private val SERVER_LIST = arrayOf("DoodStream", "MixDrop")
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,86 @@
|
||||||
|
package eu.kanade.tachiyomi.animeextension.th.pinoymoviepedia
|
||||||
|
|
||||||
|
import eu.kanade.tachiyomi.animesource.model.AnimeFilter
|
||||||
|
import eu.kanade.tachiyomi.animesource.model.AnimeFilterList
|
||||||
|
|
||||||
|
object PinoyMoviePediaFilters {
|
||||||
|
|
||||||
|
open class UriPartFilter(
|
||||||
|
displayName: String,
|
||||||
|
private val vals: Array<Pair<String, String>>,
|
||||||
|
) : AnimeFilter.Select<String>(
|
||||||
|
displayName,
|
||||||
|
vals.map { it.first }.toTypedArray(),
|
||||||
|
) {
|
||||||
|
|
||||||
|
fun toUriPart() = vals[state].second
|
||||||
|
}
|
||||||
|
|
||||||
|
private inline fun <reified R> AnimeFilterList.getFirst(): R {
|
||||||
|
return first { it is R } as R
|
||||||
|
}
|
||||||
|
|
||||||
|
private inline fun <reified R> AnimeFilterList.asUriPart(): String {
|
||||||
|
return getFirst<R>().let {
|
||||||
|
(it as UriPartFilter).toUriPart()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class GenreFilter : UriPartFilter("Genre", AnimesOnlineNinjaData.GENRES)
|
||||||
|
|
||||||
|
private inline fun <reified R> AnimeFilter.Group<UriPartFilter>.getItemUri(): String {
|
||||||
|
return state.first { it is R }.toUriPart()
|
||||||
|
}
|
||||||
|
|
||||||
|
val FILTER_LIST get() = AnimeFilterList(
|
||||||
|
AnimeFilter.Header("These filters do not affect text searches."),
|
||||||
|
GenreFilter(),
|
||||||
|
)
|
||||||
|
|
||||||
|
data class FilterSearchParams(
|
||||||
|
val genre: String = "",
|
||||||
|
)
|
||||||
|
|
||||||
|
internal fun getSearchParameters(filters: AnimeFilterList): FilterSearchParams {
|
||||||
|
if (filters.isEmpty()) return FilterSearchParams()
|
||||||
|
|
||||||
|
return FilterSearchParams(
|
||||||
|
genre = filters.asUriPart<GenreFilter>(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
private object AnimesOnlineNinjaData {
|
||||||
|
val EVERY = Pair("Select Genre", "")
|
||||||
|
|
||||||
|
val GENRES = arrayOf(
|
||||||
|
EVERY,
|
||||||
|
Pair("Fantasy", "fantasy"),
|
||||||
|
Pair("Comedy", "comedy"),
|
||||||
|
Pair("Family", "family"),
|
||||||
|
Pair("Action", "action"),
|
||||||
|
Pair("Drama", "drama"),
|
||||||
|
Pair("Romance", "romance"),
|
||||||
|
Pair("Mystery", "mystery"),
|
||||||
|
Pair("Music", "music"),
|
||||||
|
Pair("Adventure", "adventure"),
|
||||||
|
Pair("Horror", "horror"),
|
||||||
|
Pair("Digitally Restored", "digitally-restored"),
|
||||||
|
Pair("Science Fiction", "science-fiction"),
|
||||||
|
Pair("Pinay Sexy Movies", "pinay-sexy-movies"),
|
||||||
|
Pair("Crime", "crime"),
|
||||||
|
Pair("Thriller", "thriller"),
|
||||||
|
Pair("History", "history"),
|
||||||
|
Pair("Documentary", "documentary"),
|
||||||
|
Pair("Biography", "biography"),
|
||||||
|
Pair("Animation", "animation"),
|
||||||
|
Pair("War", "war"),
|
||||||
|
Pair("Musical", "musical"),
|
||||||
|
Pair("Indie", "indie"),
|
||||||
|
Pair("LGBT", "lgbt"),
|
||||||
|
Pair("Concert", "concert"),
|
||||||
|
Pair("Short Movie", "short-movie"),
|
||||||
|
Pair("2022", "2022"),
|
||||||
|
Pair("Tagalog Dubbed", "tagalog-dubbed"),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue