mirror of
				https://github.com/recloudstream/cloudstream.git
				synced 2024-08-15 01:53:11 +00:00 
			
		
		
		
	fixed base64 for testing and AllMoviesForYouProvider dood extractor
This commit is contained in:
		
							parent
							
								
									bf18e657f6
								
							
						
					
					
						commit
						94f0f30580
					
				
					 5 changed files with 51 additions and 22 deletions
				
			
		|  | @ -198,6 +198,15 @@ abstract class MainAPI { | |||
|     } | ||||
| } | ||||
| 
 | ||||
| /** Might need a different implementation for desktop*/ | ||||
| fun base64Decode(string: String): String { | ||||
|     return try { | ||||
|         String(android.util.Base64.decode(string, android.util.Base64.DEFAULT), Charsets.ISO_8859_1) | ||||
|     } catch (e: Exception) { | ||||
|         String(Base64.getDecoder().decode(string)) | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| class ErrorLoadingException(message: String? = null) : Exception(message) | ||||
| 
 | ||||
| fun parseRating(ratingString: String?): Int? { | ||||
|  |  | |||
|  | @ -1,16 +1,15 @@ | |||
| package com.lagradost.cloudstream3.animeproviders | ||||
| 
 | ||||
| import com.lagradost.cloudstream3.* | ||||
| import com.fasterxml.jackson.annotation.JsonProperty | ||||
| import com.fasterxml.jackson.module.kotlin.readValue | ||||
| import com.lagradost.cloudstream3.utils.ExtractorLink | ||||
| import com.lagradost.cloudstream3.* | ||||
| import com.lagradost.cloudstream3.mvvm.normalSafeApiCall | ||||
| import com.lagradost.cloudstream3.network.* | ||||
| import com.lagradost.cloudstream3.utils.ExtractorLink | ||||
| import com.lagradost.cloudstream3.utils.getQualityFromName | ||||
| import okhttp3.Response | ||||
| import org.jsoup.Jsoup | ||||
| import java.util.* | ||||
| import kotlin.collections.ArrayList | ||||
| 
 | ||||
| class AnimePaheProvider : MainAPI() { | ||||
|     companion object { | ||||
|  | @ -434,7 +433,7 @@ class AnimePaheProvider : MainAPI() { | |||
|             } | ||||
|         } | ||||
|         var returnValue = String(encodedUri.joinToString("").toByteArray(), Charsets.UTF_8) | ||||
|         returnValue = String(android.util.Base64.decode(returnValue, android.util.Base64.DEFAULT), Charsets.ISO_8859_1) | ||||
|         returnValue = base64Decode(returnValue) | ||||
|         return returnValue.slice(16..returnValue.length - 17) | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -5,10 +5,7 @@ import com.lagradost.cloudstream3.* | |||
| import com.lagradost.cloudstream3.network.get | ||||
| import com.lagradost.cloudstream3.network.text | ||||
| import com.lagradost.cloudstream3.network.url | ||||
| import com.lagradost.cloudstream3.utils.ExtractorLink | ||||
| import com.lagradost.cloudstream3.utils.Qualities | ||||
| import com.lagradost.cloudstream3.utils.getPostForm | ||||
| import com.lagradost.cloudstream3.utils.loadExtractor | ||||
| import com.lagradost.cloudstream3.utils.* | ||||
| import okio.Buffer | ||||
| import org.jsoup.Jsoup | ||||
| import org.jsoup.nodes.Document | ||||
|  | @ -63,7 +60,8 @@ class AllMoviesForYouProvider : MainAPI() { | |||
|         } | ||||
|         document.select("div.OptionBx")?.forEach { element -> | ||||
|             val baseElement = element.selectFirst("> a.Button") | ||||
|             if (element.selectFirst("> p.AAIco-dns")?.text() == "Streamhub") { | ||||
|             val elementText = element.selectFirst("> p.AAIco-dns")?.text() | ||||
|             if (elementText == "Streamhub" || elementText == "Dood") { | ||||
|                 baseElement?.attr("href")?.let { href -> | ||||
|                     list.add(href) | ||||
|                 } | ||||
|  | @ -108,7 +106,7 @@ class AllMoviesForYouProvider : MainAPI() { | |||
|                 if (episodes.isNotEmpty()) { | ||||
|                     episodes.forEach { episode -> | ||||
|                         val epNum = episode.selectFirst("> td > span.Num")?.text()?.toIntOrNull() | ||||
|                         val poster = episode.selectFirst("> td.MvTbImg > a > img")?.attr("src") | ||||
|                         val poster = episode.selectFirst("> td.MvTbImg > a > img")?.attr("data-src") | ||||
|                         val aName = episode.selectFirst("> td.MvTbTtl > a") | ||||
|                         val name = aName.text() | ||||
|                         val href = aName.attr("href") | ||||
|  | @ -165,6 +163,7 @@ class AllMoviesForYouProvider : MainAPI() { | |||
|         subtitleCallback: (SubtitleFile) -> Unit, | ||||
|         callback: (ExtractorLink) -> Unit | ||||
|     ): Boolean { | ||||
|         if (data == "about:blank") return false | ||||
|         if (data.startsWith("$mainUrl/episode/")) { | ||||
|             val response = get(data).text | ||||
|             getLink(Jsoup.parse(response))?.let { links -> | ||||
|  | @ -176,10 +175,11 @@ class AllMoviesForYouProvider : MainAPI() { | |||
|             } | ||||
|             return false | ||||
|         } else if (data.startsWith(mainUrl) && data != mainUrl) { | ||||
|             val realDataUrl = URLDecoder.decode(data, "application/x-www-form-urlencoded") | ||||
|             val realDataUrl = URLDecoder.decode(data, "UTF-8") | ||||
|             if (data.contains("trdownload")) { | ||||
|                 val request = get(data) | ||||
|                 if (request.url.startsWith("https://streamhub.to/d/")) { | ||||
|                 val requestUrl = request.url | ||||
|                 if (requestUrl.startsWith("https://streamhub.to/d/")) { | ||||
|                     val buffer = Buffer() | ||||
|                     val source = request.body?.source() | ||||
|                     var html = "" | ||||
|  | @ -191,13 +191,22 @@ class AllMoviesForYouProvider : MainAPI() { | |||
|                         tries += 1 | ||||
|                         html += buffer.readUtf8() | ||||
|                     } | ||||
|                     getPostForm(request.url,html)?.let { form -> | ||||
|                     getPostForm(request.url, html)?.let { form -> | ||||
|                         val postDocument = Jsoup.parse(form) | ||||
| 
 | ||||
|                         postDocument.selectFirst("a.downloadbtn")?.attr("href")?.let { url -> | ||||
|                             callback(ExtractorLink(this.name, this.name, url, mainUrl, Qualities.Unknown.value)) | ||||
|                         } | ||||
|                     } | ||||
|                 } else if (requestUrl.startsWith("https://dood")) { | ||||
|                     for (extractor in extractorApis) { | ||||
|                         if (requestUrl.startsWith(extractor.mainUrl)) { | ||||
|                             extractor.getSafeUrl(requestUrl)?.forEach { link -> | ||||
|                                 callback(link) | ||||
|                             } | ||||
|                             break | ||||
|                         } | ||||
|                     } | ||||
|                 } else { | ||||
|                     callback(ExtractorLink(this.name, this.name, realDataUrl, mainUrl, Qualities.Unknown.value)) | ||||
|                 } | ||||
|  |  | |||
|  | @ -264,7 +264,7 @@ class ThenosProvider : MainAPI() { | |||
|             val isM3u8 = source.type != "video/mp4" | ||||
|             val token = get("https://token.noss.workers.dev/").text | ||||
|             val authorization = | ||||
|                 String(android.util.Base64.decode(token, android.util.Base64.DEFAULT), Charsets.ISO_8859_1) | ||||
|                 base64Decode(token) | ||||
| 
 | ||||
|             callback.invoke( | ||||
|                 ExtractorLink( | ||||
|  |  | |||
|  | @ -1,5 +1,6 @@ | |||
| package com.lagradost.cloudstream3 | ||||
| 
 | ||||
| import com.lagradost.cloudstream3.movieproviders.ThenosProvider | ||||
| import com.lagradost.cloudstream3.mvvm.logError | ||||
| import com.lagradost.cloudstream3.utils.Qualities | ||||
| import com.lagradost.cloudstream3.utils.SubtitleHelper | ||||
|  | @ -39,7 +40,7 @@ class ProviderTests { | |||
|         return true | ||||
|     } | ||||
| 
 | ||||
|     private fun test_single_provider(api: MainAPI) { | ||||
|     private fun testSingleProviderApi(api: MainAPI) : Boolean { | ||||
|         val searchQueries = listOf("over", "iron", "guy") | ||||
|         var correctResponses = 0 | ||||
|         var searchResult: List<SearchResponse>? = null | ||||
|  | @ -62,8 +63,8 @@ class ProviderTests { | |||
|         } | ||||
| 
 | ||||
|         if (correctResponses == 0 || searchResult == null) { | ||||
|             println("Api ${api.name} did not return any valid search responses") | ||||
|             return | ||||
|             System.err.println("Api ${api.name} did not return any valid search responses") | ||||
|             return false | ||||
|         } | ||||
| 
 | ||||
|         try { | ||||
|  | @ -119,16 +120,18 @@ class ProviderTests { | |||
|                 Assert.fail("Provider has not implemented .load") | ||||
|             } | ||||
|             logError(e) | ||||
|             return false | ||||
|         } | ||||
|         return true | ||||
|     } | ||||
| 
 | ||||
|     @Test | ||||
|     fun providers_exist() { | ||||
|     fun providersExist() { | ||||
|         Assert.assertTrue(getAllProviders().isNotEmpty()) | ||||
|     } | ||||
| 
 | ||||
|     @Test | ||||
|     fun provider_correct_data() { | ||||
|     fun providerCorrectData() { | ||||
|         val isoNames = SubtitleHelper.languages.map { it.ISO_639_1 } | ||||
|         Assert.assertFalse("ISO does not contain any languages", isoNames.isNullOrEmpty()) | ||||
|         for (api in getAllProviders()) { | ||||
|  | @ -140,7 +143,7 @@ class ProviderTests { | |||
|     } | ||||
| 
 | ||||
|     @Test | ||||
|     fun provider_correct_homepage() { | ||||
|     fun providerCorrectHomepage() { | ||||
|         for (api in getAllProviders()) { | ||||
|             if (api.hasMainPage) { | ||||
|                 try { | ||||
|  | @ -167,12 +170,21 @@ class ProviderTests { | |||
|     } | ||||
| 
 | ||||
|     @Test | ||||
|     fun provider_correct() { | ||||
|     fun testSingleProvider() { | ||||
|         testSingleProviderApi(ThenosProvider()) | ||||
|     } | ||||
| 
 | ||||
|     @Test | ||||
|     fun providerCorrect() { | ||||
|         val providers = getAllProviders() | ||||
|         for ((index, api) in providers.withIndex()) { | ||||
|             try { | ||||
|                 println("Trying $api (${index + 1}/${providers.size})") | ||||
|                 test_single_provider(api) | ||||
|                 if(testSingleProviderApi(api)) { | ||||
|                     println("Success $api (${index + 1}/${providers.size})") | ||||
|                 } else { | ||||
|                     System.err.println("Error $api (${index + 1}/${providers.size})") | ||||
|                 } | ||||
|             } catch (e: Exception) { | ||||
|                 logError(e) | ||||
|             } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue