Skip to content

Commit

Permalink
feat(hi/yomovies): Add Minoplres extractor (#2256)
Browse files Browse the repository at this point in the history
  • Loading branch information
Claudemirovsky authored Sep 25, 2023
1 parent fe94803 commit 98c2c7c
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 11 deletions.
8 changes: 5 additions & 3 deletions src/hi/yomovies/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
}

ext {
extName = 'YoMovies'
pkgNameSuffix = 'hi.yomovies'
extClass = '.YoMovies'
extVersionCode = 2
extVersionCode = 3
libVersion = '13'
containsNsfw = true
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package eu.kanade.tachiyomi.animeextension.hi.yomovies

import android.app.Application
import android.content.SharedPreferences
import android.widget.Toast
import androidx.preference.EditTextPreference
import androidx.preference.ListPreference
import androidx.preference.PreferenceScreen
import eu.kanade.tachiyomi.AppInfo
import eu.kanade.tachiyomi.animeextension.hi.yomovies.extractors.MinoplresExtractor
import eu.kanade.tachiyomi.animeextension.hi.yomovies.extractors.MovembedExtractor
import eu.kanade.tachiyomi.animeextension.hi.yomovies.extractors.SpeedostreamExtractor
import eu.kanade.tachiyomi.animesource.ConfigurableAnimeSource
Expand Down Expand Up @@ -44,7 +44,7 @@ class YoMovies : ConfigurableAnimeSource, ParsedAnimeHttpSource() {

override val client: OkHttpClient = network.cloudflareClient

private val preferences: SharedPreferences by lazy {
private val preferences by lazy {
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
}

Expand Down Expand Up @@ -108,7 +108,7 @@ class YoMovies : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
// ============================== Episodes ==============================

override fun episodeListParse(response: Response): List<SEpisode> {
val document = response.asJsoup()
val document = response.use { it.asJsoup() }
val episodeList = mutableListOf<SEpisode>()

val seasonList = document.select("div#seasons > div.tvseason")
Expand Down Expand Up @@ -149,7 +149,7 @@ class YoMovies : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
// ============================ Video Links =============================

override fun videoListParse(response: Response): List<Video> {
val document = response.asJsoup()
val document = response.use { it.asJsoup() }

val videoList = document.select("div[id*=tab]:has(div.movieplay > iframe)").parallelMap { server ->
val iframe = server.selectFirst("div.movieplay > iframe")!!
Expand All @@ -176,6 +176,10 @@ class YoMovies : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
iframeUrl.contains("movembed.cc") -> {
MovembedExtractor(client, headers).videosFromUrl(iframeUrl)
}

iframeUrl.contains("minoplres") -> {
MinoplresExtractor(client, headers).videosFromUrl(iframeUrl, name)
}
else -> emptyList()
}
}
Expand All @@ -202,7 +206,7 @@ class YoMovies : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
override fun List<Video>.sort(): List<Video> {
val quality = preferences.getString(PREF_QUALITY_KEY, PREF_QUALITY_DEFAULT)!!

return this.sortedWith(
return sortedWith(
compareBy(
{ it.quality.contains(quality) },
{ Regex("""(\d+)p""").find(it.quality)?.groupValues?.get(1)?.toIntOrNull() ?: 0 },
Expand All @@ -211,15 +215,15 @@ class YoMovies : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
}

// From Dopebox
private fun <A, B> Iterable<A>.parallelMap(f: suspend (A) -> B): List<B> =
private inline fun <A, B> Iterable<A>.parallelMap(crossinline f: suspend (A) -> B): List<B> =
runBlocking {
map { async(Dispatchers.Default) { f(it) } }.awaitAll()
}

companion object {
private val PREF_DOMAIN_KEY = "preferred_domain_name_v${AppInfo.getVersionName()}"
private const val PREF_DOMAIN_TITLE = "Override BaseUrl"
private const val PREF_DOMAIN_DEFAULT = "https://yomovies.baby"
private const val PREF_DOMAIN_DEFAULT = "https://yomovies.cheap"
private const val PREF_DOMAIN_SUMMARY = "For temporary uses. Updating the extension will erase this setting."

private const val PREF_QUALITY_KEY = "preferred_quality"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package eu.kanade.tachiyomi.animeextension.hi.yomovies.extractors

import eu.kanade.tachiyomi.animesource.model.Video
import eu.kanade.tachiyomi.lib.playlistutils.PlaylistUtils
import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.util.asJsoup
import okhttp3.Headers
import okhttp3.OkHttpClient

class MinoplresExtractor(private val client: OkHttpClient, private val headers: Headers) {
private val playlistUtils by lazy { PlaylistUtils(client, headers) }

fun videosFromUrl(url: String, name: String): List<Video> {
val newHeaders = headers.newBuilder().set("Referer", url).build()
val doc = client.newCall(GET(url, newHeaders)).execute()
.use { it.asJsoup() }
val script = doc.selectFirst("script:containsData(sources:)")?.data()
?: return emptyList()

val masterUrl = script.substringAfter("file:\"").substringBefore('"')
return playlistUtils.extractFromHls(
masterUrl,
referer = url,
videoNameGen = { "$name Minoplres - $it" },
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class MovembedExtractor(private val client: OkHttpClient, private val headers: H
}

// From Dopebox
private fun <A, B> Iterable<A>.parallelMap(f: suspend (A) -> B): List<B> =
private inline fun <A, B> Iterable<A>.parallelMap(crossinline f: suspend (A) -> B): List<B> =
runBlocking {
map { async(Dispatchers.Default) { f(it) } }.awaitAll()
}
Expand Down

0 comments on commit 98c2c7c

Please sign in to comment.