From cbe8b74496bb720ad68d892912b9e3342c64c6a6 Mon Sep 17 00:00:00 2001 From: Luna712 <142361265+Luna712@users.noreply.github.com> Date: Sat, 28 Dec 2024 20:01:52 -0700 Subject: [PATCH 1/2] Add new TVTypes for generic Audio and Podcast --- .../ui/result/ResultViewModel2.kt | 4 ++++ app/src/main/res/values/strings.xml | 2 ++ .../com/lagradost/cloudstream3/MainAPI.kt | 22 ++++++++++++++++--- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultViewModel2.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultViewModel2.kt index d86420724c..7d039b7fa6 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultViewModel2.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultViewModel2.kt @@ -249,6 +249,8 @@ fun LoadResponse.toResultData(repo: APIRepository): ResultData { TvType.Music -> R.string.music_singlar TvType.AudioBook -> R.string.audio_book_singular TvType.CustomMedia -> R.string.custom_media_singluar + TvType.Audio -> R.string.audio_singluar + TvType.Podcast -> R.string.podcast_singluar } ), yearText = txt(year?.toString()), @@ -650,6 +652,8 @@ class ResultViewModel2 : ViewModel() { TvType.Music -> "Music" TvType.AudioBook -> "AudioBooks" TvType.CustomMedia -> "Media" + TvType.Audio -> "Audio" + TvType.Podcast -> "Podcasts" } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 5d0c3d3df4..6c35b8bf95 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -373,6 +373,8 @@ Music Audio Book Media + Audio + Podcast Source error Remote error Renderer error diff --git a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/MainAPI.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/MainAPI.kt index 50dd667b45..a1b03b29d9 100644 --- a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/MainAPI.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/MainAPI.kt @@ -681,8 +681,11 @@ enum class TvType(value: Int?) { Music(13), AudioBook(14), - /** Wont load the built in player, make your own interaction */ + /** Won't load the built in player, make your own interaction */ CustomMedia(15), + + Audio(16), + Podcast(17), } public enum class AutoDownloadMode(val value: Int) { @@ -698,9 +701,22 @@ public enum class AutoDownloadMode(val value: Int) { } } -// IN CASE OF FUTURE ANIME MOVIE OR SMTH fun TvType.isMovieType(): Boolean { - return this == TvType.Movie || this == TvType.AnimeMovie || this == TvType.Torrent || this == TvType.Live + return this in listOf( + TvType.AnimeMovie, + TvType.Live, + TvType.Movie, + TvType.Torrent + ) +} + +fun TvType.isAudioType(): Boolean { + return this in listOf( + TvType.Audio, + TvType.AudioBook, + TvType.Music, + TvType.Podcast + ) } fun TvType.isLiveStream(): Boolean { From d22605402381976510e046510656d1aca7b0032c Mon Sep 17 00:00:00 2001 From: Luna712 <142361265+Luna712@users.noreply.github.com> Date: Sat, 28 Dec 2024 21:02:54 -0700 Subject: [PATCH 2/2] Use when --- .../kotlin/com/lagradost/cloudstream3/MainAPI.kt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/MainAPI.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/MainAPI.kt index a1b03b29d9..fb5ef8479c 100644 --- a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/MainAPI.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/MainAPI.kt @@ -702,21 +702,23 @@ public enum class AutoDownloadMode(val value: Int) { } fun TvType.isMovieType(): Boolean { - return this in listOf( + return when (this) { TvType.AnimeMovie, TvType.Live, TvType.Movie, - TvType.Torrent - ) + TvType.Torrent -> true + else -> false + } } fun TvType.isAudioType(): Boolean { - return this in listOf( + return when (this) { TvType.Audio, TvType.AudioBook, TvType.Music, - TvType.Podcast - ) + TvType.Podcast -> true + else -> false + } } fun TvType.isLiveStream(): Boolean {