mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
Add sorting by release date
This commit is contained in:
parent
0c418fdf9b
commit
5f1dbd1056
8 changed files with 55 additions and 12 deletions
|
@ -5,6 +5,7 @@ import com.lagradost.cloudstream3.ui.SyncWatchType
|
|||
import com.lagradost.cloudstream3.ui.library.ListSorting
|
||||
import com.lagradost.cloudstream3.ui.result.UiText
|
||||
import me.xdrop.fuzzywuzzy.FuzzySearch
|
||||
import java.util.Date
|
||||
|
||||
interface SyncAPI : OAuth2API {
|
||||
/**
|
||||
|
@ -124,6 +125,8 @@ interface SyncAPI : OAuth2API {
|
|||
ListSorting.AlphabeticalZ -> items.sortedBy { it.name }.reversed()
|
||||
ListSorting.UpdatedNew -> items.sortedBy { it.lastUpdatedUnixTime?.times(-1) }
|
||||
ListSorting.UpdatedOld -> items.sortedBy { it.lastUpdatedUnixTime }
|
||||
ListSorting.ReleaseDateNew -> items.sortedByDescending { it.releaseDate }
|
||||
ListSorting.ReleaseDateOld -> items.sortedBy { it.releaseDate }
|
||||
else -> items
|
||||
}
|
||||
}
|
||||
|
@ -158,9 +161,10 @@ interface SyncAPI : OAuth2API {
|
|||
override var posterUrl: String?,
|
||||
override var posterHeaders: Map<String, String>?,
|
||||
override var quality: SearchQuality?,
|
||||
val releaseDate: Date?,
|
||||
override var id: Int? = null,
|
||||
val plot : String? = null,
|
||||
val rating: Int? = null,
|
||||
val tags: List<String>? = null,
|
||||
val tags: List<String>? = null
|
||||
) : SearchResponse
|
||||
}
|
|
@ -16,15 +16,16 @@ import com.lagradost.cloudstream3.syncproviders.SyncIdName
|
|||
import com.lagradost.cloudstream3.ui.SyncWatchType
|
||||
import com.lagradost.cloudstream3.ui.library.ListSorting
|
||||
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.AppUtils.parseJson
|
||||
import com.lagradost.cloudstream3.utils.AppUtils.toJson
|
||||
import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson
|
||||
import com.lagradost.cloudstream3.utils.Coroutines.ioSafe
|
||||
import com.lagradost.cloudstream3.utils.DataStore.toKotlinObject
|
||||
import com.lagradost.cloudstream3.utils.DataStoreHelper.toYear
|
||||
import java.net.URL
|
||||
import java.net.URLEncoder
|
||||
import java.util.*
|
||||
import java.util.Locale
|
||||
|
||||
class AniListApi(index: Int) : AccountManager(index), SyncAPI {
|
||||
override var name = "AniList"
|
||||
|
@ -631,8 +632,9 @@ class AniListApi(index: Int) : AccountManager(index), SyncAPI {
|
|||
?: this.media.coverImage.medium,
|
||||
null,
|
||||
null,
|
||||
this.media.seasonYear.toYear(),
|
||||
null,
|
||||
plot = this.media.description
|
||||
plot = this.media.description,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -689,6 +691,8 @@ class AniListApi(index: Int) : AccountManager(index), SyncAPI {
|
|||
ListSorting.AlphabeticalZ,
|
||||
ListSorting.UpdatedNew,
|
||||
ListSorting.UpdatedOld,
|
||||
ListSorting.ReleaseDateNew,
|
||||
ListSorting.ReleaseDateOld,
|
||||
ListSorting.RatingHigh,
|
||||
ListSorting.RatingLow,
|
||||
)
|
||||
|
|
|
@ -119,6 +119,8 @@ class LocalList : SyncAPI {
|
|||
ListSorting.AlphabeticalZ,
|
||||
ListSorting.UpdatedNew,
|
||||
ListSorting.UpdatedOld,
|
||||
ListSorting.ReleaseDateNew,
|
||||
ListSorting.ReleaseDateOld,
|
||||
// ListSorting.RatingHigh,
|
||||
// ListSorting.RatingLow,
|
||||
)
|
||||
|
|
|
@ -19,14 +19,18 @@ import com.lagradost.cloudstream3.syncproviders.SyncIdName
|
|||
import com.lagradost.cloudstream3.ui.SyncWatchType
|
||||
import com.lagradost.cloudstream3.ui.library.ListSorting
|
||||
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.AppUtils.parseJson
|
||||
import com.lagradost.cloudstream3.utils.DataStore.toKotlinObject
|
||||
import java.net.URL
|
||||
import java.security.SecureRandom
|
||||
import java.text.ParseException
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
import java.time.Instant
|
||||
import java.time.format.DateTimeFormatter
|
||||
import java.util.Calendar
|
||||
import java.util.Date
|
||||
import java.util.TimeZone
|
||||
|
||||
/** max 100 via https://myanimelist.net/apiconfig/references/api/v2#tag/anime */
|
||||
const val MAL_MAX_SEARCH_LIMIT = 25
|
||||
|
@ -247,7 +251,7 @@ class MALApi(index: Int) : AccountManager(index), SyncAPI {
|
|||
getDataAboutMalId(internalId)?.my_list_status //?: throw ErrorLoadingException("No my_list_status")
|
||||
return SyncAPI.SyncStatus(
|
||||
score = data?.score,
|
||||
status = SyncWatchType.fromInternalId(malStatusAsString.indexOf(data?.status)) ,
|
||||
status = SyncWatchType.fromInternalId(malStatusAsString.indexOf(data?.status)),
|
||||
isFavorite = null,
|
||||
watchedEpisodes = data?.num_episodes_watched,
|
||||
)
|
||||
|
@ -445,6 +449,12 @@ class MALApi(index: Int) : AccountManager(index), SyncAPI {
|
|||
null,
|
||||
null,
|
||||
plot = this.node.synopsis,
|
||||
releaseDate = if (this.node.start_date == null) null else Date.from(
|
||||
Instant.from(
|
||||
DateTimeFormatter.ofPattern(if (this.node.start_date.length == 4) "yyyy" else if (this.node.start_date.length == 7) "yyyy-MM" else "yyyy-MM-dd")
|
||||
.parse(this.node.start_date)
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -509,6 +519,8 @@ class MALApi(index: Int) : AccountManager(index), SyncAPI {
|
|||
ListSorting.AlphabeticalZ,
|
||||
ListSorting.UpdatedNew,
|
||||
ListSorting.UpdatedOld,
|
||||
ListSorting.ReleaseDateNew,
|
||||
ListSorting.ReleaseDateOld,
|
||||
ListSorting.RatingHigh,
|
||||
ListSorting.RatingLow,
|
||||
)
|
||||
|
|
|
@ -31,6 +31,7 @@ import com.lagradost.cloudstream3.ui.SyncWatchType
|
|||
import com.lagradost.cloudstream3.ui.library.ListSorting
|
||||
import com.lagradost.cloudstream3.ui.result.txt
|
||||
import com.lagradost.cloudstream3.utils.AppUtils.toJson
|
||||
import com.lagradost.cloudstream3.utils.DataStoreHelper.toYear
|
||||
import okhttp3.Interceptor
|
||||
import okhttp3.Response
|
||||
import java.math.BigInteger
|
||||
|
@ -669,7 +670,8 @@ class SimklApi(index: Int) : AccountManager(index), SyncAPI {
|
|||
this.movie.poster?.let { getPosterUrl(it) },
|
||||
null,
|
||||
null,
|
||||
movie.ids.simkl,
|
||||
this.movie.year?.toYear(),
|
||||
movie.ids.simkl
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -701,6 +703,7 @@ class SimklApi(index: Int) : AccountManager(index), SyncAPI {
|
|||
this.show.poster?.let { getPosterUrl(it) },
|
||||
null,
|
||||
null,
|
||||
this.show.year?.toYear(),
|
||||
show.ids.simkl
|
||||
)
|
||||
}
|
||||
|
@ -1026,6 +1029,8 @@ class SimklApi(index: Int) : AccountManager(index), SyncAPI {
|
|||
ListSorting.AlphabeticalZ,
|
||||
ListSorting.UpdatedNew,
|
||||
ListSorting.UpdatedOld,
|
||||
ListSorting.ReleaseDateNew,
|
||||
ListSorting.ReleaseDateOld,
|
||||
ListSorting.RatingHigh,
|
||||
ListSorting.RatingLow,
|
||||
)
|
||||
|
|
|
@ -21,6 +21,8 @@ enum class ListSorting(@StringRes val stringRes: Int) {
|
|||
RatingLow(R.string.sort_rating_asc),
|
||||
UpdatedNew(R.string.sort_updated_new),
|
||||
UpdatedOld(R.string.sort_updated_old),
|
||||
ReleaseDateNew(R.string.sort_release_date_new),
|
||||
ReleaseDateOld(R.string.sort_release_date_old),
|
||||
AlphabeticalA(R.string.sort_alphabetical_a),
|
||||
AlphabeticalZ(R.string.sort_alphabetical_z),
|
||||
}
|
||||
|
|
|
@ -2,8 +2,8 @@ package com.lagradost.cloudstream3.utils
|
|||
|
||||
import android.content.Context
|
||||
import com.fasterxml.jackson.annotation.JsonProperty
|
||||
import com.lagradost.cloudstream3.*
|
||||
import com.lagradost.cloudstream3.APIHolder.unixTimeMS
|
||||
import com.lagradost.cloudstream3.AcraApplication
|
||||
import com.lagradost.cloudstream3.AcraApplication.Companion.context
|
||||
import com.lagradost.cloudstream3.AcraApplication.Companion.getKey
|
||||
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.setKey
|
||||
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.SyncAPI
|
||||
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.VideoWatchState
|
||||
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.KProperty
|
||||
|
||||
|
@ -195,6 +205,8 @@ object DataStoreHelper {
|
|||
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.
|
||||
**/
|
||||
|
@ -242,7 +254,7 @@ object DataStoreHelper {
|
|||
null,
|
||||
null,
|
||||
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,
|
||||
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,
|
||||
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,4 +797,6 @@
|
|||
<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_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>
|
||||
</resources>
|
Loading…
Add table
Add a link
Reference in a new issue