-
Notifications
You must be signed in to change notification settings - Fork 259
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(src/all): New Source: MissAV (#2224)
Co-authored-by: jmir1 <[email protected]>
- Loading branch information
1 parent
0ce5997
commit 5a12d24
Showing
10 changed files
with
532 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,2 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest /> |
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,19 @@ | ||
plugins { | ||
alias(libs.plugins.android.application) | ||
alias(libs.plugins.kotlin.android) | ||
} | ||
|
||
ext { | ||
extName = 'MissAV' | ||
pkgNameSuffix = 'all.missav' | ||
extClass = '.MissAV' | ||
extVersionCode = 1 | ||
containsNsfw = true | ||
} | ||
|
||
dependencies { | ||
implementation(project(':lib-unpacker')) | ||
implementation(project(':lib-playlist-utils')) | ||
} | ||
|
||
apply from: "$rootDir/common.gradle" |
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
165 changes: 165 additions & 0 deletions
165
src/all/missav/src/eu/kanade/tachiyomi/animeextension/all/missav/MissAV.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,165 @@ | ||
package eu.kanade.tachiyomi.animeextension.all.missav | ||
|
||
import android.app.Application | ||
import androidx.preference.ListPreference | ||
import androidx.preference.PreferenceScreen | ||
import eu.kanade.tachiyomi.animesource.ConfigurableAnimeSource | ||
import eu.kanade.tachiyomi.animesource.model.AnimeFilterList | ||
import eu.kanade.tachiyomi.animesource.model.AnimesPage | ||
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.playlistutils.PlaylistUtils | ||
import eu.kanade.tachiyomi.lib.unpacker.Unpacker | ||
import eu.kanade.tachiyomi.network.GET | ||
import eu.kanade.tachiyomi.util.asJsoup | ||
import okhttp3.HttpUrl.Companion.toHttpUrl | ||
import okhttp3.Request | ||
import okhttp3.Response | ||
import rx.Observable | ||
import uy.kohesive.injekt.Injekt | ||
import uy.kohesive.injekt.api.get | ||
|
||
class MissAV : AnimeHttpSource(), ConfigurableAnimeSource { | ||
|
||
override val name = "MissAV" | ||
|
||
override val lang = "all" | ||
|
||
override val baseUrl = "https://missav.com" | ||
|
||
override val supportsLatest = true | ||
|
||
override val client = network.cloudflareClient | ||
|
||
override fun headersBuilder() = super.headersBuilder() | ||
.add("Referer", "$baseUrl/") | ||
|
||
private val playlistExtractor by lazy { | ||
PlaylistUtils(client, headers) | ||
} | ||
|
||
private val preferences by lazy { | ||
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000) | ||
} | ||
|
||
override fun popularAnimeRequest(page: Int) = | ||
GET("$baseUrl/en/today-hot?page=$page", headers) | ||
|
||
override fun popularAnimeParse(response: Response): AnimesPage { | ||
val document = response.asJsoup() | ||
|
||
val entries = document.select("div.thumbnail").map { element -> | ||
SAnime.create().apply { | ||
element.select("a.text-secondary").let { | ||
setUrlWithoutDomain(it.attr("href")) | ||
title = it.text() | ||
} | ||
thumbnail_url = element.selectFirst("img")?.attr("abs:data-src") | ||
} | ||
} | ||
|
||
val hasNextPage = document.selectFirst("a[rel=next]") != null | ||
|
||
return AnimesPage(entries, hasNextPage) | ||
} | ||
|
||
override fun latestUpdatesRequest(page: Int) = | ||
GET("$baseUrl/en/new?page=$page", headers) | ||
|
||
override fun latestUpdatesParse(response: Response) = popularAnimeParse(response) | ||
|
||
override fun searchAnimeRequest(page: Int, query: String, filters: AnimeFilterList): Request { | ||
val url = baseUrl.toHttpUrl().newBuilder().apply { | ||
val genre = filters.firstInstanceOrNull<GenreList>()?.selected | ||
if (query.isNotEmpty()) { | ||
addEncodedPathSegments("en/search") | ||
addPathSegment(query.trim()) | ||
} else if (genre != null) { | ||
addEncodedPathSegments(genre) | ||
} else { | ||
addEncodedPathSegments("en/new") | ||
} | ||
filters.firstInstanceOrNull<SortFilter>()?.selected?.let { | ||
addQueryParameter("sort", it) | ||
} | ||
addQueryParameter("page", page.toString()) | ||
}.build().toString() | ||
|
||
return GET(url, headers) | ||
} | ||
|
||
override fun getFilterList() = getFilters() | ||
|
||
override fun searchAnimeParse(response: Response) = popularAnimeParse(response) | ||
|
||
override fun animeDetailsParse(response: Response): SAnime { | ||
val document = response.asJsoup() | ||
|
||
return SAnime.create().apply { | ||
title = document.select("h1.text-base").text() | ||
genre = document.select("div.text-secondary > a[href*=/genres/]").joinToString { it.text() } | ||
description = document.select("div.mb-1").text() | ||
author = document.select("div.text-secondary > a[href*=/makers/]").joinToString { it.text() } | ||
artist = document.select("div.text-secondary > a[href*=/actresses/]").joinToString { it.text() } | ||
status = SAnime.COMPLETED | ||
thumbnail_url = document.select("video.player").attr("abs:data-poster") | ||
} | ||
} | ||
|
||
override fun fetchEpisodeList(anime: SAnime): Observable<List<SEpisode>> { | ||
return Observable.just( | ||
listOf( | ||
SEpisode.create().apply { | ||
url = anime.url | ||
name = "Episode" | ||
}, | ||
), | ||
) | ||
} | ||
|
||
override fun videoListParse(response: Response): List<Video> { | ||
val document = response.asJsoup() | ||
|
||
val playlists = document.selectFirst("script:containsData(function(p,a,c,k,e,d))")?.html() | ||
?.let(Unpacker::unpack)?.ifEmpty { null } | ||
?: return emptyList() | ||
|
||
val masterPlaylist = playlists.substringAfter("source=\"").substringBefore("\";") | ||
|
||
return playlistExtractor.extractFromHls(masterPlaylist) | ||
} | ||
|
||
override fun List<Video>.sort(): List<Video> { | ||
val quality = preferences.getString(PREF_QUALITY, PREF_QUALITY_DEFAULT)!! | ||
|
||
return this.sortedWith( | ||
compareBy { it.quality.contains(quality) }, | ||
).reversed() | ||
} | ||
|
||
override fun setupPreferenceScreen(screen: PreferenceScreen) { | ||
ListPreference(screen.context).apply { | ||
key = PREF_QUALITY | ||
title = PREF_QUALITY_TITLE | ||
entries = arrayOf("720p", "480p", "360p") | ||
entryValues = arrayOf("720", "480", "360") | ||
setDefaultValue(PREF_QUALITY_DEFAULT) | ||
summary = "%s" | ||
}.also(screen::addPreference) | ||
} | ||
|
||
override fun episodeListParse(response: Response): List<SEpisode> { | ||
throw UnsupportedOperationException("Not Used") | ||
} | ||
|
||
private inline fun <reified T> List<*>.firstInstanceOrNull(): T? = | ||
filterIsInstance<T>().firstOrNull() | ||
|
||
companion object { | ||
private const val PREF_QUALITY = "preferred_quality" | ||
private const val PREF_QUALITY_TITLE = "Preferred quality" | ||
private const val PREF_QUALITY_DEFAULT = "720" | ||
} | ||
} |
Oops, something went wrong.