mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
cbaca158fa
3 changed files with 54 additions and 37 deletions
|
@ -165,7 +165,7 @@ dependencies {
|
||||||
androidTestImplementation("androidx.test:core")
|
androidTestImplementation("androidx.test:core")
|
||||||
|
|
||||||
//implementation("io.karn:khttp-android:0.1.2") //okhttp instead
|
//implementation("io.karn:khttp-android:0.1.2") //okhttp instead
|
||||||
// implementation("org.jsoup:jsoup:1.13.1")
|
// implementation("org.jsoup:jsoup:1.13.1")
|
||||||
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.13.1")
|
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.13.1")
|
||||||
|
|
||||||
implementation("androidx.preference:preference-ktx:1.2.0")
|
implementation("androidx.preference:preference-ktx:1.2.0")
|
||||||
|
@ -220,8 +220,8 @@ dependencies {
|
||||||
implementation("androidx.work:work-runtime-ktx:2.8.1")
|
implementation("androidx.work:work-runtime-ktx:2.8.1")
|
||||||
|
|
||||||
// Networking
|
// Networking
|
||||||
// implementation("com.squareup.okhttp3:okhttp:4.9.2")
|
// implementation("com.squareup.okhttp3:okhttp:4.9.2")
|
||||||
// implementation("com.squareup.okhttp3:okhttp-dnsoverhttps:4.9.1")
|
// implementation("com.squareup.okhttp3:okhttp-dnsoverhttps:4.9.1")
|
||||||
implementation("com.github.Blatzar:NiceHttp:0.4.3")
|
implementation("com.github.Blatzar:NiceHttp:0.4.3")
|
||||||
// To fix SSL fuckery on android 9
|
// To fix SSL fuckery on android 9
|
||||||
implementation("org.conscrypt:conscrypt-android:2.2.1")
|
implementation("org.conscrypt:conscrypt-android:2.2.1")
|
||||||
|
@ -243,11 +243,9 @@ dependencies {
|
||||||
// used for subtitle decoding https://github.com/albfernandez/juniversalchardet
|
// used for subtitle decoding https://github.com/albfernandez/juniversalchardet
|
||||||
implementation("com.github.albfernandez:juniversalchardet:2.4.0")
|
implementation("com.github.albfernandez:juniversalchardet:2.4.0")
|
||||||
|
|
||||||
// slow af yt
|
|
||||||
//implementation("com.github.HaarigerHarald:android-youtubeExtractor:master-SNAPSHOT")
|
|
||||||
|
|
||||||
// newpipe yt taken from https://github.com/TeamNewPipe/NewPipe/blob/dev/app/build.gradle#L204
|
// newpipe yt taken from https://github.com/TeamNewPipe/NewPipe/blob/dev/app/build.gradle#L204
|
||||||
implementation("com.github.TeamNewPipe:NewPipeExtractor:8495ad619e")
|
// this should be updated frequently to avoid trailer fu*kery
|
||||||
|
implementation("com.github.TeamNewPipe:NewPipeExtractor:1f08d28")
|
||||||
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:1.1.6")
|
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:1.1.6")
|
||||||
|
|
||||||
// Library/extensions searching with Levenshtein distance
|
// Library/extensions searching with Levenshtein distance
|
||||||
|
|
|
@ -60,8 +60,8 @@ class SimklApi(index: Int) : AccountManager(index), SyncAPI {
|
||||||
private var lastScoreTime = -1L
|
private var lastScoreTime = -1L
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val clientId = BuildConfig.SIMKL_CLIENT_ID
|
private const val clientId: String = BuildConfig.SIMKL_CLIENT_ID
|
||||||
private const val clientSecret = BuildConfig.SIMKL_CLIENT_SECRET
|
private const val clientSecret: String = BuildConfig.SIMKL_CLIENT_SECRET
|
||||||
private var lastLoginState = ""
|
private var lastLoginState = ""
|
||||||
|
|
||||||
const val SIMKL_TOKEN_KEY: String = "simkl_token"
|
const val SIMKL_TOKEN_KEY: String = "simkl_token"
|
||||||
|
@ -498,6 +498,9 @@ class SimklApi(index: Int) : AccountManager(index), SyncAPI {
|
||||||
val episodes: Array<EpisodeMetadata>?,
|
val episodes: Array<EpisodeMetadata>?,
|
||||||
override var isFavorite: Boolean? = null,
|
override var isFavorite: Boolean? = null,
|
||||||
override var maxEpisodes: Int? = null,
|
override var maxEpisodes: Int? = null,
|
||||||
|
/** Save seen episodes separately to know the change from old to new.
|
||||||
|
* Required to remove seen episodes if count decreases */
|
||||||
|
val oldEpisodes: Int,
|
||||||
) : SyncAPI.AbstractSyncStatus()
|
) : SyncAPI.AbstractSyncStatus()
|
||||||
|
|
||||||
override suspend fun getStatus(id: String): SyncAPI.AbstractSyncStatus? {
|
override suspend fun getStatus(id: String): SyncAPI.AbstractSyncStatus? {
|
||||||
|
@ -521,7 +524,8 @@ class SimklApi(index: Int) : AccountManager(index), SyncAPI {
|
||||||
score = foundItem.user_rating,
|
score = foundItem.user_rating,
|
||||||
watchedEpisodes = foundItem.watched_episodes_count,
|
watchedEpisodes = foundItem.watched_episodes_count,
|
||||||
maxEpisodes = foundItem.total_episodes_count,
|
maxEpisodes = foundItem.total_episodes_count,
|
||||||
episodes = episodes
|
episodes = episodes,
|
||||||
|
oldEpisodes = foundItem.watched_episodes_count ?: 0,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
return if (searchResult != null) {
|
return if (searchResult != null) {
|
||||||
|
@ -530,7 +534,8 @@ class SimklApi(index: Int) : AccountManager(index), SyncAPI {
|
||||||
score = 0,
|
score = 0,
|
||||||
watchedEpisodes = 0,
|
watchedEpisodes = 0,
|
||||||
maxEpisodes = if (searchResult.type == "movie") 0 else null,
|
maxEpisodes = if (searchResult.type == "movie") 0 else null,
|
||||||
episodes = episodes
|
episodes = episodes,
|
||||||
|
oldEpisodes = 0,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
null
|
null
|
||||||
|
@ -604,32 +609,46 @@ class SimklApi(index: Int) : AccountManager(index), SyncAPI {
|
||||||
SimklListStatusType.ReWatching.value
|
SimklListStatusType.ReWatching.value
|
||||||
).contains(status.status)
|
).contains(status.status)
|
||||||
) {
|
) {
|
||||||
val cutEpisodes = simklStatus.episodes.take(watchedEpisodes)
|
suspend fun postEpisodes(
|
||||||
|
url: String,
|
||||||
val (seasons, episodes) = if (cutEpisodes.any { it.season != null }) {
|
rawEpisodes: List<EpisodeMetadata>
|
||||||
EpisodeMetadata.convertToSeasons(cutEpisodes) to null
|
): Boolean {
|
||||||
} else {
|
val (seasons, episodes) = if (rawEpisodes.any { it.season != null }) {
|
||||||
null to EpisodeMetadata.convertToEpisodes(cutEpisodes)
|
EpisodeMetadata.convertToSeasons(rawEpisodes) to null
|
||||||
|
} else {
|
||||||
|
null to EpisodeMetadata.convertToEpisodes(rawEpisodes)
|
||||||
|
}
|
||||||
|
debugPrint { "Synced history using $url: seasons=${seasons?.toList()}, episodes=${episodes?.toList()}" }
|
||||||
|
return app.post(
|
||||||
|
url,
|
||||||
|
json = StatusRequest(
|
||||||
|
shows = listOf(
|
||||||
|
HistoryMediaObject(
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
MediaObject.Ids.fromMap(parsedId),
|
||||||
|
seasons,
|
||||||
|
episodes
|
||||||
|
)
|
||||||
|
),
|
||||||
|
movies = emptyList()
|
||||||
|
),
|
||||||
|
interceptor = interceptor
|
||||||
|
).isSuccessful
|
||||||
}
|
}
|
||||||
|
|
||||||
debugPrint { "Synced history for ${status.watchedEpisodes} given size of ${simklStatus.episodes.size}: seasons=${seasons?.toList()}, episodes=${episodes?.toList()}" }
|
// If episodes decrease: remove all episodes beyond watched episodes.
|
||||||
val episodeResponse = app.post(
|
val removeResponse = if (simklStatus.oldEpisodes > watchedEpisodes) {
|
||||||
"$mainUrl/sync/history",
|
val removeEpisodes = simklStatus.episodes
|
||||||
json = StatusRequest(
|
.drop(watchedEpisodes)
|
||||||
shows = listOf(
|
postEpisodes("$mainUrl/sync/history/remove", removeEpisodes)
|
||||||
HistoryMediaObject(
|
} else {
|
||||||
null,
|
true
|
||||||
null,
|
}
|
||||||
MediaObject.Ids.fromMap(parsedId),
|
val cutEpisodes = simklStatus.episodes.take(watchedEpisodes)
|
||||||
seasons,
|
val addResponse = postEpisodes("$mainUrl/sync/history/", cutEpisodes)
|
||||||
episodes
|
|
||||||
)
|
removeResponse && addResponse
|
||||||
),
|
|
||||||
movies = emptyList()
|
|
||||||
),
|
|
||||||
interceptor = interceptor
|
|
||||||
)
|
|
||||||
episodeResponse.isSuccessful
|
|
||||||
} else true
|
} else true
|
||||||
|
|
||||||
val newStatus =
|
val newStatus =
|
||||||
|
|
|
@ -1707,7 +1707,7 @@ class ResultViewModel2 : ViewModel() {
|
||||||
else -> {
|
else -> {
|
||||||
if (response.type.isLiveStream())
|
if (response.type.isLiveStream())
|
||||||
R.string.play_livestream_button
|
R.string.play_livestream_button
|
||||||
else if (response.type.isMovieType()) // this wont break compatibility as you only need to override isMovieType
|
else if (response.isMovie()) // this wont break compatibility as you only need to override isMovieType
|
||||||
R.string.play_movie_button
|
R.string.play_movie_button
|
||||||
else null
|
else null
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue