fix bug and parses more data

This commit is contained in:
Arjix 2021-07-22 16:37:59 +03:00 committed by GitHub
parent 3583145e42
commit c91c5e8d66
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,15 +1,19 @@
package com.lagradost.cloudstream3.animeproviders package com.lagradost.cloudstream3.animeproviders
import android.annotation.SuppressLint
import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.module.kotlin.readValue import com.fasterxml.jackson.module.kotlin.readValue
import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.extractors.Vidstream
import com.lagradost.cloudstream3.utils.getQualityFromName import com.lagradost.cloudstream3.utils.getQualityFromName
import org.jsoup.Jsoup import org.jsoup.Jsoup
import org.jsoup.nodes.Document import org.jsoup.nodes.Document
import java.util.* import java.util.*
import kotlin.collections.ArrayList import kotlin.collections.ArrayList
import khttp.structures.cookie.CookieJar import khttp.structures.cookie.CookieJar
import java.text.SimpleDateFormat
class TenshiProvider : MainAPI() { class TenshiProvider : MainAPI() {
@ -79,11 +83,17 @@ class TenshiProvider : MainAPI() {
) )
} else { } else {
AnimeSearchResponse( AnimeSearchResponse(
title, href, getSlug(href), title,
this.name, TvType.Anime, href,
img, null, null, getSlug(href),
this.name,
TvType.Anime,
img,
null,
null,
EnumSet.of(DubStatus.Subbed), EnumSet.of(DubStatus.Subbed),
null, null null,
null
) )
} }
) )
@ -91,6 +101,13 @@ class TenshiProvider : MainAPI() {
return returnValue return returnValue
} }
@SuppressLint("SimpleDateFormat")
private fun dateParser(dateString: String): String? {
val format = SimpleDateFormat("dd 'of' MMM',' yyyy")
val newFormat = SimpleDateFormat("dd-MM-yyyy")
return newFormat.format(format.parse(dateString.replace("th ", " ").replace("st ", " ").replace("nd ", " ").replace("rd ", " ")))
}
// data class TenshiSearchResponse( // data class TenshiSearchResponse(
// @JsonProperty("url") var url : String, // @JsonProperty("url") var url : String,
// @JsonProperty("title") var title : String, // @JsonProperty("title") var title : String,
@ -165,7 +182,7 @@ class TenshiProvider : MainAPI() {
override fun load(slug: String): LoadResponse? { override fun load(slug: String): LoadResponse? {
val url = "$mainUrl/anime/${slug}" val url = "$mainUrl/anime/${slug}"
val response = khttp.get(url, timeout = 120.0) val response = khttp.get(url, timeout = 120.0, cookies=mapOf("loop-view" to "thumb"))
val document = Jsoup.parse(response.text) val document = Jsoup.parse(response.text)
val englishTitle = document.selectFirst("span.value > span[title=\"English\"]")?.parent()?.text()?.trim() val englishTitle = document.selectFirst("span.value > span[title=\"English\"]")?.parent()?.text()?.trim()
@ -175,11 +192,19 @@ class TenshiProvider : MainAPI() {
val isDubbed = false val isDubbed = false
val episodeNodes = document.select("li[class*=\"episode\"] > a") val episodeNodes = document.select("li[class*=\"episode\"] > a")
val episodes = ArrayList<AnimeEpisode>(episodeNodes?.map { AnimeEpisode(it.attr("href")) } val episodes = ArrayList<AnimeEpisode>(episodeNodes?.map {
AnimeEpisode(
it.attr("href"),
it.selectFirst(".episode-title")?.text()?.trim(),
it.selectFirst("img")?.attr("src"),
dateParser(it.selectFirst(".episode-date").text().trim()).toString(),
null,
it.attr("data-content").trim(),
) }
?: ArrayList<AnimeEpisode>()) ?: ArrayList<AnimeEpisode>())
println("tenshimoe" + episodes[0].url)
val statusText = document.selectFirst("li.status > .value").text().trim() println("tenshimoe" + episodes[0].posterUrl)
val status = when (statusText) { val status = when (document.selectFirst("li.status > .value")?.text()?.trim()) {
"Ongoing" -> ShowStatus.Ongoing "Ongoing" -> ShowStatus.Ongoing
"Completed" -> ShowStatus.Completed "Completed" -> ShowStatus.Completed
else -> null else -> null
@ -188,11 +213,11 @@ class TenshiProvider : MainAPI() {
val pattern = "(\\d{4})".toRegex() val pattern = "(\\d{4})".toRegex()
val (year) = pattern.find(yearText)!!.destructured val (year) = pattern.find(yearText)!!.destructured
val poster = document.selectFirst("img.cover-image").attr("src") val poster = document.selectFirst("img.cover-image")?.attr("src")
val type = document.selectFirst("a[href*=\"https://tenshi.moe/type/\"]").text().trim() val type = document.selectFirst("a[href*=\"https://tenshi.moe/type/\"]")?.text()?.trim()
val synopsis = document.selectFirst(".entry-description > .card-body").text().trim() val synopsis = document.selectFirst(".entry-description > .card-body")?.text()?.trim()
val genre = document.select("li.genre.meta-data > span.value").map { it.text().trim() } val genre = document.select("li.genre.meta-data > span.value").map { it?.text()?.trim().toString() }
val synonyms = document.select("li.synonym.meta-data > div.info-box > span.value").map { it?.text()?.trim().toString() } val synonyms = document.select("li.synonym.meta-data > div.info-box > span.value").map { it?.text()?.trim().toString() }
@ -211,7 +236,8 @@ class TenshiProvider : MainAPI() {
synopsis, synopsis,
ArrayList(genre) ?: ArrayList(), ArrayList(genre) ?: ArrayList(),
ArrayList(synonyms), ArrayList(synonyms),
null, null, null,
null,
) )
} }