Skip to content

Commit

Permalink
date bug fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
LagradOst committed Sep 19, 2021
1 parent b631307 commit 6a561a3
Showing 1 changed file with 6 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ class TenshiProvider : MainAPI() {
override val supportedTypes: Set<TvType>
get() = setOf(TvType.Anime, TvType.AnimeMovie, TvType.ONA)

private fun autoLoadToken(): Boolean {
if (token != null) return true
return loadToken()
}

private fun loadToken(): Boolean {
return try {
val response = khttp.get(mainUrl)
Expand Down Expand Up @@ -147,11 +142,10 @@ class TenshiProvider : MainAPI() {
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 ", " ")
)
)
val data = format.parse(
dateString.replace("th ", " ").replace("st ", " ").replace("nd ", " ").replace("rd ", " ")
) ?: return null
return newFormat.format(data)
}

// data class TenshiSearchResponse(
Expand Down Expand Up @@ -235,12 +229,12 @@ class TenshiProvider : MainAPI() {

val episodeNodes = document.select("li[class*=\"episode\"] > a")

val episodes = ArrayList<AnimeEpisode>(episodeNodes?.map {
val episodes = ArrayList(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(),
dateParser(it.selectFirst(".episode-date").text().trim()),
null,
it.attr("data-content").trim(),
)
Expand Down

0 comments on commit 6a561a3

Please sign in to comment.