From a8d32415e880369550c4184c2cacd866d202f606 Mon Sep 17 00:00:00 2001 From: Jace <54625750+Jacekun@users.noreply.github.com> Date: Wed, 4 May 2022 19:39:02 +0800 Subject: [PATCH] [Feature] Add Seasons and Episode number on TV Series on Soap2Day provider. (#1023) --- .../movieproviders/SoaptwoDayProvider.kt | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/SoaptwoDayProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/SoaptwoDayProvider.kt index 3a7519f8..fe5a4b8c 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/SoaptwoDayProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/SoaptwoDayProvider.kt @@ -72,13 +72,23 @@ class SoaptwoDayProvider:MainAPI() { val title = soup.selectFirst(".hidden-lg > div:nth-child(1) > h4")?.text() ?: "" val description = soup.selectFirst("p#wrap")?.text()?.trim() val poster = soup.selectFirst(".col-md-5 > div:nth-child(1) > div:nth-child(1) > img")?.attr("src") - val episodes = soup.select("div.alert > div > div > a").mapNotNull { - val link = fixUrlNull(it?.attr("href")) ?: return@mapNotNull null - val name = it?.text()?.replace(Regex("(^(\\d+)\\.)"),"") - Episode( - name = name, - data = link - ) + val episodes = mutableListOf() + soup.select("div.alert").forEach { + val season = it?.selectFirst("h4")?.text()?.filter { c -> c.isDigit() }?.toIntOrNull() + it?.select("div > div > a")?.forEach { entry -> + val link = fixUrlNull(entry?.attr("href")) ?: return@forEach + val text = entry?.text() ?: "" + val name = text.replace(Regex("(^(\\d+)\\.)"),"") + val epNum = text.substring(0, text.indexOf(".")).toIntOrNull() + episodes.add( + Episode( + name = name, + data = link, + season = season, + episode = epNum + ) + ) + } } val otherInfoBody = soup.select("div.col-sm-8 div.panel-body").toString() //Fetch casts