fix episodes without a streaming link make AoDParser crash

This commit is contained in:
Jannik 2020-11-26 17:32:15 +01:00
parent dfaf359952
commit 3ed55ca3c9
Signed by: Seil0
GPG Key ID: E8459F3723C52C24
1 changed files with 12 additions and 10 deletions

View File

@ -235,7 +235,6 @@ object AoDParser {
//Log.i(javaClass.name, "New csrf token is $csrfToken") //Log.i(javaClass.name, "New csrf token is $csrfToken")
} }
val pl = res.select("input.streamstarter_html5").first() val pl = res.select("input.streamstarter_html5").first()
val primary = pl.attr("data-playlist") val primary = pl.attr("data-playlist")
val secondary = pl.attr("data-otherplaylist") val secondary = pl.attr("data-otherplaylist")
@ -291,7 +290,7 @@ object AoDParser {
) )
} }
} }
Log.i(javaClass.name, "Loading secondary plalyist finished") Log.i(javaClass.name, "Loading secondary playlist finished")
// parse additional info from the media page // parse additional info from the media page
res.select("table.vertical-table").select("tr").forEach { row -> res.select("table.vertical-table").select("tr").forEach { row ->
@ -310,15 +309,18 @@ object AoDParser {
// parse additional information for tv shows // parse additional information for tv shows
if (media.type == MediaType.TVSHOW) { if (media.type == MediaType.TVSHOW) {
res.select("div.three-box-container > div.episodebox").forEach { episodebox -> res.select("div.three-box-container > div.episodebox").forEach { episodebox ->
val episodeId = episodebox.select("div.flip-front").attr("id").substringAfter("-").toInt() // make sure the episode has a streaming link
val episodeShortDesc = episodebox.select("p.episodebox-shorttext").text() if (episodebox.select("input.streamstarter_html5").isNotEmpty()) {
val episodeWatched = episodebox.select("div.episodebox-icons > div").hasClass("status-icon-orange") val episodeId = episodebox.select("div.flip-front").attr("id").substringAfter("-").toInt()
val episodeWatchedCallback = episodebox.select("input.streamstarter_html5").eachAttr("data-playlist").first() val episodeShortDesc = episodebox.select("p.episodebox-shorttext").text()
val episodeWatched = episodebox.select("div.episodebox-icons > div").hasClass("status-icon-orange")
val episodeWatchedCallback = episodebox.select("input.streamstarter_html5").eachAttr("data-playlist").first()
media.episodes.firstOrNull { it.id == episodeId }?.apply { media.episodes.firstOrNull { it.id == episodeId }?.apply {
shortDesc = episodeShortDesc shortDesc = episodeShortDesc
watched = episodeWatched watched = episodeWatched
watchedCallback = episodeWatchedCallback watchedCallback = episodeWatchedCallback
}
} }
} }
} }