mirror of
				https://github.com/hexated/cloudstream-extensions-hexated.git
				synced 2024-08-15 00:03:22 +00:00 
			
		
		
		
	[test] added lib support in YugenAnime
This commit is contained in:
		
							parent
							
								
									15370e9c14
								
							
						
					
					
						commit
						c4a5dfe065
					
				
					 2 changed files with 47 additions and 1 deletions
				
			
		|  | @ -1,5 +1,5 @@ | |||
| // use an integer for version numbers | ||||
| version = 3 | ||||
| version = 4 | ||||
| 
 | ||||
| 
 | ||||
| cloudstream { | ||||
|  |  | |||
|  | @ -5,6 +5,7 @@ import com.lagradost.cloudstream3.* | |||
| import com.lagradost.cloudstream3.LoadResponse.Companion.addAniListId | ||||
| import com.lagradost.cloudstream3.LoadResponse.Companion.addMalId | ||||
| import com.lagradost.cloudstream3.LoadResponse.Companion.addTrailer | ||||
| import com.lagradost.cloudstream3.syncproviders.SyncIdName | ||||
| import com.lagradost.cloudstream3.utils.ExtractorLink | ||||
| import com.lagradost.cloudstream3.utils.M3u8Helper | ||||
| import org.jsoup.nodes.Document | ||||
|  | @ -18,6 +19,11 @@ class YugenAnime : MainAPI() { | |||
|     override var lang = "en" | ||||
|     override val hasDownloadSupport = true | ||||
| 
 | ||||
|     override val supportedSyncNames = setOf( | ||||
|         SyncIdName.Anilist, | ||||
|         SyncIdName.MyAnimeList | ||||
|     ) | ||||
| 
 | ||||
|     override val supportedTypes = setOf( | ||||
|         TvType.Anime, | ||||
|         TvType.AnimeMovie, | ||||
|  | @ -25,6 +31,9 @@ class YugenAnime : MainAPI() { | |||
|     ) | ||||
| 
 | ||||
|     companion object { | ||||
|         private const val consumetAnilist = "https://api.consumet.org/meta/anilist" | ||||
|         private const val consumetMal = "https://api.consumet.org/meta/mal" | ||||
| 
 | ||||
|         fun getType(t: String): TvType { | ||||
|             return if (t.contains("OVA", true) || t.contains("Special", true)) TvType.OVA | ||||
|             else if (t.contains("Movie", true)) TvType.AnimeMovie | ||||
|  | @ -81,6 +90,28 @@ class YugenAnime : MainAPI() { | |||
|         } | ||||
|     } | ||||
| 
 | ||||
|     override suspend fun getLoadUrl(name: SyncIdName, id: String): String? { | ||||
|         val syncId = id.split("/").last() | ||||
|         val url = if (name == SyncIdName.Anilist) { | ||||
|             "${consumetAnilist}/info/$syncId" | ||||
|         } else { | ||||
|             "${consumetMal}/info/$syncId" | ||||
|         } | ||||
|         val res = app.get(url).parsedSafe<SyncInfo>() | ||||
| 
 | ||||
|         val title = res?.title?.romaji ?: res?.title?.english | ||||
|         val year = res?.startDate?.year | ||||
|         val season = res?.season | ||||
| 
 | ||||
|         val document = app.get("$mainUrl/discover/?q=$title").document | ||||
|         val syncUrl = document.select("div.cards-grid a.anime-meta").find { | ||||
|             it.attr("title").equals(title, true) || it.select("div.anime-details span").text().equals("$season $year", true) | ||||
|         }?.attr("href") | ||||
| 
 | ||||
|         return fixUrl(syncUrl ?: return null) | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     override suspend fun load(url: String): LoadResponse? { | ||||
|         val document = app.get(url).document | ||||
| 
 | ||||
|  | @ -185,4 +216,19 @@ class YugenAnime : MainAPI() { | |||
|         @JsonProperty("hls") val hls: List<String>? = null, | ||||
|     ) | ||||
| 
 | ||||
|     data class SyncTitle( | ||||
|         @JsonProperty("romaji") val romaji: String? = null, | ||||
|         @JsonProperty("english") val english: String? = null, | ||||
|     ) | ||||
| 
 | ||||
|     data class StartDate( | ||||
|         @JsonProperty("year") val year: Int? = null, | ||||
|     ) | ||||
| 
 | ||||
|     data class SyncInfo( | ||||
|         @JsonProperty("title") val title: SyncTitle? = null, | ||||
|         @JsonProperty("startDate") val startDate: StartDate? = null, | ||||
|         @JsonProperty("season") val season: String? = null, | ||||
|     ) | ||||
| 
 | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue