Skip to content

Commit 4100e9d

Browse files
cuong-tranjmir1
andauthored
fix(video-list): Properly call sortVideos/sort (#2058)
Co-authored-by: jmir1 <[email protected]>
1 parent 17f8b99 commit 4100e9d

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

app/src/main/java/eu/kanade/tachiyomi/ui/player/loader/EpisodeLoader.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,11 @@ class EpisodeLoader {
6666
// TODO(1.6): Remove else block when dropping support for ext lib <1.6
6767
return if (source.javaClass.declaredMethods.any { it.name == "getHosterList" }) {
6868
source.getHosterList(episode.toSEpisode())
69+
.let { source.run { it.sortHosters() } }
6970
} else {
70-
source.getVideoList(episode.toSEpisode()).toHosterList()
71+
source.getVideoList(episode.toSEpisode())
72+
.let { source.run { it.sortVideos() } }
73+
.toHosterList()
7174
}
7275
}
7376

@@ -142,7 +145,9 @@ class EpisodeLoader {
142145
* @param hoster the hoster.
143146
*/
144147
private suspend fun getVideosOnHttp(source: AnimeHttpSource, hoster: Hoster): List<Video> {
145-
return source.getVideoList(hoster).parseVideoUrls(source)
148+
return source.getVideoList(hoster)
149+
.let { source.run { it.sortVideos() } }
150+
.parseVideoUrls(source)
146151
}
147152

148153
// TODO(1.6): Remove after ext lib bump

source-api/src/commonMain/kotlin/eu/kanade/tachiyomi/animesource/online/AnimeHttpSource.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ abstract class AnimeHttpSource : AnimeCatalogueSource {
304304
return client.newCall(hosterListRequest(episode))
305305
.awaitSuccess()
306306
.let { response ->
307-
hosterListParse(response).sortHosters()
307+
hosterListParse(response)
308308
}
309309
}
310310

@@ -340,7 +340,7 @@ abstract class AnimeHttpSource : AnimeCatalogueSource {
340340
return client.newCall(videoListRequest(hoster))
341341
.awaitSuccess()
342342
.let { response ->
343-
videoListParse(response, hoster).sortVideos()
343+
videoListParse(response, hoster)
344344
}
345345
}
346346

@@ -385,18 +385,17 @@ abstract class AnimeHttpSource : AnimeCatalogueSource {
385385
* @param episode the episode.
386386
* @return the videos for the episode.
387387
*/
388-
@Suppress("DEPRECATION")
389388
override suspend fun getVideoList(episode: SEpisode): List<Video> {
389+
@Suppress("DEPRECATION")
390390
return fetchVideoList(episode).awaitSingle()
391391
}
392392

393-
@Suppress("DEPRECATION")
394393
@Deprecated("Use the non-RxJava API instead", replaceWith = ReplaceWith("getVideoList"))
395394
override fun fetchVideoList(episode: SEpisode): Observable<List<Video>> {
396395
return client.newCall(videoListRequest(episode))
397396
.asObservableSuccess()
398397
.map { response ->
399-
videoListParse(response).sort()
398+
videoListParse(response)
400399
}
401400
}
402401

@@ -422,7 +421,7 @@ abstract class AnimeHttpSource : AnimeCatalogueSource {
422421
*
423422
* @since extensions-lib 16
424423
*/
425-
protected open fun List<Hoster>.sortHosters(): List<Hoster> {
424+
open fun List<Hoster>.sortHosters(): List<Hoster> {
426425
return this
427426
}
428427

@@ -431,8 +430,9 @@ abstract class AnimeHttpSource : AnimeCatalogueSource {
431430
*
432431
* @since extensions-lib 16
433432
*/
434-
protected open fun List<Video>.sortVideos(): List<Video> {
435-
return this
433+
open fun List<Video>.sortVideos(): List<Video> {
434+
@Suppress("DEPRECATION")
435+
return sort()
436436
}
437437

438438
/**

0 commit comments

Comments
 (0)