UHDMovies: handle errors and fix some warnings and inconsistencies (#1351)
This commit is contained in:
parent
ae5c347daf
commit
d42f5c6cc6
@ -6,7 +6,7 @@ ext {
|
|||||||
extName = 'UHD Movies'
|
extName = 'UHD Movies'
|
||||||
pkgNameSuffix = 'en.uhdmovies'
|
pkgNameSuffix = 'en.uhdmovies'
|
||||||
extClass = '.UHDMovies'
|
extClass = '.UHDMovies'
|
||||||
extVersionCode = 8
|
extVersionCode = 9
|
||||||
libVersion = '13'
|
libVersion = '13'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ class UHDMovies : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||||||
val resp = response.asJsoup()
|
val resp = response.asJsoup()
|
||||||
val episodeList = mutableListOf<SEpisode>()
|
val episodeList = mutableListOf<SEpisode>()
|
||||||
val episodeElements = resp.select("p:has(a[href*=?id])[style*=center],p:has(a[href*=?id]):has(span.maxbutton-1-center)")
|
val episodeElements = resp.select("p:has(a[href*=?id])[style*=center],p:has(a[href*=?id]):has(span.maxbutton-1-center)")
|
||||||
val qualityRegex = "[0-9]{3,4}p".toRegex(RegexOption.IGNORE_CASE)
|
val qualityRegex = "\\d{3,4}p".toRegex(RegexOption.IGNORE_CASE)
|
||||||
val firstText = episodeElements.first()!!.text()
|
val firstText = episodeElements.first()!!.text()
|
||||||
if (firstText.contains("Episode", true) ||
|
if (firstText.contains("Episode", true) ||
|
||||||
firstText.contains("Zip", true) ||
|
firstText.contains("Zip", true) ||
|
||||||
@ -119,16 +119,16 @@ class UHDMovies : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||||||
) {
|
) {
|
||||||
episodeElements.map { row ->
|
episodeElements.map { row ->
|
||||||
val prevP = row.previousElementSibling()!!
|
val prevP = row.previousElementSibling()!!
|
||||||
val seasonRegex = "[ .]S(?:eason)?[ .]?([0-9]{1,2})[ .]".toRegex(RegexOption.IGNORE_CASE)
|
val seasonRegex = "[ .]S(?:eason)?[ .]?(\\d{1,2})[ .]".toRegex(RegexOption.IGNORE_CASE)
|
||||||
val result = seasonRegex.find(prevP.text())
|
val result = seasonRegex.find(prevP.text())
|
||||||
|
|
||||||
val season = (
|
val season = (
|
||||||
result?.groups?.get(1)?.value ?: let {
|
result?.groups?.get(1)?.value ?: let {
|
||||||
val prevPre = row.previousElementSiblings()!!.prev("pre,div.mks_separator")
|
val prevPre = row.previousElementSiblings().prev("pre,div.mks_separator")
|
||||||
val preResult = seasonRegex.find(prevPre.first()!!.text())
|
val preResult = seasonRegex.find(prevPre.first()!!.text())
|
||||||
preResult?.groups?.get(1)?.value ?: let {
|
preResult?.groups?.get(1)?.value ?: let {
|
||||||
val title = resp.select("h1.entry-title")
|
val title = resp.select("h1.entry-title")
|
||||||
val titleResult = "[ .\\[(]S(?:eason)?[ .]?([0-9]{1,2})[ .\\])]".toRegex(RegexOption.IGNORE_CASE).find(title.text())
|
val titleResult = "[ .\\[(]S(?:eason)?[ .]?(\\d{1,2})[ .\\])]".toRegex(RegexOption.IGNORE_CASE).find(title.text())
|
||||||
titleResult?.groups?.get(1)?.value ?: "-1"
|
titleResult?.groups?.get(1)?.value ?: "-1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -182,11 +182,17 @@ class UHDMovies : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||||||
qualityMatchOwn?.value ?: "HD"
|
qualityMatchOwn?.value ?: "HD"
|
||||||
}
|
}
|
||||||
|
|
||||||
val collectionName = row.previousElementSiblings()!!.prev("h1,h2,h3,pre").first()!!.text()
|
val collectionName = row.previousElementSiblings().prev("h1,h2,h3,pre").first()!!.text()
|
||||||
.replace("Download", "", true).trim()
|
.replace("Download", "", true).trim().let {
|
||||||
|
if (it.contains("Collection", true)) {
|
||||||
|
row.previousElementSibling()!!.ownText()
|
||||||
|
} else {
|
||||||
|
it
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
row.select("a").map { linkElement ->
|
row.select("a").map { linkElement ->
|
||||||
Triple(linkElement.attr("href")!!, quality, collectionName)
|
Triple(linkElement.attr("href"), quality, collectionName)
|
||||||
}
|
}
|
||||||
}.flatten().groupBy { it.third }.map { group ->
|
}.flatten().groupBy { it.third }.map { group ->
|
||||||
collectionIdx++
|
collectionIdx++
|
||||||
@ -236,6 +242,9 @@ class UHDMovies : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||||||
}.getOrNull()
|
}.getOrNull()
|
||||||
}.flatten(),
|
}.flatten(),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (videoList.isEmpty()) throw Exception("No working links found")
|
||||||
|
|
||||||
return Observable.just(videoList.sort())
|
return Observable.just(videoList.sort())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,6 +278,7 @@ class UHDMovies : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||||||
val mediaResponse = client.newBuilder().followRedirects(false).build()
|
val mediaResponse = client.newBuilder().followRedirects(false).build()
|
||||||
.newCall(GET(redirectUrl)).execute()
|
.newCall(GET(redirectUrl)).execute()
|
||||||
val path = mediaResponse.body.string().substringAfter("replace(\"").substringBefore("\"")
|
val path = mediaResponse.body.string().substringAfter("replace(\"").substringBefore("\"")
|
||||||
|
if (path == "/404") return Pair(emptyList(), "")
|
||||||
val mediaUrl = "https://" + mediaResponse.request.url.host + path
|
val mediaUrl = "https://" + mediaResponse.request.url.host + path
|
||||||
val videoList = mutableListOf<Video>()
|
val videoList = mutableListOf<Video>()
|
||||||
|
|
||||||
@ -280,26 +290,30 @@ class UHDMovies : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||||||
return Pair(videoList, mediaUrl)
|
return Pair(videoList, mediaUrl)
|
||||||
}
|
}
|
||||||
|
|
||||||
private val sizeRegex = "\\[((?:.(?!\\[))+)][ ]*\$".toRegex(RegexOption.IGNORE_CASE)
|
private val sizeRegex = "\\[((?:.(?!\\[))+)] *\$".toRegex(RegexOption.IGNORE_CASE)
|
||||||
|
|
||||||
private fun extractWorkerLinks(mediaUrl: String, quality: String, type: Int): List<Video> {
|
private fun extractWorkerLinks(mediaUrl: String, quality: String, type: Int): List<Video> {
|
||||||
val reqLink = mediaUrl.replace("/file/", "/wfile/") + "?type=$type"
|
val reqLink = mediaUrl.replace("/file/", "/wfile/") + "?type=$type"
|
||||||
val resp = client.newCall(GET(reqLink)).execute().asJsoup()
|
val resp = client.newCall(GET(reqLink)).execute().asJsoup()
|
||||||
val sizeMatch = sizeRegex.find(resp.select("div.card-header").text().trim())
|
val sizeMatch = sizeRegex.find(resp.select("div.card-header").text().trim())
|
||||||
val size = sizeMatch?.groups?.get(1)?.value?.let { " - $it" } ?: ""
|
val size = sizeMatch?.groups?.get(1)?.value?.let { " - $it" } ?: ""
|
||||||
return resp.select("div.card-body div.mb-4 > a").mapIndexed { index, linkElement ->
|
return try {
|
||||||
val link = linkElement.attr("href")
|
resp.select("div.card-body div.mb-4 > a").mapIndexed { index, linkElement ->
|
||||||
val decodedLink = if (link.contains("workers.dev")) {
|
val link = linkElement.attr("href")
|
||||||
link
|
val decodedLink = if (link.contains("workers.dev")) {
|
||||||
} else {
|
link
|
||||||
String(Base64.decode(link.substringAfter("download?url="), Base64.DEFAULT))
|
} else {
|
||||||
}
|
String(Base64.decode(link.substringAfter("download?url="), Base64.DEFAULT))
|
||||||
|
}
|
||||||
|
|
||||||
Video(
|
Video(
|
||||||
url = decodedLink,
|
url = decodedLink,
|
||||||
quality = "$quality - CF $type Worker ${index + 1}$size",
|
quality = "$quality - CF $type Worker ${index + 1}$size",
|
||||||
videoUrl = decodedLink,
|
videoUrl = decodedLink,
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
} catch (_: Exception) {
|
||||||
|
emptyList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -334,10 +348,16 @@ class UHDMovies : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||||||
return this.sortedWith(comparator)
|
return this.sortedWith(comparator)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun String.fixQuality(): Float = this.substringAfterLast("-").trim()
|
private fun String.fixQuality(): Float {
|
||||||
.replace("GB", "", true)
|
val size = this.substringAfterLast("-").trim()
|
||||||
.replace("MB", "", true)
|
return if (size.contains("GB", true)) {
|
||||||
.toFloat()
|
size.replace("GB", "", true)
|
||||||
|
.toFloat() * 1000
|
||||||
|
} else {
|
||||||
|
size.replace("MB", "", true)
|
||||||
|
.toFloat()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun setupPreferenceScreen(screen: PreferenceScreen) {
|
override fun setupPreferenceScreen(screen: PreferenceScreen) {
|
||||||
val videoQualityPref = ListPreference(screen.context).apply {
|
val videoQualityPref = ListPreference(screen.context).apply {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user