fix(de/streamcloud): Fix video extractor (#2463)
This commit is contained in:
@ -1,17 +1,20 @@
|
|||||||
apply plugin: 'com.android.application'
|
plugins {
|
||||||
apply plugin: 'kotlin-android'
|
alias(libs.plugins.android.application)
|
||||||
apply plugin: 'kotlinx-serialization'
|
alias(libs.plugins.kotlin.android)
|
||||||
|
}
|
||||||
|
|
||||||
ext {
|
ext {
|
||||||
extName = 'StreamCloud'
|
extName = 'StreamCloud'
|
||||||
pkgNameSuffix = 'de.streamcloud'
|
pkgNameSuffix = 'de.streamcloud'
|
||||||
extClass = '.StreamCloud'
|
extClass = '.StreamCloud'
|
||||||
extVersionCode = 5
|
extVersionCode = 6
|
||||||
libVersion = '13'
|
libVersion = '13'
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(project(':lib-dood-extractor'))
|
implementation(project(':lib-dood-extractor'))
|
||||||
|
implementation(project(':lib-streamtape-extractor'))
|
||||||
|
implementation(project(':lib-mixdrop-extractor'))
|
||||||
}
|
}
|
||||||
|
|
||||||
apply from: "$rootDir/common.gradle"
|
apply from: "$rootDir/common.gradle"
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package eu.kanade.tachiyomi.animeextension.de.streamcloud
|
package eu.kanade.tachiyomi.animeextension.de.streamcloud
|
||||||
|
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
import android.content.SharedPreferences
|
|
||||||
import androidx.preference.ListPreference
|
import androidx.preference.ListPreference
|
||||||
import androidx.preference.MultiSelectListPreference
|
import androidx.preference.MultiSelectListPreference
|
||||||
import androidx.preference.PreferenceScreen
|
import androidx.preference.PreferenceScreen
|
||||||
@ -12,11 +11,10 @@ import eu.kanade.tachiyomi.animesource.model.SEpisode
|
|||||||
import eu.kanade.tachiyomi.animesource.model.Video
|
import eu.kanade.tachiyomi.animesource.model.Video
|
||||||
import eu.kanade.tachiyomi.animesource.online.ParsedAnimeHttpSource
|
import eu.kanade.tachiyomi.animesource.online.ParsedAnimeHttpSource
|
||||||
import eu.kanade.tachiyomi.lib.doodextractor.DoodExtractor
|
import eu.kanade.tachiyomi.lib.doodextractor.DoodExtractor
|
||||||
|
import eu.kanade.tachiyomi.lib.mixdropextractor.MixDropExtractor
|
||||||
|
import eu.kanade.tachiyomi.lib.streamtapeextractor.StreamTapeExtractor
|
||||||
import eu.kanade.tachiyomi.network.GET
|
import eu.kanade.tachiyomi.network.GET
|
||||||
import eu.kanade.tachiyomi.util.asJsoup
|
import eu.kanade.tachiyomi.util.asJsoup
|
||||||
import okhttp3.Headers
|
|
||||||
import okhttp3.OkHttpClient
|
|
||||||
import okhttp3.Request
|
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import org.jsoup.nodes.Document
|
import org.jsoup.nodes.Document
|
||||||
import org.jsoup.nodes.Element
|
import org.jsoup.nodes.Element
|
||||||
@ -28,140 +26,125 @@ class StreamCloud : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||||||
|
|
||||||
override val name = "StreamCloud"
|
override val name = "StreamCloud"
|
||||||
|
|
||||||
override val baseUrl = "https://streamcloud.cam"
|
override val baseUrl = "https://streamcloud.movie"
|
||||||
|
|
||||||
override val lang = "de"
|
override val lang = "de"
|
||||||
|
|
||||||
override val supportsLatest = false
|
override val supportsLatest = false
|
||||||
|
|
||||||
override val client: OkHttpClient = network.cloudflareClient
|
override val client = network.cloudflareClient
|
||||||
|
|
||||||
private val preferences: SharedPreferences by lazy {
|
private val preferences by lazy {
|
||||||
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
|
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun popularAnimeSelector(): String = "#dle-content div.item"
|
// ============================== Popular ===============================
|
||||||
|
override fun popularAnimeRequest(page: Int) = GET("$baseUrl/beliebte-filme/")
|
||||||
|
|
||||||
override fun popularAnimeRequest(page: Int): Request = GET("$baseUrl/beliebte-filme/")
|
override fun popularAnimeSelector() = "div#dle-content > div.item > div.thumb > a"
|
||||||
|
|
||||||
override fun popularAnimeFromElement(element: Element): SAnime {
|
override fun popularAnimeFromElement(element: Element) = SAnime.create().apply {
|
||||||
val anime = SAnime.create()
|
setUrlWithoutDomain(element.attr("href"))
|
||||||
anime.setUrlWithoutDomain(element.select("div.thumb a").attr("href"))
|
element.selectFirst("img")!!.run {
|
||||||
anime.thumbnail_url = baseUrl + element.select("div.thumb a img").attr("src")
|
thumbnail_url = absUrl("src")
|
||||||
anime.title = element.select("div.thumb a img").attr("alt")
|
title = attr("alt")
|
||||||
return anime
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun popularAnimeNextPageSelector(): String? = null
|
override fun popularAnimeNextPageSelector() = null
|
||||||
|
|
||||||
// episodes
|
// =============================== Latest ===============================
|
||||||
|
override fun latestUpdatesNextPageSelector() = throw Exception("Not used")
|
||||||
|
|
||||||
|
override fun latestUpdatesFromElement(element: Element) = throw Exception("Not used")
|
||||||
|
|
||||||
|
override fun latestUpdatesRequest(page: Int) = throw Exception("Not used")
|
||||||
|
|
||||||
|
override fun latestUpdatesSelector() = throw Exception("Not used")
|
||||||
|
|
||||||
|
// =============================== Search ===============================
|
||||||
|
override fun searchAnimeRequest(page: Int, query: String, filters: AnimeFilterList) =
|
||||||
|
GET("$baseUrl/index.php?do=search&subaction=search&search_start=$page&full_search=0&story=$query")
|
||||||
|
|
||||||
|
override fun searchAnimeSelector() = popularAnimeSelector()
|
||||||
|
|
||||||
|
override fun searchAnimeFromElement(element: Element) = popularAnimeFromElement(element)
|
||||||
|
|
||||||
|
override fun searchAnimeNextPageSelector() = "#nextlink"
|
||||||
|
|
||||||
|
// =========================== Anime Details ============================
|
||||||
|
override fun animeDetailsParse(document: Document) = SAnime.create().apply {
|
||||||
|
title = document.selectFirst("#title span.title")!!.text()
|
||||||
|
status = SAnime.COMPLETED
|
||||||
|
with(document.selectFirst("div#longInfo")!!) {
|
||||||
|
thumbnail_url = selectFirst("img")?.absUrl("src")
|
||||||
|
genre = selectFirst("span.masha_index10")?.let {
|
||||||
|
it.text().split("/").joinToString()
|
||||||
|
}
|
||||||
|
description = select("#storyline > span > p").eachText().joinToString("\n")
|
||||||
|
author = selectFirst("strong:contains(Regie:) + div > a")?.text()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============================== Episodes ==============================
|
||||||
|
override fun episodeListParse(response: Response): List<SEpisode> {
|
||||||
|
val document = response.use { it.asJsoup() }
|
||||||
|
val episode = SEpisode.create().apply {
|
||||||
|
name = document.selectFirst("#title span.title")!!.text()
|
||||||
|
episode_number = 1F
|
||||||
|
setUrlWithoutDomain(document.location())
|
||||||
|
}
|
||||||
|
return listOf(episode)
|
||||||
|
}
|
||||||
|
|
||||||
override fun episodeListSelector() = throw Exception("not used")
|
override fun episodeListSelector() = throw Exception("not used")
|
||||||
|
|
||||||
override fun episodeListParse(response: Response): List<SEpisode> {
|
|
||||||
val document = response.asJsoup()
|
|
||||||
val episodeList = mutableListOf<SEpisode>()
|
|
||||||
val episode = SEpisode.create()
|
|
||||||
episode.name = document.select("#title span.title").text()
|
|
||||||
episode.episode_number = 1F
|
|
||||||
episode.setUrlWithoutDomain(document.select("meta[property=\"og:url\"]").attr("content"))
|
|
||||||
episodeList.add(episode)
|
|
||||||
return episodeList.reversed()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun episodeListRequest(anime: SAnime): Request {
|
|
||||||
return GET(baseUrl + anime.url, headers = Headers.headersOf("if-modified-since", ""))
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun episodeFromElement(element: Element): SEpisode = throw Exception("not used")
|
override fun episodeFromElement(element: Element): SEpisode = throw Exception("not used")
|
||||||
|
|
||||||
// Video Extractor
|
// ============================ Video Links =============================
|
||||||
|
private val streamtapeExtractor by lazy { StreamTapeExtractor(client) }
|
||||||
override fun videoListRequest(episode: SEpisode): Request {
|
private val doodExtractor by lazy { DoodExtractor(client) }
|
||||||
return GET(baseUrl + episode.url, headers = Headers.headersOf("if-modified-since", ""))
|
private val mixdropExtractor by lazy { MixDropExtractor(client) }
|
||||||
}
|
|
||||||
|
|
||||||
override fun videoListParse(response: Response): List<Video> {
|
override fun videoListParse(response: Response): List<Video> {
|
||||||
val document = response.asJsoup()
|
val document = response.use { it.asJsoup() }
|
||||||
return videosFromElement(document)
|
val iframeurl = document.selectFirst("div.player-container-wrap > iframe")
|
||||||
}
|
?.attr("src")
|
||||||
|
?: error("No videos!")
|
||||||
|
val iframeDoc = client.newCall(GET(iframeurl)).execute().use { it.asJsoup() }
|
||||||
|
|
||||||
private fun videosFromElement(document: Document): List<Video> {
|
val hosterSelection = preferences.getStringSet(PREF_HOSTER_SELECTION_KEY, PREF_HOSTER_SELECTION_DEFAULT)!!
|
||||||
val videoList = mutableListOf<Video>()
|
val items = iframeDoc.select("div._player ul._player-mirrors li")
|
||||||
val iframeurl = document.select("div.embed-responsive-item.player-container-wrap iframe").attr("src")
|
|
||||||
val iframedoc = client.newCall(GET(iframeurl, headers = Headers.headersOf("if-modified-since", ""))).execute().asJsoup()
|
|
||||||
val lis = iframedoc.select("div._player ul._player-mirrors li")
|
|
||||||
val hosterSelection = preferences.getStringSet("hoster_selection", setOf("stape", "dood"))
|
|
||||||
for (li in lis) {
|
|
||||||
when {
|
|
||||||
li.text().contains("streamtape.com") && hosterSelection?.contains("stape") == true -> {
|
|
||||||
val url = li.attr("data-link")
|
|
||||||
runCatching {
|
|
||||||
with(
|
|
||||||
client.newCall(GET(url, headers = Headers.headersOf("Referer", baseUrl, "Cookie", "Fuck Streamtape because they add concatenation to fuck up scrapers")))
|
|
||||||
.execute().asJsoup(),
|
|
||||||
) {
|
|
||||||
linkRegex.find(this.select("script:containsData(document.getElementById('robotlink'))").toString())?.let {
|
|
||||||
val quality = "Streamtape"
|
|
||||||
val id = it.groupValues[1].replace("%27+%20(%27xcdb", "")
|
|
||||||
val videoUrl = "https://streamtape.com/get_video?$id&stream=1".replace("""" + '""", "")
|
|
||||||
videoList.add(Video(videoUrl, quality, videoUrl))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
li.text().contains("doodstream.com") && hosterSelection?.contains("dood") == true -> {
|
return items.flatMap { element ->
|
||||||
val quality = "Doodstream"
|
val url = element.attr("data-link").run {
|
||||||
val link = "https:" + li.attr("data-link")
|
takeIf { startsWith("https") }
|
||||||
val video = DoodExtractor(client).videoFromUrl(link, quality, false)
|
?: "https:$this"
|
||||||
if (video != null) {
|
|
||||||
videoList.add(video)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
runCatching {
|
||||||
|
when {
|
||||||
|
url.contains("streamtape") && hosterSelection.contains("stape") -> {
|
||||||
|
streamtapeExtractor.videosFromUrl(url)
|
||||||
|
}
|
||||||
|
url.startsWith("https://dood") && hosterSelection.contains("dood") -> {
|
||||||
|
doodExtractor.videosFromUrl(url)
|
||||||
|
}
|
||||||
|
url.contains("mixdrop.") && hosterSelection.contains("mixdrop") -> {
|
||||||
|
mixdropExtractor.videosFromUrl(url)
|
||||||
|
}
|
||||||
|
else -> emptyList()
|
||||||
|
}
|
||||||
|
}.getOrElse { emptyList() }
|
||||||
}
|
}
|
||||||
|
|
||||||
return videoList
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private val linkRegex =
|
|
||||||
Regex("""(i(|" \+ ')d(|" \+ ')=.*?&(|" \+ ')e(|" \+ ')x(|" \+ ')p(|" \+ ')i(|" \+ ')r(|" \+ ')e(|" \+ ')s(|" \+ ')=.*?&(|" \+ ')i(|" \+ ')p(|" \+ ')=.*?&(|" \+ ')t(|" \+ ')o(|" \+ ')k(|" \+ ')e(|" \+ ')n(|" \+ ')=.*)'""")
|
|
||||||
|
|
||||||
override fun List<Video>.sort(): List<Video> {
|
override fun List<Video>.sort(): List<Video> {
|
||||||
val hoster = preferences.getString("preferred_hoster", "Streamtape")
|
val hoster = preferences.getString(PREF_HOSTER_KEY, PREF_HOSTER_DEFAULT)!!
|
||||||
val hosterList = mutableListOf<Video>()
|
|
||||||
val otherList = mutableListOf<Video>()
|
return sortedWith(
|
||||||
if (hoster != null) {
|
compareBy { it.url.contains(hoster) },
|
||||||
for (video in this) {
|
).reversed()
|
||||||
if (video.url.contains(hoster)) {
|
|
||||||
hosterList.add(video)
|
|
||||||
} else {
|
|
||||||
otherList.add(video)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
otherList += this
|
|
||||||
}
|
|
||||||
val newList = mutableListOf<Video>()
|
|
||||||
var preferred = 0
|
|
||||||
for (video in hosterList) {
|
|
||||||
if (hoster?.let { video.quality.contains(it) } == true) {
|
|
||||||
newList.add(preferred, video)
|
|
||||||
preferred++
|
|
||||||
} else {
|
|
||||||
newList.add(video)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (video in otherList) {
|
|
||||||
if (hoster?.let { video.quality.contains(it) } == true) {
|
|
||||||
newList.add(preferred, video)
|
|
||||||
preferred++
|
|
||||||
} else {
|
|
||||||
newList.add(video)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return newList
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun videoListSelector() = throw Exception("not used")
|
override fun videoListSelector() = throw Exception("not used")
|
||||||
@ -170,56 +153,14 @@ class StreamCloud : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||||||
|
|
||||||
override fun videoUrlParse(document: Document) = throw Exception("not used")
|
override fun videoUrlParse(document: Document) = throw Exception("not used")
|
||||||
|
|
||||||
// Search
|
// ============================== Settings ==============================
|
||||||
|
|
||||||
override fun searchAnimeFromElement(element: Element): SAnime {
|
|
||||||
val anime = SAnime.create()
|
|
||||||
anime.setUrlWithoutDomain(element.select("div.thumb a").attr("href"))
|
|
||||||
anime.thumbnail_url = baseUrl + element.select("div.thumb a img").attr("src")
|
|
||||||
anime.title = element.select("div.thumb a img").attr("alt")
|
|
||||||
return anime
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun searchAnimeNextPageSelector(): String = "#nextlink"
|
|
||||||
|
|
||||||
override fun searchAnimeSelector(): String = "#dle-content div.item"
|
|
||||||
|
|
||||||
override fun searchAnimeRequest(page: Int, query: String, filters: AnimeFilterList): Request = GET("$baseUrl/index.php?do=search&subaction=search&search_start=$page&full_search=0&story=$query")
|
|
||||||
|
|
||||||
// Details
|
|
||||||
|
|
||||||
override fun animeDetailsParse(document: Document): SAnime {
|
|
||||||
val anime = SAnime.create()
|
|
||||||
anime.thumbnail_url = baseUrl + document.select("#longInfo img").attr("src")
|
|
||||||
anime.title = document.select("#title span.masha_index4").text()
|
|
||||||
anime.genre = document.select("#longInfo span.masha_index10").text().split("/").joinToString(", ") { it }
|
|
||||||
anime.description = document.select("#longInfo #storyline span p").text()
|
|
||||||
if (document.select("#longInfo div[style] a").attr("href").toString().contains("director")) {
|
|
||||||
anime.author = document.select("#longInfo div[style] a").toString().substringAfter("</span>").substringBefore("</a>")
|
|
||||||
}
|
|
||||||
anime.status = SAnime.COMPLETED
|
|
||||||
return anime
|
|
||||||
}
|
|
||||||
|
|
||||||
// Latest
|
|
||||||
|
|
||||||
override fun latestUpdatesNextPageSelector(): String = throw Exception("Not used")
|
|
||||||
|
|
||||||
override fun latestUpdatesFromElement(element: Element): SAnime = throw Exception("Not used")
|
|
||||||
|
|
||||||
override fun latestUpdatesRequest(page: Int): Request = throw Exception("Not used")
|
|
||||||
|
|
||||||
override fun latestUpdatesSelector(): String = throw Exception("Not used")
|
|
||||||
|
|
||||||
// Preferences
|
|
||||||
|
|
||||||
override fun setupPreferenceScreen(screen: PreferenceScreen) {
|
override fun setupPreferenceScreen(screen: PreferenceScreen) {
|
||||||
val hosterPref = ListPreference(screen.context).apply {
|
ListPreference(screen.context).apply {
|
||||||
key = "preferred_hoster"
|
key = PREF_HOSTER_KEY
|
||||||
title = "Standard-Hoster"
|
title = PREF_HOSTER_TITLE
|
||||||
entries = arrayOf("Streamtape", "DoodStream")
|
entries = PREF_HOSTER_ENTRIES
|
||||||
entryValues = arrayOf("https://streamtape.com", "https://dood.")
|
entryValues = PREF_HOSTER_VALUES
|
||||||
setDefaultValue("https://streamtape.com")
|
setDefaultValue(PREF_HOSTER_DEFAULT)
|
||||||
summary = "%s"
|
summary = "%s"
|
||||||
|
|
||||||
setOnPreferenceChangeListener { _, newValue ->
|
setOnPreferenceChangeListener { _, newValue ->
|
||||||
@ -228,19 +169,33 @@ class StreamCloud : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||||||
val entry = entryValues[index] as String
|
val entry = entryValues[index] as String
|
||||||
preferences.edit().putString(key, entry).commit()
|
preferences.edit().putString(key, entry).commit()
|
||||||
}
|
}
|
||||||
}
|
}.also(screen::addPreference)
|
||||||
val subSelection = MultiSelectListPreference(screen.context).apply {
|
|
||||||
key = "hoster_selection"
|
MultiSelectListPreference(screen.context).apply {
|
||||||
title = "Hoster auswählen"
|
key = PREF_HOSTER_SELECTION_KEY
|
||||||
entries = arrayOf("Streamtape", "Doodstream")
|
title = PREF_HOSTER_SELECTION_TITLE
|
||||||
entryValues = arrayOf("stape", "dood")
|
entries = PREF_HOSTER_SELECTION_ENTRIES
|
||||||
setDefaultValue(setOf("stape", "dood"))
|
entryValues = PREF_HOSTER_SELECTION_VALUES
|
||||||
|
setDefaultValue(PREF_HOSTER_SELECTION_DEFAULT)
|
||||||
|
|
||||||
setOnPreferenceChangeListener { _, newValue ->
|
setOnPreferenceChangeListener { _, newValue ->
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
preferences.edit().putStringSet(key, newValue as Set<String>).commit()
|
preferences.edit().putStringSet(key, newValue as Set<String>).commit()
|
||||||
}
|
}
|
||||||
}
|
}.also(screen::addPreference)
|
||||||
screen.addPreference(hosterPref)
|
}
|
||||||
screen.addPreference(subSelection)
|
|
||||||
|
companion object {
|
||||||
|
private const val PREF_HOSTER_KEY = "preferred_hoster"
|
||||||
|
private const val PREF_HOSTER_TITLE = "Standard-Hoster"
|
||||||
|
private const val PREF_HOSTER_DEFAULT = "https://streamtape.com"
|
||||||
|
private val PREF_HOSTER_ENTRIES = arrayOf("Streamtape", "DoodStream")
|
||||||
|
private val PREF_HOSTER_VALUES = arrayOf("https://streamtape.com", "https://dood.")
|
||||||
|
|
||||||
|
private const val PREF_HOSTER_SELECTION_KEY = "hoster_selection"
|
||||||
|
private const val PREF_HOSTER_SELECTION_TITLE = "Hoster auswählen"
|
||||||
|
private val PREF_HOSTER_SELECTION_ENTRIES = arrayOf("Streamtape", "DoodStream", "MixDrop")
|
||||||
|
private val PREF_HOSTER_SELECTION_VALUES = arrayOf("stape", "dood", "mixdrop")
|
||||||
|
private val PREF_HOSTER_SELECTION_DEFAULT by lazy { PREF_HOSTER_SELECTION_VALUES.toSet() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user