@@ -4,6 +4,7 @@ import com.lagradost.cloudstream3.*
44import com.lagradost.cloudstream3.utils.*
55import com.lagradost.cloudstream3.utils.AppUtils.parseJson
66import com.lagradost.cloudstream3.utils.AppUtils.toJson
7+ import com.lagradost.cloudstream3.network.CloudflareKiller
78import com.fasterxml.jackson.annotation.JsonProperty
89import java.net.ServerSocket
910import java.net.Socket
@@ -204,9 +205,9 @@ class BinTVProvider : MainAPI() {
204205 // Fetch PPV matches
205206 val ppvMatches = mutableListOf<EventLoadData >()
206207 val ppvUrls = listOf (
208+ " https://api.ppv.cx/api/streams" ,
207209 " https://old.ppv.to/api/streams" ,
208- " https://api.ppv.to/api/streams" ,
209- " https://api.ppv.cx/api/streams"
210+ " https://api.ppv.to/api/streams"
210211 )
211212 val ppvHeaders = mapOf (
212213 " User-Agent" to " Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Mobile Safari/537.36" ,
@@ -217,7 +218,15 @@ class BinTVProvider : MainAPI() {
217218 var ppvText = " "
218219 for (url in ppvUrls) {
219220 try {
220- val res = app.get(url, headers = ppvHeaders, timeout = 15L )
221+ val res = if (url.contains(" api.ppv.cx" )) {
222+ app.get(url, headers = ppvHeaders, interceptor = cfInterceptor, timeout = 20L )
223+ } else {
224+ try {
225+ app.get(url, headers = ppvHeaders, timeout = 15L )
226+ } catch (e: Exception ) {
227+ app.get(url, headers = ppvHeaders, interceptor = cfInterceptor, timeout = 20L )
228+ }
229+ }
221230 if (res.code == 200 && res.text.isNotBlank()) {
222231 ppvText = res.text
223232 break
@@ -548,11 +557,20 @@ class BinTVProvider : MainAPI() {
548557 " Origin" to (embedHost ? : " https://bintv.net" )
549558 )
550559
551- val embedHtml = try {
552- app.get(embedUrl, headers = fetchHeaders, timeout = 20L ).text
560+ var embedHtml = " "
561+ try {
562+ val res = app.get(embedUrl, headers = fetchHeaders, timeout = 20L )
563+ embedHtml = res.text
564+ if (embedHtml.contains(" Just a moment" ) || res.code == 403 ) {
565+ embedHtml = app.get(embedUrl, headers = fetchHeaders, interceptor = cfInterceptor, timeout = 20L ).text
566+ }
553567 } catch (fetchErr: Exception ) {
554568 println (" BinTV: Failed to fetch embed page $embedUrl - ${fetchErr.message} " )
555- " "
569+ try {
570+ embedHtml = app.get(embedUrl, headers = fetchHeaders, interceptor = cfInterceptor, timeout = 20L ).text
571+ } catch (cfErr: Exception ) {
572+ println (" BinTV: Failed to fetch embed page with CloudflareKiller - ${cfErr.message} " )
573+ }
556574 }
557575
558576 // Search for m3u8 links
@@ -608,6 +626,7 @@ class BinTVProvider : MainAPI() {
608626 }
609627
610628 companion object {
629+ private val cfInterceptor = CloudflareKiller ()
611630 private var serverSocket: ServerSocket ? = null
612631 private var port: Int = 0
613632
0 commit comments