Applied PR changes

This commit is contained in:
Jace 2022-10-02 10:37:51 +08:00
parent 4956581cbc
commit e52b320927
2 changed files with 39 additions and 51 deletions

View file

@ -23,5 +23,5 @@ cloudstream {
"AsianDrama", "AsianDrama",
) )
iconUrl = "https://www.google.com/s2/favicons?domain=pinoymovieshub.ph&sz=%size%" iconUrl = "https://www.google.com/s2/favicons?domain=www.pinoymovieshub.ph&sz=%size%"
} }

View file

@ -3,7 +3,6 @@ package com.lagradost
import android.util.Log import android.util.Log
import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.annotation.JsonProperty
import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.mvvm.logError
import com.lagradost.cloudstream3.utils.AppUtils import com.lagradost.cloudstream3.utils.AppUtils
import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.loadExtractor import com.lagradost.cloudstream3.utils.loadExtractor
@ -23,7 +22,6 @@ class PinoyMoviesHub : MainAPI() {
page: Int, page: Int,
request: MainPageRequest request: MainPageRequest
): HomePageResponse { ): HomePageResponse {
val all = ArrayList<HomePageList>()
val doc = app.get(mainUrl).document val doc = app.get(mainUrl).document
val rows = listOfNotNull( val rows = listOfNotNull(
Pair("Suggestion", "div.items.featured"), Pair("Suggestion", "div.items.featured"),
@ -40,24 +38,20 @@ class PinoyMoviesHub : MainAPI() {
val maindoc = doc.selectFirst("div.module") val maindoc = doc.selectFirst("div.module")
?.select("div.content.full_width_layout.full") ?.select("div.content.full_width_layout.full")
rows.forEach { pair -> val all = rows.mapNotNull { pair ->
// Fetch row title // Fetch row title
val title = pair.first val title = pair.first
// Fetch list of items and map // Fetch list of items and map
//Log.i(TAG, "Title => $title") //Log.i(TAG, "Title => $title")
maindoc?.select(pair.second)?.let { inner -> val results = maindoc?.select(pair.second)?.select("article").getResults(this.name)
//Log.i(TAG, "inner => $inner") if (results.isEmpty()) {
val results = inner.select("article").getResults(this.name) return@mapNotNull null
if (results.isNotEmpty()) {
all.add(
HomePageList(
name = title,
list = results,
isHorizontalImages = false
)
)
}
} }
HomePageList(
name = title,
list = results,
isHorizontalImages = false
)
} }
return HomePageResponse(all) return HomePageResponse(all)
} }
@ -128,43 +122,37 @@ class PinoyMoviesHub : MainAPI() {
callback: (ExtractorLink) -> Unit callback: (ExtractorLink) -> Unit
): Boolean { ): Boolean {
try { //Log.i(TAG, "Loading ajax request..")
//Log.i(TAG, "Loading ajax request..") val requestLink = "${mainUrl}/wp-admin/admin-ajax.php"
val requestLink = "${mainUrl}/wp-admin/admin-ajax.php" val action = "doo_player_ajax"
val action = "doo_player_ajax" val nume = "1"
val nume = "1" val type = "movie"
val type = "movie" val doc = app.post(
val doc = app.post( url = requestLink,
url = requestLink, referer = mainUrl,
referer = mainUrl, headers = mapOf(
headers = mapOf( Pair("User-Agent", USER_AGENT),
Pair("User-Agent", USER_AGENT), Pair("Sec-Fetch-Mode", "cors")
Pair("Sec-Fetch-Mode", "cors") ),
), data = mapOf(
data = mapOf( Pair("action", action),
Pair("action", action), Pair("post", data),
Pair("post", data), Pair("nume", nume),
Pair("nume", nume), Pair("type", type)
Pair("type", type)
)
) )
//Log.i(TAG, "Response (${doc.code}) => ${doc.text}") )
AppUtils.tryParseJson<Response?>(doc.text)?.let { //Log.i(TAG, "Response (${doc.code}) => ${doc.text}")
val streamLink = it.embed_url ?: "" AppUtils.tryParseJson<Response?>(doc.text)?.let {
//Log.i(TAG, "Response (streamLink) => ${streamLink}") val streamLink = it.embed_url ?: ""
if (streamLink.isNotBlank()) { //Log.i(TAG, "Response (streamLink) => ${streamLink}")
loadExtractor( if (streamLink.isNotBlank()) {
url = streamLink, loadExtractor(
referer = mainUrl, url = streamLink,
callback = callback, referer = mainUrl,
subtitleCallback = subtitleCallback callback = callback,
) subtitleCallback = subtitleCallback
} )
} }
} catch (e: Exception) {
//Log.i(TAG, "Error => $e")
logError(e)
return false
} }
return true return true
} }