autoformat the code and add the changes requested

This commit is contained in:
Eddy 2022-09-04 17:30:14 +02:00
parent 313017749c
commit 640cc4c575
4 changed files with 268 additions and 226 deletions

View file

@ -7,17 +7,19 @@ import org.jsoup.Jsoup
open class MytvExtractor : ExtractorApi() {
override val name: String = "Mytv"
override val mainUrl: String = "https://www.myvi.tv/"
private val srcRegex = Regex("""PlayerLoader\.CreatePlayer\(\"v\=(.*)\\u0026tp""") // would be possible to use the parse and find src attribute
private val srcRegex =
Regex("""PlayerLoader\.CreatePlayer\(\"v\=(.*)\\u0026tp""") // would be possible to use the parse and find src attribute
override val requiresReferer = false
override suspend fun getUrl(url: String, referer: String?): List<ExtractorLink>? {
val cleaned_url = url
val html =app.get(cleaned_url)
val html = app.get(cleaned_url)
with(html) { // raised error ERROR_CODE_PARSING_CONTAINER_UNSUPPORTED (3003) is due to the response: "error_nofile"
srcRegex.find(this.text)?.groupValues?.get(1)?.let { link ->
var lien = link
lien= lien.replace("%2f","/").replace("%3a",":").replace("%3f","?").replace("%3d","=").replace("%26","&")
lien = lien.replace("%2f", "/").replace("%3a", ":").replace("%3f", "?")
.replace("%3d", "=").replace("%26", "&")
//val html = app.get(url).text
//val document = Jsoup.parse(html)
@ -25,7 +27,7 @@ open class MytvExtractor : ExtractorApi() {
return listOf(
ExtractorLink(
name,
name ,
name,
lien,
cleaned_url, // voir si site demande le referer à mettre ici
Qualities.Unknown.value,

View file

@ -1,3 +1,4 @@
package com.lagradost
import com.lagradost.cloudstream3.utils.*
import com.lagradost.cloudstream3.app
@ -7,20 +8,21 @@ import org.jsoup.Jsoup
open class SibnetExtractor : ExtractorApi() {
override val name: String = "Sibnet"
override val mainUrl: String = "https://video.sibnet.ru"
private val srcRegex = Regex("""player\.src\(\[\{src: \"(.*?)\"""") // would be possible to use the parse and find src attribute
private val srcRegex =
Regex("""player\.src\(\[\{src: \"(.*?)\"""") // would be possible to use the parse and find src attribute
override val requiresReferer = true
override suspend fun getUrl(url: String, referer: String?): List<ExtractorLink>? {
val cleaned_url = url
val html =app.get(cleaned_url)
val html = app.get(cleaned_url)
with(html) { // raised error ERROR_CODE_PARSING_CONTAINER_UNSUPPORTED (3003) is due to the response: "error_nofile"
srcRegex.find(this.text)?.groupValues?.get(1)?.let { link ->
return listOf(
ExtractorLink(
name,
name ,
mainUrl+link,
name,
mainUrl + link,
cleaned_url, // voir si site demande le referer à mettre ici
Qualities.Unknown.value,
)

View file

@ -1,5 +1,7 @@
package com.lagradost
package com.lagradost.cloudstream3.animeproviders
import com.fasterxml.jackson.annotation.JsonProperty
import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.utils.*
@ -14,8 +16,10 @@ class VostfreeProvider : MainAPI() {
override val hasQuickSearch = false // recherche rapide (optionel, pas vraimet utile)
override val hasMainPage = true // page d'accueil (optionel mais encoragé)
override var lang = "fr" // fournisseur est en francais
//override val supportedTypes = setOf(TvType.Movie) // ici on ne supporte que les films
override val supportedTypes = setOf( TvType.Anime,TvType.AnimeMovie,TvType.OVA) // animes, animesfilms et series
override val supportedTypes =
setOf(TvType.Anime, TvType.AnimeMovie, TvType.OVA) // animes, animesfilms et series
// liste des types: https://recloudstream.github.io/dokka/app/com.lagradost.cloudstream3/-tv-type/index.html
/**
@ -29,16 +33,20 @@ class VostfreeProvider : MainAPI() {
val link = "$mainUrl/index.php?story=$query&do=search&subaction=search"
// L'url pour chercher un anime de dragon sera donc: 'https://vostfree.cx/index.php?story=dragon&do=search&subaction=search'
// le $ dans une string permet d'insérer une variable
val document = app.get(link).document // app.get() permet de télécharger la page html avec une requete HTTP (get)
val document =
app.get(link).document // app.get() permet de télécharger la page html avec une requete HTTP (get)
// on convertit le html en un document
return document.select("div.search-result") // on séléctione tous les éléments 'enfant' du type articles
.apmap { div -> // apmap crée une liste des éléments (ici newMovieSearchResponse et newAnimeSearchResponse)
//val posterContainer = div.selectFirst("> span.image ") // selectione le premier élément correspondant à ces critères
val type = div?.selectFirst("div.genre")?.text()?.replace("\t", "")?.replace("\n", "")
val type =
div?.selectFirst("div.genre")?.text()?.replace("\t", "")?.replace("\n", "")
// replace enlève tous les '\t' et '\n' du titre
val mediaPoster = mainUrl + div?.selectFirst("span.image > img")?.attr("src") // récupère le texte de l'attribut src de l'élément
val mediaPoster = mainUrl + div?.selectFirst("span.image > img")
?.attr("src") // récupère le texte de l'attribut src de l'élément
val href = div?.selectFirst("div.info > div.title > a")?.attr("href") ?: throw ErrorLoadingException("invalid link") // renvoie une erreur si il n'y a pas de lien vers le média
val href = div?.selectFirst("div.info > div.title > a")?.attr("href")
?: throw ErrorLoadingException("invalid link") // renvoie une erreur si il n'y a pas de lien vers le média
val title = div.selectFirst("> div.info > div.title > a")?.text().toString()
when (type) {
@ -85,113 +93,138 @@ class VostfreeProvider : MainAPI() {
@JsonProperty("url") val url: String,
@JsonProperty("episodeNumber") val episodeNumber: String,
)
override suspend fun load(url: String): LoadResponse {
val document = app.get(url).document // récupere le texte sur la page (requète http)
// url est le lien retourné par la fonction search (la variable href) ou la fonction getMainPage
var mediaType=TvType.Anime
var mediaType = TvType.Anime
val episodes = ArrayList<Episode>()
val meta = document.selectFirst("div#dle-content > div.watch-top > div.image-bg > div.image-bg-content > div.slide-block ")
var poster : String? = ""
val meta =
document.selectFirst("div#dle-content > div.watch-top > div.image-bg > div.image-bg-content > div.slide-block ")
var poster: String? = ""
var title = ""
var description : String? = ""// first() selectione le premier élément de la liste
var description: String? = ""// first() selectione le premier élément de la liste
/////////////////////////////////////////////////
val isSaison = document.select("div.new_player_series_count > a")
var saison00 = -1
var i = 0
var noSeason =true
var noSeason = true
var enterInIseason = false
isSaison.forEach {
var url1=it.attr("href")
while(noSeason){
it.select("[alt=Saison 0$i]").forEach{ // enter in the block when it match the season
noSeason=false
var url1 = it.attr("href")
while (noSeason) {
it.select("[alt=Saison 0$i]")
.forEach { // enter in the block when it match the season
noSeason = false
}
it.select("[alt=Saison $i]").forEach{ // enter in the block when it match the season
noSeason=false
it.select("[alt=Saison $i]")
.forEach { // enter in the block when it match the season
noSeason = false
}
i++
}
i=i-1
i = i - 1
saison00 = i
i = 0 // reinit i et noSeason for the next page
noSeason =true
noSeason = true
var document1 = app.get(url1).document // récupere le texte sur la page (requète http)
// url est le lien retourné par la fonction search (la variable href) ou la fonction getMainPage
var meta1 = document1.selectFirst("div#dle-content > div.watch-top > div.image-bg > div.image-bg-content > div.slide-block ")
poster = mainUrl + meta1?.select(" div.slide-poster > img")?.attr("src") // récupere le texte de l'attribut 'data-src'
title = meta1?.select("div.slide-middle > h1")?.text() ?: throw ErrorLoadingException("Invalid title")
title =title.replace("Saison","").replace("saison","").replace("SAISON","")
title =title.replace("Season","").replace("season","").replace("SEASON","")
description= meta1.select("div.slide-middle > div.slide-desc").first()?.text() // first() selectione le premier élément de la liste
var meta1 =
document1.selectFirst("div#dle-content > div.watch-top > div.image-bg > div.image-bg-content > div.slide-block ")
poster = mainUrl + meta1?.select(" div.slide-poster > img")
?.attr("src") // récupere le texte de l'attribut 'data-src'
title = meta1?.select("div.slide-middle > h1")?.text()
?: throw ErrorLoadingException("Invalid title")
title = title.replace("Saison", "").replace("saison", "").replace("SAISON", "")
.replace("Season", "").replace("season", "").replace("SEASON", "")
description = meta1.select("div.slide-middle > div.slide-desc").first()
?.text() // first() selectione le premier élément de la liste
val listEpisode =document.select(" select.new_player_selector > option").forEach {
val listEpisode = document.select(" select.new_player_selector > option").forEach {
if( it.text()!="Film"){
if (it.text() != "Film") {
val link =
EpisodeData(
url1,
it.text().replace("Episode ",""),
it.text().replace("Episode ", ""),
).toJson()
episodes.add( Episode(
episodes.add(
Episode(
link,
episode = it.text().replace("Episode ","").toInt(),
season=saison00,
episode = it.text().replace("Episode ", "").toInt(),
season = saison00,
name = "Saison ${saison00.toString()}" + it.text(),
//description= description,
posterUrl = poster
) )
}else{
)
)
} else {
mediaType=TvType.AnimeMovie
mediaType = TvType.AnimeMovie
}
}
enterInIseason = true
}
poster = mainUrl + meta?.select(" div.slide-poster > img")?.attr("src") // récupere le texte de l'attribut 'data-src'
title = meta?.select("div.slide-middle > h1")?.text() ?: throw ErrorLoadingException("Invalid title")
poster = mainUrl + meta?.select(" div.slide-poster > img")
?.attr("src") // récupere le texte de l'attribut 'data-src'
title = meta?.select("div.slide-middle > h1")?.text()
?: throw ErrorLoadingException("Invalid title")
description = meta.select("div.slide-middle > div.slide-desc").first()?.text() // first() selectione le premier élément de la liste
description = meta.select("div.slide-middle > div.slide-desc").first()
?.text() // first() selectione le premier élément de la liste
//var saison0 = document.select("div.new_player_series_count > a")?.text()?.replace("Saison 0","")?.replace("Saison ","")?.toInt()
var season : Int?
if(enterInIseason){val seasontext = meta.select("ul.slide-top > li:last-child > b:last-child").text()
title =title.replace("Saison","").replace("saison","").replace("SAISON","")
title =title.replace("Season","").replace("season","").replace("SEASON","")
var season: Int?
if (enterInIseason) {
val seasontext = meta.select("ul.slide-top > li:last-child > b:last-child").text()
title = title.replace("Saison", "").replace("saison", "").replace("SAISON", "")
.replace("Season", "").replace("season", "").replace("SEASON", "")
var index = seasontext?.indexOf('0')
var no = seasontext
while (index == 0) {no = seasontext?.drop(1).toString()
index = no?.indexOf('0')}
while (index == 0) {
no = seasontext?.drop(1).toString()
index = no?.indexOf('0')
}
season = no.toInt()
}else{
season = null}
val listEpisode =document.select(" select.new_player_selector > option").forEach {
} else {
season = null
}
val listEpisode = document.select(" select.new_player_selector > option").forEach {
if( it.text()!="Film"){
if (it.text() != "Film") {
val link =
EpisodeData(
url,
it.text().replace("Episode ",""),
it.text().replace("Episode ", ""),
).toJson()
episodes.add( Episode(
episodes.add(
Episode(
link,
episode = it.text().replace("Episode ","").toInt(),
season=season,
episode = it.text().replace("Episode ", "").toInt(),
season = season,
name = "Saison ${season.toString()}" + it.text(),
//description= description,
posterUrl = poster
) )}else{
)
)
} else {
mediaType=TvType.AnimeMovie
mediaType = TvType.AnimeMovie
}
}
if (mediaType == TvType.AnimeMovie) {
return newMovieLoadResponse(title, url, mediaType,url) { // retourne les informations du film
return newMovieLoadResponse(
title,
url,
mediaType,
url
) { // retourne les informations du film
this.posterUrl = poster
this.plot = description
}
@ -204,7 +237,10 @@ class VostfreeProvider : MainAPI() {
) {
this.posterUrl = poster
this.plot = description
addEpisodes(if(title.contains("VF")) DubStatus.Dubbed else DubStatus.Subbed, episodes)
addEpisodes(
if (title.contains("VF")) DubStatus.Dubbed else DubStatus.Subbed,
episodes
)
}
}
@ -218,53 +254,61 @@ class VostfreeProvider : MainAPI() {
subtitleCallback: (SubtitleFile) -> Unit,
callback: (ExtractorLink) -> Unit,
): Boolean {
val parsedInfo = tryParseJson<EpisodeData>(data)//?:throw ErrorLoadingException("Invalid url")
val url = if(parsedInfo?.url !=null){parsedInfo.url}else{data}
val noEpisode = if(parsedInfo?.episodeNumber !=null){parsedInfo.episodeNumber}else{"1"} // if is not a movie then take the episode number else 1
val parsedInfo =
tryParseJson<EpisodeData>(data)//?:throw ErrorLoadingException("Invalid url")
val url = if (parsedInfo?.url != null) {
parsedInfo.url
} else {
data
}
val noEpisode = if (parsedInfo?.episodeNumber != null) {
parsedInfo.episodeNumber
} else {
"1"
} // if is not a movie then take the episode number else 1
val document = app.get(url).document
document.select("div.new_player_bottom").apmap { player_bottom -> // séléctione tous les players
document.select("div.new_player_bottom")
.apmap { player_bottom -> // séléctione tous les players
// supprimer les zéro de 0015 pour obtenir l'episode 15
var index = noEpisode?.indexOf('0')
var no = noEpisode
while (index == 0) {no = noEpisode?.drop(1).toString()
index = no?.indexOf('0')}
while (index == 0) {
no = noEpisode?.drop(1).toString()
index = no?.indexOf('0')
}
var cssQuery = " div#buttons_$no" // no numéro épisode
val buttonsNepisode = player_bottom?.select(cssQuery)?:throw ErrorLoadingException("Non player") //séléctione tous les players pour l'episode NoEpisode
val buttonsNepisode = player_bottom?.select(cssQuery)
?: throw ErrorLoadingException("Non player") //séléctione tous les players pour l'episode NoEpisode
buttonsNepisode.select("> div").forEach {
val player = it.attr("id")?.toString()?: throw ErrorLoadingException("Player No found") //prend tous les players resultat : "player_2140" et "player_6521"
val playerName = it.select("div#$player").text() // prend le nom du player ex : "Uqload" et "Sibnet"
val player = it.attr("id")?.toString()
?: throw ErrorLoadingException("Player No found") //prend tous les players resultat : "player_2140" et "player_6521"
val playerName = it.select("div#$player")
.text() // prend le nom du player ex : "Uqload" et "Sibnet"
//for(i in playerName.indices){
var codePlayload =
document.selectFirst("div#content_$player")?.text().toString() // resultat : "325544" ou "https:..." peut être lorsque playerName = VIP ou Upvid DStream
var playerUrl =""
when (playerName) {
"VIP" -> playerUrl = codePlayload
"Upvid" -> playerUrl = codePlayload // extractor à faire
"Uqload" -> // film_iframe
playerUrl = "https://uqload.com/embed-$codePlayload.html" // OK
"Dstream" -> playerUrl = codePlayload
"Streamsb" -> playerUrl = codePlayload // OK
"Vudeo" -> playerUrl = codePlayload // OK
"Mytv" -> // film_iframe
playerUrl = "https://www.myvi.tv/embed/$codePlayload" //OK
"Sibnet" -> // film_iframe
playerUrl = "https://video.sibnet.ru/shell.php?videoid=$codePlayload" // OK
"NinjaS" -> // film_iframe
playerUrl = codePlayload
"Stream" -> // == myTv extractor + security
playerUrl = "https://myvi.ru/player/embed/html/$codePlayload" //OK
document.selectFirst("div#content_$player")?.text()
.toString() // resultat : "325544" ou "https:..." peut être lorsque playerName = VIP ou Upvid DStream
var playerUrl = ""
playerUrl = when (playerName) {
"VIP", "Upvid", "Dstream", "Streamsb", "Vudeo", "NinjaS" -> codePlayload
"Uqload" -> "https://uqload.com/embed-$codePlayload.html"
"Mytv" -> "https://www.myvi.tv/embed/$codePlayload"
"Sibnet" -> "https://video.sibnet.ru/shell.php?videoid=$codePlayload"
"Stream" -> "https://myvi.ru/player/embed/html/$codePlayload"
else -> ""
}
if (playerUrl != "")
loadExtractor(httpsify(playerUrl), playerUrl, subtitleCallback) { link -> // charge un extracteur d'extraire le lien direct .mp4
callback.invoke(ExtractorLink( // ici je modifie le callback pour ajouter des informations, normalement ce n'est pas nécessaire
loadExtractor(
httpsify(playerUrl),
playerUrl,
subtitleCallback
) { link -> // charge un extracteur d'extraire le lien direct .mp4
callback.invoke(
ExtractorLink( // ici je modifie le callback pour ajouter des informations, normalement ce n'est pas nécessaire
link.source,
link.name + "",
link.url,
@ -273,7 +317,8 @@ class VostfreeProvider : MainAPI() {
link.isM3u8,
link.headers,
link.extractorData
))
)
)
}
// }
@ -288,61 +333,49 @@ class VostfreeProvider : MainAPI() {
override suspend fun getMainPage(
page: Int,
request : MainPageRequest
request: MainPageRequest
): HomePageResponse {
val list = ArrayList<HomePageList>()
val animeDubStatus = ArrayList<String>(15)
val animeDubStatus = ArrayList<String>(1)
animeDubStatus.add("/animes-vf/")
animeDubStatus.add("/animes-vostfr/")
animeDubStatus.add("/films-vf-vostfr/")
animeDubStatus.add("/genre/Action/")
animeDubStatus.add("/genre/Aventure/")
animeDubStatus.add("/genre/Comédie/")
animeDubStatus.add("/genre/Tranche+de+vie/")
animeDubStatus.add("/genre/Drame/")
animeDubStatus.add("/genre/Fantasy/")
animeDubStatus.add("/genre/Surnaturel/")
animeDubStatus.add("/genre/Mystère/")
animeDubStatus.add("/genre/Shonen/")
animeDubStatus.add("/genre/Psychologique/")
animeDubStatus.add("/genre/Romance/")
animeDubStatus.add("/genre/Sci-Fi/")
animeDubStatus.forEach {
val documentZero = app.get("$mainUrl$it").document
val numberOFpage=documentZero.select("div.navigation > div.pages > a").text()
var lastpage = if(numberOFpage !="")numberOFpage.substringAfterLast(" ").toString().toInt() else 1
val numberOFpage = documentZero.select("div.navigation > div.pages > a").text()
var lastpage = if (numberOFpage != "") numberOFpage.substringAfterLast(" ").toString()
.toInt() else 1
val openPageMax = 2 // prendre uniquement les n pages
lastpage =if(lastpage>openPageMax){openPageMax}else{ lastpage}
var categoryTitle =""
for(i in 1 .. lastpage) {
lastpage = if (lastpage > openPageMax) {
openPageMax
} else {
lastpage
}
var categoryTitle = ""
for (i in 1..lastpage) {
var page = "/page/$i"
val document = app.get("$mainUrl$it$page").document
val movies = document.select("div#content > div#dle-content > div.movie-poster")
if (it.contains("genre", true)) {
categoryTitle = it.replace("/genre/", "").replace("/", " (page $i)").replace("+", " ")
categoryTitle = "Catégorie : $categoryTitle"
} else {
categoryTitle =
document.select("div#left-movies-block > ul#left-movies-tabs > li").text().replace("Animes VF", " Animes EN FRANÇAIS (page $i)").replace("Animes VOSTFR", " Animes VOSTFR (page $i)")
.replace("Films VF et VOSTFR", "FILMS EN FRANÇAIS OU EN VOSTFR (page $i)").replace("Liste","").replace("La liste des","")
}
document.select("div#left-movies-block > ul#left-movies-tabs > li").text()
.replace("Animes VF", " Animes EN FRANÇAIS (page $i)")
.replace("Animes VOSTFR", " Animes VOSTFR (page $i)")
.replace("Films VF et VOSTFR", "FILMS EN FRANÇAIS OU EN VOSTFR (page $i)")
.replace("Liste", "").replace("La liste des", "")
val returnList = movies.mapNotNull { article ->
// map est la même chose que apmap (mais apmap est plus rapide)
// ici si un élément est null, il sera automatiquement enlevé de la liste
val poster = article.select("span.image")
val posterUrl = mainUrl + poster.select("> img").attr("src")
val subdub =article.select("div.quality").text()
val subdub = article.select("div.quality").text()
val genre= article.select("div.genre").text()
val genre = article.select("div.genre").text()
val title = article.select("div.info > div.title").text()
val link = article.select("div.play > a").attr("href")
@ -366,9 +399,10 @@ class VostfreeProvider : MainAPI() {
false,
) {
this.posterUrl = posterUrl
if (subdub=="VF") DubStatus.Dubbed else DubStatus.Subbed
if (subdub == "VF") DubStatus.Dubbed else DubStatus.Subbed
//this.quality = quality
} }
}
}
}
if (returnList.isEmpty()) throw ErrorLoadingException()
@ -378,7 +412,8 @@ class VostfreeProvider : MainAPI() {
}
if (list.isEmpty()) throw ErrorLoadingException()
return HomePageResponse(
list)
list
)
}

View file

@ -1,13 +1,14 @@
package com.lagradost
import com.lagradost.cloudstream3.utils.*
import com.lagradost.cloudstream3.app
open class VudeoExtractor : ExtractorApi() {
override val name: String = "Vudeo"
override val mainUrl: String = "https://vudeo.io/"
private val srcRegex = Regex("""sources\: \[\"(.*)\"""") // would be possible to use the parse and find src attribute
private val srcRegex =
Regex("""sources\: \[\"(.*)\"""") // would be possible to use the parse and find src attribute
override val requiresReferer = false
@ -18,7 +19,7 @@ open class VudeoExtractor : ExtractorApi() {
return listOf(
ExtractorLink(
name,
name ,
name,
link,
cleaned_url, // voir si site demande le referer à mettre ici
Qualities.Unknown.value,
@ -29,3 +30,5 @@ open class VudeoExtractor : ExtractorApi() {
return null
}
}