forked from recloudstream/cloudstream
		
	fixed nicehttp
This commit is contained in:
		
							parent
							
								
									d4d083b3c3
								
							
						
					
					
						commit
						eb36315b04
					
				
					 6 changed files with 75 additions and 68 deletions
				
			
		|  | @ -156,7 +156,7 @@ dependencies { | ||||||
|     // Networking |     // Networking | ||||||
| //    implementation "com.squareup.okhttp3:okhttp:4.9.2" | //    implementation "com.squareup.okhttp3:okhttp:4.9.2" | ||||||
| //    implementation "com.squareup.okhttp3:okhttp-dnsoverhttps:4.9.1" | //    implementation "com.squareup.okhttp3:okhttp-dnsoverhttps:4.9.1" | ||||||
|     implementation 'com.github.Blatzar:NiceHttp:0.1.8' |     implementation 'com.github.Blatzar:NiceHttp:0.2.0' | ||||||
| 
 | 
 | ||||||
|     // Util to skip the URI file fuckery 🙏 |     // Util to skip the URI file fuckery 🙏 | ||||||
|     implementation "com.github.tachiyomiorg:unifile:17bec43" |     implementation "com.github.tachiyomiorg:unifile:17bec43" | ||||||
|  |  | ||||||
|  | @ -11,7 +11,7 @@ | ||||||
|     <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> <!-- Used for player vertical slide--> |     <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> <!-- Used for player vertical slide--> | ||||||
|     <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" /> <!--Used for app update--> |     <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" /> <!--Used for app update--> | ||||||
|     <!--<uses-permission android:name="com.android.providers.tv.permission.WRITE_EPG_DATA" /> not used atm, but code exist that requires it that are not run--> |     <!--<uses-permission android:name="com.android.providers.tv.permission.WRITE_EPG_DATA" /> not used atm, but code exist that requires it that are not run--> | ||||||
|     <permission android:name="android.permission.QUERY_ALL_PACKAGES" /> <!-- Used for getting if vlc is installed --> | <!--    <permission android:name="android.permission.QUERY_ALL_PACKAGES" /> <!– Used for getting if vlc is installed –>--> | ||||||
| 
 | 
 | ||||||
|     <!-- Fixes android tv fuckery --> |     <!-- Fixes android tv fuckery --> | ||||||
|     <uses-feature |     <uses-feature | ||||||
|  |  | ||||||
|  | @ -478,7 +478,7 @@ open class SflixProvider : MainAPI() { | ||||||
|             val data = negotiateNewSid(extractorData) ?: return null to null |             val data = negotiateNewSid(extractorData) ?: return null to null | ||||||
|             app.post( |             app.post( | ||||||
|                 "$extractorData&t=${generateTimeStamp()}&sid=${data.sid}", |                 "$extractorData&t=${generateTimeStamp()}&sid=${data.sid}", | ||||||
|                 data = 40, headers = headers |                 json = "40", headers = headers | ||||||
|             ) |             ) | ||||||
| 
 | 
 | ||||||
|             // This makes the second get request work, and re-connect work. |             // This makes the second get request work, and re-connect work. | ||||||
|  | @ -542,7 +542,7 @@ open class SflixProvider : MainAPI() { | ||||||
|                 val url = "${extractorData}&t=${generateTimeStamp()}&sid=${data.sid}" |                 val url = "${extractorData}&t=${generateTimeStamp()}&sid=${data.sid}" | ||||||
| 
 | 
 | ||||||
|                 getUpdatedData( |                 getUpdatedData( | ||||||
|                     app.post(url, data = authData, headers = headers), |                     app.post(url, json = authData, headers = headers), | ||||||
|                     data, |                     data, | ||||||
|                     extractorData |                     extractorData | ||||||
|                 ).also { |                 ).also { | ||||||
|  | @ -655,7 +655,7 @@ open class SflixProvider : MainAPI() { | ||||||
|             extractorData?.let { negotiateNewSid(it) }?.also { |             extractorData?.let { negotiateNewSid(it) }?.also { | ||||||
|                 app.post( |                 app.post( | ||||||
|                     "$extractorData&t=${generateTimeStamp()}&sid=${it.sid}", |                     "$extractorData&t=${generateTimeStamp()}&sid=${it.sid}", | ||||||
|                     data = "40", |                     json = "40", | ||||||
|                     timeout = 60 |                     timeout = 60 | ||||||
|                 ) |                 ) | ||||||
|                 val text = app.get( |                 val text = app.get( | ||||||
|  |  | ||||||
|  | @ -3,12 +3,12 @@ package com.lagradost.cloudstream3.movieproviders | ||||||
| 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.mvvm.logError | ||||||
| import com.lagradost.cloudstream3.utils.* |  | ||||||
| import com.lagradost.cloudstream3.utils.AppUtils.parseJson | import com.lagradost.cloudstream3.utils.AppUtils.parseJson | ||||||
|  | import com.lagradost.cloudstream3.utils.ExtractorLink | ||||||
|  | import com.lagradost.cloudstream3.utils.Qualities | ||||||
| import org.jsoup.Jsoup | import org.jsoup.Jsoup | ||||||
| import java.util.* |  | ||||||
| 
 | 
 | ||||||
| class SoaptwoDayProvider:MainAPI() { | class SoaptwoDayProvider : MainAPI() { | ||||||
|     override var mainUrl = "https://secretlink.xyz" //Probably a rip off, but it has no captcha |     override var mainUrl = "https://secretlink.xyz" //Probably a rip off, but it has no captcha | ||||||
|     override var name = "Soap2Day" |     override var name = "Soap2Day" | ||||||
|     override val hasMainPage = true |     override val hasMainPage = true | ||||||
|  | @ -18,6 +18,7 @@ class SoaptwoDayProvider:MainAPI() { | ||||||
|         TvType.Movie, |         TvType.Movie, | ||||||
|         TvType.TvSeries, |         TvType.TvSeries, | ||||||
|     ) |     ) | ||||||
|  | 
 | ||||||
|     override suspend fun getMainPage(): HomePageResponse { |     override suspend fun getMainPage(): HomePageResponse { | ||||||
|         val items = ArrayList<HomePageList>() |         val items = ArrayList<HomePageList>() | ||||||
|         val urls = listOf( |         val urls = listOf( | ||||||
|  | @ -27,19 +28,21 @@ class SoaptwoDayProvider:MainAPI() { | ||||||
|         for ((url, name) in urls) { |         for ((url, name) in urls) { | ||||||
|             try { |             try { | ||||||
|                 val soup = app.get(url).document |                 val soup = app.get(url).document | ||||||
|                 val home = soup.select("div.container div.row div.col-sm-12.col-lg-12 div.row div.col-sm-12.col-lg-12 .col-xs-6").map { |                 val home = | ||||||
|                     val title = it.selectFirst("h5 a")!!.text() |                     soup.select("div.container div.row div.col-sm-12.col-lg-12 div.row div.col-sm-12.col-lg-12 .col-xs-6") | ||||||
|                     val link = it.selectFirst("a")!!.attr("href") |                         .map { | ||||||
|                     TvSeriesSearchResponse( |                             val title = it.selectFirst("h5 a")!!.text() | ||||||
|                         title, |                             val link = it.selectFirst("a")!!.attr("href") | ||||||
|                         link, |                             TvSeriesSearchResponse( | ||||||
|                         this.name, |                                 title, | ||||||
|                         TvType.TvSeries, |                                 link, | ||||||
|                         fixUrl(it.selectFirst("img")!!.attr("src")), |                                 this.name, | ||||||
|                         null, |                                 TvType.TvSeries, | ||||||
|                         null, |                                 fixUrl(it.selectFirst("img")!!.attr("src")), | ||||||
|                     ) |                                 null, | ||||||
|                 } |                                 null, | ||||||
|  |                             ) | ||||||
|  |                         } | ||||||
| 
 | 
 | ||||||
|                 items.add(HomePageList(name, home)) |                 items.add(HomePageList(name, home)) | ||||||
|             } catch (e: Exception) { |             } catch (e: Exception) { | ||||||
|  | @ -51,34 +54,36 @@ class SoaptwoDayProvider:MainAPI() { | ||||||
| 
 | 
 | ||||||
|     override suspend fun search(query: String): List<SearchResponse> { |     override suspend fun search(query: String): List<SearchResponse> { | ||||||
|         val doc = app.get("$mainUrl/search/keyword/$query").document |         val doc = app.get("$mainUrl/search/keyword/$query").document | ||||||
|         return doc.select("div.container div.row div.col-sm-12.col-lg-12 div.row div.col-sm-12.col-lg-12 .col-xs-6").map { |         return doc.select("div.container div.row div.col-sm-12.col-lg-12 div.row div.col-sm-12.col-lg-12 .col-xs-6") | ||||||
|             val title = it.selectFirst("h5 a")!!.text() |             .map { | ||||||
|             val image = fixUrl(it.selectFirst("img")!!.attr("src")) |                 val title = it.selectFirst("h5 a")!!.text() | ||||||
|             val href = fixUrl(it.selectFirst("a")!!.attr("href")) |                 val image = fixUrl(it.selectFirst("img")!!.attr("src")) | ||||||
|             TvSeriesSearchResponse( |                 val href = fixUrl(it.selectFirst("a")!!.attr("href")) | ||||||
|                 title, |                 TvSeriesSearchResponse( | ||||||
|                 href, |                     title, | ||||||
|                 this.name, |                     href, | ||||||
|                 TvType.TvSeries, |                     this.name, | ||||||
|                 image, |                     TvType.TvSeries, | ||||||
|                 null, |                     image, | ||||||
|                 null |                     null, | ||||||
|             ) |                     null | ||||||
|         } |                 ) | ||||||
|  |             } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     override suspend fun load(url: String): LoadResponse? { |     override suspend fun load(url: String): LoadResponse? { | ||||||
|         val soup = app.get(url).document |         val soup = app.get(url).document | ||||||
|         val title = soup.selectFirst(".hidden-lg > div:nth-child(1) > h4")?.text() ?: "" |         val title = soup.selectFirst(".hidden-lg > div:nth-child(1) > h4")?.text() ?: "" | ||||||
|         val description = soup.selectFirst("p#wrap")?.text()?.trim() |         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 poster = | ||||||
|  |             soup.selectFirst(".col-md-5 > div:nth-child(1) > div:nth-child(1) > img")?.attr("src") | ||||||
|         val episodes = mutableListOf<Episode>() |         val episodes = mutableListOf<Episode>() | ||||||
|         soup.select("div.alert").forEach { |         soup.select("div.alert").forEach { | ||||||
|             val season = it?.selectFirst("h4")?.text()?.filter { c -> c.isDigit() }?.toIntOrNull() |             val season = it?.selectFirst("h4")?.text()?.filter { c -> c.isDigit() }?.toIntOrNull() | ||||||
|             it?.select("div > div > a")?.forEach { entry -> |             it?.select("div > div > a")?.forEach { entry -> | ||||||
|                 val link = fixUrlNull(entry?.attr("href")) ?: return@forEach |                 val link = fixUrlNull(entry?.attr("href")) ?: return@forEach | ||||||
|                 val text = entry?.text() ?: "" |                 val text = entry?.text() ?: "" | ||||||
|                 val name = text.replace(Regex("(^(\\d+)\\.)"),"") |                 val name = text.replace(Regex("(^(\\d+)\\.)"), "") | ||||||
|                 val epNum = text.substring(0, text.indexOf(".")).toIntOrNull() |                 val epNum = text.substring(0, text.indexOf(".")).toIntOrNull() | ||||||
|                 episodes.add( |                 episodes.add( | ||||||
|                     Episode( |                     Episode( | ||||||
|  | @ -149,7 +154,7 @@ class SoaptwoDayProvider:MainAPI() { | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     data class ServerJson ( |     data class ServerJson( | ||||||
|         @JsonProperty("0") val zero: String?, |         @JsonProperty("0") val zero: String?, | ||||||
|         @JsonProperty("key") val key: Boolean?, |         @JsonProperty("key") val key: Boolean?, | ||||||
|         @JsonProperty("val") val stream: String?, |         @JsonProperty("val") val stream: String?, | ||||||
|  | @ -163,7 +168,7 @@ class SoaptwoDayProvider:MainAPI() { | ||||||
|         @JsonProperty("next_epi_url") val nextEpiUrl: String? |         @JsonProperty("next_epi_url") val nextEpiUrl: String? | ||||||
|     ) |     ) | ||||||
| 
 | 
 | ||||||
|     data class Subs ( |     data class Subs( | ||||||
|         @JsonProperty("id") val id: Int?, |         @JsonProperty("id") val id: Int?, | ||||||
|         @JsonProperty("movieId") val movieId: Int?, |         @JsonProperty("movieId") val movieId: Int?, | ||||||
|         @JsonProperty("tvId") val tvId: Int?, |         @JsonProperty("tvId") val tvId: Int?, | ||||||
|  | @ -188,16 +193,19 @@ class SoaptwoDayProvider:MainAPI() { | ||||||
|         val idplayer2 = doc.selectFirst("#divP")?.text() |         val idplayer2 = doc.selectFirst("#divP")?.text() | ||||||
|         val movieid = doc.selectFirst("div.row input#hId")!!.attr("value") |         val movieid = doc.selectFirst("div.row input#hId")!!.attr("value") | ||||||
|         val tvType = try { |         val tvType = try { | ||||||
|             doc.selectFirst(".col-md-5 > div:nth-child(1) > div:nth-child(1) > img")!!.attr("src") ?: "" |             doc.selectFirst(".col-md-5 > div:nth-child(1) > div:nth-child(1) > img")!!.attr("src") | ||||||
|  |                 ?: "" | ||||||
|         } catch (e: Exception) { |         } catch (e: Exception) { | ||||||
|             "" |             "" | ||||||
|         } |         } | ||||||
|         val ajaxlink = if (tvType.contains("movie")) "$mainUrl/home/index/GetMInfoAjax" else "$mainUrl/home/index/GetEInfoAjax" |         val ajaxlink = | ||||||
|  |             if (tvType.contains("movie")) "$mainUrl/home/index/GetMInfoAjax" else "$mainUrl/home/index/GetEInfoAjax" | ||||||
|         listOf( |         listOf( | ||||||
|             idplayer, |             idplayer, | ||||||
|             idplayer2, |             idplayer2, | ||||||
|         ).mapNotNull { playerID -> |         ).mapNotNull { playerID -> | ||||||
|             val url = app.post(ajaxlink, |             val url = app.post( | ||||||
|  |                 ajaxlink, | ||||||
|                 headers = mapOf( |                 headers = mapOf( | ||||||
|                     "Host" to "secretlink.xyz", |                     "Host" to "secretlink.xyz", | ||||||
|                     "User-Agent" to USER_AGENT, |                     "User-Agent" to USER_AGENT, | ||||||
|  | @ -211,32 +219,35 @@ class SoaptwoDayProvider:MainAPI() { | ||||||
|                     "Referer" to data, |                     "Referer" to data, | ||||||
|                     "Sec-Fetch-Dest" to "empty", |                     "Sec-Fetch-Dest" to "empty", | ||||||
|                     "Sec-Fetch-Mode" to "cors", |                     "Sec-Fetch-Mode" to "cors", | ||||||
|                     "Sec-Fetch-Site" to "same-origin",), |                     "Sec-Fetch-Site" to "same-origin", | ||||||
|  |                 ), | ||||||
|                 data = mapOf( |                 data = mapOf( | ||||||
|                     Pair("pass",movieid), |                     Pair("pass", movieid), | ||||||
|                     Pair("param",playerID), |                     Pair("param", playerID ?: ""), | ||||||
|                 ) |                 ) | ||||||
|             ).text.replace("\\\"","\"").replace("\"{","{").replace("}\"","}") |             ).text.replace("\\\"", "\"").replace("\"{", "{").replace("}\"", "}") | ||||||
|                 .replace("\\\\\\/","\\/") |                 .replace("\\\\\\/", "\\/") | ||||||
|             val json = parseJson<ServerJson>(url) |             val json = parseJson<ServerJson>(url) | ||||||
|             listOfNotNull( |             listOfNotNull( | ||||||
|                 json.stream, |                 json.stream, | ||||||
|                 json.streambackup |                 json.streambackup | ||||||
|             ).apmap { stream -> |             ).apmap { stream -> | ||||||
|                 val cleanstreamurl = stream.replace("\\/","/").replace("\\\\\\","") |                 val cleanstreamurl = stream.replace("\\/", "/").replace("\\\\\\", "") | ||||||
|                 if (cleanstreamurl.isNotBlank()) { |                 if (cleanstreamurl.isNotBlank()) { | ||||||
|                     callback(ExtractorLink( |                     callback( | ||||||
|                         "Soap2Day", |                         ExtractorLink( | ||||||
|                         "Soap2Day", |                             "Soap2Day", | ||||||
|                         cleanstreamurl, |                             "Soap2Day", | ||||||
|                         "https://soap2day.ac", |                             cleanstreamurl, | ||||||
|                         Qualities.Unknown.value, |                             "https://soap2day.ac", | ||||||
|                         isM3u8 = false |                             Qualities.Unknown.value, | ||||||
|                     )) |                             isM3u8 = false | ||||||
|  |                         ) | ||||||
|  |                     ) | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|             json.subs?.forEach { subtitle -> |             json.subs?.forEach { subtitle -> | ||||||
|                 val sublink = mainUrl+subtitle.path |                 val sublink = mainUrl + subtitle.path | ||||||
|                 listOf( |                 listOf( | ||||||
|                     sublink, |                     sublink, | ||||||
|                     subtitle.downlink |                     subtitle.downlink | ||||||
|  |  | ||||||
|  | @ -211,12 +211,6 @@ class WebViewResolver(val interceptUrl: Regex, val additionalUrls: List<Regex> = | ||||||
|             this.method, |             this.method, | ||||||
|             webViewUrl, |             webViewUrl, | ||||||
|             this.requestHeaders, |             this.requestHeaders, | ||||||
|             null, |  | ||||||
|             emptyMap(), |  | ||||||
|             emptyMap(), |  | ||||||
|             null, |  | ||||||
|             10, |  | ||||||
|             TimeUnit.MINUTES |  | ||||||
|         ) |         ) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -613,16 +613,18 @@ class MALApi(index: Int) : AccountManager(index), SyncAPI { | ||||||
|         score: Int? = null, |         score: Int? = null, | ||||||
|         num_watched_episodes: Int? = null, |         num_watched_episodes: Int? = null, | ||||||
|     ): String? { |     ): String? { | ||||||
|  |         val data = mapOf( | ||||||
|  |             "status" to status, | ||||||
|  |             "score" to score?.toString(), | ||||||
|  |             "num_watched_episodes" to num_watched_episodes?.toString() | ||||||
|  |         ).filter { it.value != null } as Map<String, String> | ||||||
|  | 
 | ||||||
|         return app.put( |         return app.put( | ||||||
|             "https://api.myanimelist.net/v2/anime/$id/my_list_status", |             "https://api.myanimelist.net/v2/anime/$id/my_list_status", | ||||||
|             headers = mapOf( |             headers = mapOf( | ||||||
|                 "Authorization" to "Bearer " + (getAuth() ?: return null) |                 "Authorization" to "Bearer " + (getAuth() ?: return null) | ||||||
|             ), |             ), | ||||||
|             data = mapOf( |             data = data | ||||||
|                 "status" to status, |  | ||||||
|                 "score" to score?.toString(), |  | ||||||
|                 "num_watched_episodes" to num_watched_episodes?.toString() |  | ||||||
|             ) |  | ||||||
|         ).text |         ).text | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue