mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
Add sorting by release date (#1206)
This commit is contained in:
parent
82f8ab489e
commit
150ad5fc9f
8 changed files with 53 additions and 10 deletions
|
@ -5,6 +5,7 @@ import com.lagradost.cloudstream3.ui.SyncWatchType
|
||||||
import com.lagradost.cloudstream3.ui.library.ListSorting
|
import com.lagradost.cloudstream3.ui.library.ListSorting
|
||||||
import com.lagradost.cloudstream3.ui.result.UiText
|
import com.lagradost.cloudstream3.ui.result.UiText
|
||||||
import me.xdrop.fuzzywuzzy.FuzzySearch
|
import me.xdrop.fuzzywuzzy.FuzzySearch
|
||||||
|
import java.util.Date
|
||||||
|
|
||||||
interface SyncAPI : OAuth2API {
|
interface SyncAPI : OAuth2API {
|
||||||
/**
|
/**
|
||||||
|
@ -124,6 +125,8 @@ interface SyncAPI : OAuth2API {
|
||||||
ListSorting.AlphabeticalZ -> items.sortedBy { it.name }.reversed()
|
ListSorting.AlphabeticalZ -> items.sortedBy { it.name }.reversed()
|
||||||
ListSorting.UpdatedNew -> items.sortedBy { it.lastUpdatedUnixTime?.times(-1) }
|
ListSorting.UpdatedNew -> items.sortedBy { it.lastUpdatedUnixTime?.times(-1) }
|
||||||
ListSorting.UpdatedOld -> items.sortedBy { it.lastUpdatedUnixTime }
|
ListSorting.UpdatedOld -> items.sortedBy { it.lastUpdatedUnixTime }
|
||||||
|
ListSorting.ReleaseDateNew -> items.sortedByDescending { it.releaseDate }
|
||||||
|
ListSorting.ReleaseDateOld -> items.sortedBy { it.releaseDate }
|
||||||
else -> items
|
else -> items
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -158,9 +161,10 @@ interface SyncAPI : OAuth2API {
|
||||||
override var posterUrl: String?,
|
override var posterUrl: String?,
|
||||||
override var posterHeaders: Map<String, String>?,
|
override var posterHeaders: Map<String, String>?,
|
||||||
override var quality: SearchQuality?,
|
override var quality: SearchQuality?,
|
||||||
|
val releaseDate: Date?,
|
||||||
override var id: Int? = null,
|
override var id: Int? = null,
|
||||||
val plot : String? = null,
|
val plot : String? = null,
|
||||||
val rating: Int? = null,
|
val rating: Int? = null,
|
||||||
val tags: List<String>? = null,
|
val tags: List<String>? = null
|
||||||
) : SearchResponse
|
) : SearchResponse
|
||||||
}
|
}
|
|
@ -16,15 +16,16 @@ import com.lagradost.cloudstream3.syncproviders.SyncIdName
|
||||||
import com.lagradost.cloudstream3.ui.SyncWatchType
|
import com.lagradost.cloudstream3.ui.SyncWatchType
|
||||||
import com.lagradost.cloudstream3.ui.library.ListSorting
|
import com.lagradost.cloudstream3.ui.library.ListSorting
|
||||||
import com.lagradost.cloudstream3.ui.result.txt
|
import com.lagradost.cloudstream3.ui.result.txt
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.parseJson
|
|
||||||
import com.lagradost.cloudstream3.utils.AppContextUtils.splitQuery
|
import com.lagradost.cloudstream3.utils.AppContextUtils.splitQuery
|
||||||
|
import com.lagradost.cloudstream3.utils.AppUtils.parseJson
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.toJson
|
import com.lagradost.cloudstream3.utils.AppUtils.toJson
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson
|
import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson
|
||||||
import com.lagradost.cloudstream3.utils.Coroutines.ioSafe
|
import com.lagradost.cloudstream3.utils.Coroutines.ioSafe
|
||||||
import com.lagradost.cloudstream3.utils.DataStore.toKotlinObject
|
import com.lagradost.cloudstream3.utils.DataStore.toKotlinObject
|
||||||
|
import com.lagradost.cloudstream3.utils.DataStoreHelper.toYear
|
||||||
import java.net.URL
|
import java.net.URL
|
||||||
import java.net.URLEncoder
|
import java.net.URLEncoder
|
||||||
import java.util.*
|
import java.util.Locale
|
||||||
|
|
||||||
class AniListApi(index: Int) : AccountManager(index), SyncAPI {
|
class AniListApi(index: Int) : AccountManager(index), SyncAPI {
|
||||||
override var name = "AniList"
|
override var name = "AniList"
|
||||||
|
@ -631,8 +632,9 @@ class AniListApi(index: Int) : AccountManager(index), SyncAPI {
|
||||||
?: this.media.coverImage.medium,
|
?: this.media.coverImage.medium,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
|
this.media.seasonYear.toYear(),
|
||||||
null,
|
null,
|
||||||
plot = this.media.description
|
plot = this.media.description,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -689,6 +691,8 @@ class AniListApi(index: Int) : AccountManager(index), SyncAPI {
|
||||||
ListSorting.AlphabeticalZ,
|
ListSorting.AlphabeticalZ,
|
||||||
ListSorting.UpdatedNew,
|
ListSorting.UpdatedNew,
|
||||||
ListSorting.UpdatedOld,
|
ListSorting.UpdatedOld,
|
||||||
|
ListSorting.ReleaseDateNew,
|
||||||
|
ListSorting.ReleaseDateOld,
|
||||||
ListSorting.RatingHigh,
|
ListSorting.RatingHigh,
|
||||||
ListSorting.RatingLow,
|
ListSorting.RatingLow,
|
||||||
)
|
)
|
||||||
|
|
|
@ -119,6 +119,11 @@ class LocalList : SyncAPI {
|
||||||
ListSorting.AlphabeticalZ,
|
ListSorting.AlphabeticalZ,
|
||||||
ListSorting.UpdatedNew,
|
ListSorting.UpdatedNew,
|
||||||
ListSorting.UpdatedOld,
|
ListSorting.UpdatedOld,
|
||||||
|
ListSorting.ReleaseDateNew,
|
||||||
|
ListSorting.ReleaseDateOld,
|
||||||
|
// ListSorting.RatingHigh,
|
||||||
|
// ListSorting.RatingLow,
|
||||||
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ import java.security.SecureRandom
|
||||||
import java.text.ParseException
|
import java.text.ParseException
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
|
import java.time.format.DateTimeFormatter
|
||||||
import java.util.Calendar
|
import java.util.Calendar
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
@ -448,6 +449,12 @@ class MALApi(index: Int) : AccountManager(index), SyncAPI {
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
plot = this.node.synopsis,
|
plot = this.node.synopsis,
|
||||||
|
releaseDate = if (this.node.startDate == null) null else try {Date.from(
|
||||||
|
Instant.from(
|
||||||
|
DateTimeFormatter.ofPattern(if (this.node.startDate.length == 4) "yyyy" else if (this.node.startDate.length == 7) "yyyy-MM" else "yyyy-MM-dd")
|
||||||
|
.parse(this.node.startDate)
|
||||||
|
)
|
||||||
|
)} catch (_: RuntimeException) {null}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -512,6 +519,8 @@ class MALApi(index: Int) : AccountManager(index), SyncAPI {
|
||||||
ListSorting.AlphabeticalZ,
|
ListSorting.AlphabeticalZ,
|
||||||
ListSorting.UpdatedNew,
|
ListSorting.UpdatedNew,
|
||||||
ListSorting.UpdatedOld,
|
ListSorting.UpdatedOld,
|
||||||
|
ListSorting.ReleaseDateNew,
|
||||||
|
ListSorting.ReleaseDateOld,
|
||||||
ListSorting.RatingHigh,
|
ListSorting.RatingHigh,
|
||||||
ListSorting.RatingLow,
|
ListSorting.RatingLow,
|
||||||
)
|
)
|
||||||
|
|
|
@ -31,6 +31,7 @@ import com.lagradost.cloudstream3.ui.SyncWatchType
|
||||||
import com.lagradost.cloudstream3.ui.library.ListSorting
|
import com.lagradost.cloudstream3.ui.library.ListSorting
|
||||||
import com.lagradost.cloudstream3.ui.result.txt
|
import com.lagradost.cloudstream3.ui.result.txt
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.toJson
|
import com.lagradost.cloudstream3.utils.AppUtils.toJson
|
||||||
|
import com.lagradost.cloudstream3.utils.DataStoreHelper.toYear
|
||||||
import okhttp3.Interceptor
|
import okhttp3.Interceptor
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import java.math.BigInteger
|
import java.math.BigInteger
|
||||||
|
@ -670,7 +671,8 @@ class SimklApi(index: Int) : AccountManager(index), SyncAPI {
|
||||||
this.movie.poster?.let { getPosterUrl(it) },
|
this.movie.poster?.let { getPosterUrl(it) },
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
movie.ids.simkl,
|
this.movie.year?.toYear(),
|
||||||
|
movie.ids.simkl
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -702,6 +704,7 @@ class SimklApi(index: Int) : AccountManager(index), SyncAPI {
|
||||||
this.show.poster?.let { getPosterUrl(it) },
|
this.show.poster?.let { getPosterUrl(it) },
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
|
this.show.year?.toYear(),
|
||||||
show.ids.simkl
|
show.ids.simkl
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -1027,6 +1030,8 @@ class SimklApi(index: Int) : AccountManager(index), SyncAPI {
|
||||||
ListSorting.AlphabeticalZ,
|
ListSorting.AlphabeticalZ,
|
||||||
ListSorting.UpdatedNew,
|
ListSorting.UpdatedNew,
|
||||||
ListSorting.UpdatedOld,
|
ListSorting.UpdatedOld,
|
||||||
|
ListSorting.ReleaseDateNew,
|
||||||
|
ListSorting.ReleaseDateOld,
|
||||||
ListSorting.RatingHigh,
|
ListSorting.RatingHigh,
|
||||||
ListSorting.RatingLow,
|
ListSorting.RatingLow,
|
||||||
)
|
)
|
||||||
|
|
|
@ -23,6 +23,8 @@ enum class ListSorting(@StringRes val stringRes: Int) {
|
||||||
UpdatedOld(R.string.sort_updated_old),
|
UpdatedOld(R.string.sort_updated_old),
|
||||||
AlphabeticalA(R.string.sort_alphabetical_a),
|
AlphabeticalA(R.string.sort_alphabetical_a),
|
||||||
AlphabeticalZ(R.string.sort_alphabetical_z),
|
AlphabeticalZ(R.string.sort_alphabetical_z),
|
||||||
|
ReleaseDateNew(R.string.sort_release_date_new),
|
||||||
|
ReleaseDateOld(R.string.sort_release_date_old),
|
||||||
}
|
}
|
||||||
|
|
||||||
const val LAST_SYNC_API_KEY = "last_sync_api"
|
const val LAST_SYNC_API_KEY = "last_sync_api"
|
||||||
|
@ -132,4 +134,4 @@ class LibraryViewModel : ViewModel() {
|
||||||
MainActivity.reloadLibraryEvent -= ::reloadPages
|
MainActivity.reloadLibraryEvent -= ::reloadPages
|
||||||
super.onCleared()
|
super.onCleared()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,8 @@ package com.lagradost.cloudstream3.utils
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty
|
import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
import com.lagradost.cloudstream3.*
|
|
||||||
import com.lagradost.cloudstream3.APIHolder.unixTimeMS
|
import com.lagradost.cloudstream3.APIHolder.unixTimeMS
|
||||||
|
import com.lagradost.cloudstream3.AcraApplication
|
||||||
import com.lagradost.cloudstream3.AcraApplication.Companion.context
|
import com.lagradost.cloudstream3.AcraApplication.Companion.context
|
||||||
import com.lagradost.cloudstream3.AcraApplication.Companion.getKey
|
import com.lagradost.cloudstream3.AcraApplication.Companion.getKey
|
||||||
import com.lagradost.cloudstream3.AcraApplication.Companion.getKeys
|
import com.lagradost.cloudstream3.AcraApplication.Companion.getKeys
|
||||||
|
@ -11,6 +11,13 @@ import com.lagradost.cloudstream3.AcraApplication.Companion.removeKey
|
||||||
import com.lagradost.cloudstream3.AcraApplication.Companion.removeKeys
|
import com.lagradost.cloudstream3.AcraApplication.Companion.removeKeys
|
||||||
import com.lagradost.cloudstream3.AcraApplication.Companion.setKey
|
import com.lagradost.cloudstream3.AcraApplication.Companion.setKey
|
||||||
import com.lagradost.cloudstream3.CommonActivity.showToast
|
import com.lagradost.cloudstream3.CommonActivity.showToast
|
||||||
|
import com.lagradost.cloudstream3.DubStatus
|
||||||
|
import com.lagradost.cloudstream3.EpisodeResponse
|
||||||
|
import com.lagradost.cloudstream3.MainActivity
|
||||||
|
import com.lagradost.cloudstream3.R
|
||||||
|
import com.lagradost.cloudstream3.SearchQuality
|
||||||
|
import com.lagradost.cloudstream3.SearchResponse
|
||||||
|
import com.lagradost.cloudstream3.TvType
|
||||||
import com.lagradost.cloudstream3.syncproviders.AccountManager
|
import com.lagradost.cloudstream3.syncproviders.AccountManager
|
||||||
import com.lagradost.cloudstream3.syncproviders.SyncAPI
|
import com.lagradost.cloudstream3.syncproviders.SyncAPI
|
||||||
import com.lagradost.cloudstream3.ui.WatchType
|
import com.lagradost.cloudstream3.ui.WatchType
|
||||||
|
@ -18,6 +25,9 @@ import com.lagradost.cloudstream3.ui.library.ListSorting
|
||||||
import com.lagradost.cloudstream3.ui.result.UiImage
|
import com.lagradost.cloudstream3.ui.result.UiImage
|
||||||
import com.lagradost.cloudstream3.ui.result.VideoWatchState
|
import com.lagradost.cloudstream3.ui.result.VideoWatchState
|
||||||
import com.lagradost.cloudstream3.utils.AppContextUtils.filterProviderByPreferredMedia
|
import com.lagradost.cloudstream3.utils.AppContextUtils.filterProviderByPreferredMedia
|
||||||
|
import java.util.Calendar
|
||||||
|
import java.util.Date
|
||||||
|
import java.util.GregorianCalendar
|
||||||
import kotlin.reflect.KClass
|
import kotlin.reflect.KClass
|
||||||
import kotlin.reflect.KProperty
|
import kotlin.reflect.KProperty
|
||||||
|
|
||||||
|
@ -195,6 +205,8 @@ object DataStoreHelper {
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun Int.toYear() : Date = GregorianCalendar.getInstance().also { it.set(Calendar.YEAR, this) }.time
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to display notifications on new episodes and posters in library.
|
* Used to display notifications on new episodes and posters in library.
|
||||||
**/
|
**/
|
||||||
|
@ -242,7 +254,7 @@ object DataStoreHelper {
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
latestUpdatedTime,
|
latestUpdatedTime,
|
||||||
apiName, type, posterUrl, posterHeaders, quality, this.id, plot = this.plot, rating = this.rating, tags = this.tags
|
apiName, type, posterUrl, posterHeaders, quality, year?.toYear(), this.id, plot = this.plot, rating = this.rating, tags = this.tags
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -273,7 +285,7 @@ object DataStoreHelper {
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
latestUpdatedTime,
|
latestUpdatedTime,
|
||||||
apiName, type, posterUrl, posterHeaders, quality, this.id, plot = this.plot, rating = this.rating, tags = this.tags
|
apiName, type, posterUrl, posterHeaders, quality, year?.toYear(), this.id, plot = this.plot, rating = this.rating, tags = this.tags
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -304,7 +316,7 @@ object DataStoreHelper {
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
latestUpdatedTime,
|
latestUpdatedTime,
|
||||||
apiName, type, posterUrl, posterHeaders, quality, this.id, plot = this.plot, rating = this.rating, tags = this.tags
|
apiName, type, posterUrl, posterHeaders, quality, year?.toYear(), this.id, plot = this.plot, rating = this.rating, tags = this.tags
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -797,6 +797,8 @@
|
||||||
<string name="device_pin_error_message">Can\'t get the device PIN code, try local authentication</string>
|
<string name="device_pin_error_message">Can\'t get the device PIN code, try local authentication</string>
|
||||||
<string name="device_pin_expired_message">PIN code is now expired !</string>
|
<string name="device_pin_expired_message">PIN code is now expired !</string>
|
||||||
<string name="device_pin_counter_text">Code expires in %1$dm %2$ds</string>
|
<string name="device_pin_counter_text">Code expires in %1$dm %2$ds</string>
|
||||||
|
<string name="sort_release_date_new">Release Date (New to Old)</string>
|
||||||
|
<string name="sort_release_date_old">Release Date (Old to New)</string>
|
||||||
<string name="hide_player_control_names_key" translatable="false">hide_player_control_names_key</string>
|
<string name="hide_player_control_names_key" translatable="false">hide_player_control_names_key</string>
|
||||||
<string name="hide_player_control_names">Hide names of the player\'s controls</string>
|
<string name="hide_player_control_names">Hide names of the player\'s controls</string>
|
||||||
</resources>
|
</resources>
|
Loading…
Reference in a new issue