From 7330403b970b879269cb3cbacc7c434fb0c86bd3 Mon Sep 17 00:00:00 2001 From: KingLucius Date: Thu, 6 Jul 2023 15:07:16 +0300 Subject: [PATCH] SoraStreamKids --- SoraStream/build.gradle.kts | 2 +- .../src/main/kotlin/com/hexated/SoraStream.kt | 6 +-- .../main/kotlin/com/hexated/SoraStreamKids.kt | 46 +++++++++++++++++++ .../kotlin/com/hexated/SoraStreamPlugin.kt | 1 + 4 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 SoraStream/src/main/kotlin/com/hexated/SoraStreamKids.kt diff --git a/SoraStream/build.gradle.kts b/SoraStream/build.gradle.kts index 65ee9df5..e9cda9c9 100644 --- a/SoraStream/build.gradle.kts +++ b/SoraStream/build.gradle.kts @@ -26,7 +26,7 @@ cloudstream { // All of these properties are optional, you can safely remove them description = "#1 best extention based on MultiAPI" - authors = listOf("Hexated", "Sora") + authors = listOf("Hexated", "Sora", "KingLucius") /** * Status int as the following: diff --git a/SoraStream/src/main/kotlin/com/hexated/SoraStream.kt b/SoraStream/src/main/kotlin/com/hexated/SoraStream.kt index faf0f2c7..301e9685 100644 --- a/SoraStream/src/main/kotlin/com/hexated/SoraStream.kt +++ b/SoraStream/src/main/kotlin/com/hexated/SoraStream.kt @@ -77,13 +77,13 @@ open class SoraStream : TmdbProvider() { /** AUTHOR : Hexated & Sora */ companion object { /** TOOLS */ - private const val tmdbAPI = "https://api.themoviedb.org/3" + const val tmdbAPI = "https://api.themoviedb.org/3" const val gdbot = "https://gdtot.pro" const val anilistAPI = "https://graphql.anilist.co" const val malsyncAPI = "https://api.malsync.moe" const val consumetHelper = "https://api.consumet.org/anime/9anime/helper" - private val apiKey = + val apiKey = base64DecodeAPI("ZTM=NTg=MjM=MjM=ODc=MzI=OGQ=MmE=Nzk=Nzk=ZjI=NTA=NDY=NDA=MzA=YjA=") // PLEASE DON'T STEAL /** ALL SOURCES */ @@ -225,7 +225,7 @@ open class SoraStream : TmdbProvider() { return newHomePageResponse(request.name, home) } - private fun Media.toSearchResponse(type: String? = null): SearchResponse? { + fun Media.toSearchResponse(type: String? = null): SearchResponse? { return newMovieSearchResponse( title ?: name ?: originalTitle ?: return null, Data(id = id, type = mediaType ?: type).toJson(), diff --git a/SoraStream/src/main/kotlin/com/hexated/SoraStreamKids.kt b/SoraStream/src/main/kotlin/com/hexated/SoraStreamKids.kt new file mode 100644 index 00000000..7e9ffe26 --- /dev/null +++ b/SoraStream/src/main/kotlin/com/hexated/SoraStreamKids.kt @@ -0,0 +1,46 @@ +package com.hexated + +import com.lagradost.cloudstream3.* +import java.time.LocalDateTime +import java.time.format.DateTimeFormatter + +class SoraStreamKids : SoraStream() { + override var name = "SoraStream-Kids" + val mainURL = "$tmdbAPI/discover/movie?api_key=$apiKey" + + override val supportedTypes = setOf( + TvType.Movie, + ) + + val todaydate = LocalDateTime.now() + val minimumday = todaydate.minusDays(40) + val dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd") + val todayFormatted = todaydate.format(dateFormatter) + val minimumdayFormatted = minimumday.format(dateFormatter) + val thisyear = todaydate.year + + override val mainPage = mainPageOf( + "$mainURL&language=en-US&sort_by=popularity.desc&with_genres=16&with_original_language=en" to "Popular Movies", + "$mainURL&language=en-US&primary_release_date.gte=$minimumdayFormatted&primary_release_date.lte=$todayFormatted&sort_by=popularity.desc&with_genres=16&with_original_language=en&without_keywords=263548" to "Now Playing", + "$mainURL&language=en-US&primary_release_date.gte=$todayFormatted&primary_release_date.lte=$thisyear-12-31&sort_by=popularity.desc&with_genres=16&with_original_language=en&without_keywords=263548" to "Upcoming Movies", + "$mainURL&language=en-US&sort_by=vote_average.desc&vote_count.gte=200&with_genres=16&with_original_language=en&without_keywords=263548" to "Top Rated Movies", + "$mainURL&language=en-US&sort_by=vote_average.desc&vote_count.gte=200&with_companies=3&with_genres=16&with_original_language=en&without_keywords=263548" to "Pixar", + "$mainURL&language=en-US&sort_by=vote_average.desc&vote_count.gte=200&with_companies=3&with_genres=16&with_keywords=263548&with_original_language=en" to "Pixar Short Films", + "$mainURL&language=en-US&sort_by=vote_average.desc&vote_count.gte=200&with_companies=6125|2&with_genres=16&with_original_language=en&without_companies=3&without_keywords=263548" to "Walt Disney", + "$mainURL&language=en-US&sort_by=vote_average.desc&vote_count.gte=200&with_companies=7|521&with_genres=16&with_original_language=en&without_keywords=263548" to "DreamWorks", + "$mainURL&language=en-US&sort_by=vote_average.desc&vote_count.gte=200&with_companies=2251&with_genres=16&with_original_language=en&without_keywords=263548" to "Sony", + ) + + override suspend fun getMainPage( + page: Int, + request: MainPageRequest + ): HomePageResponse { + val type = if (request.data.contains("/movie")) "movie" else "tv" + val home = app.get("${request.data}&page=$page") + .parsedSafe()?.results + ?.mapNotNull { media -> + media.toSearchResponse(type) + } ?: throw ErrorLoadingException("Invalid Json reponse") + return newHomePageResponse(request.name, home) + } +} \ No newline at end of file diff --git a/SoraStream/src/main/kotlin/com/hexated/SoraStreamPlugin.kt b/SoraStream/src/main/kotlin/com/hexated/SoraStreamPlugin.kt index 27f4b152..3bf770dc 100644 --- a/SoraStream/src/main/kotlin/com/hexated/SoraStreamPlugin.kt +++ b/SoraStream/src/main/kotlin/com/hexated/SoraStreamPlugin.kt @@ -11,5 +11,6 @@ class SoraStreamPlugin: Plugin() { // All providers should be added in this manner. Please don't edit the providers list directly. registerMainAPI(SoraStream()) registerMainAPI(SoraStreamLite()) + registerMainAPI(SoraStreamKids()) } } \ No newline at end of file