mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-28 16:00:31 +05:30
Merge pull request #6865 from Bnyro/master
refactor: directly add loaded videos to playlist to improve UX
This commit is contained in:
commit
589bd45c01
@ -184,19 +184,18 @@ object PlaylistsHelper {
|
|||||||
} else {
|
} else {
|
||||||
// if not logged in, all video information needs to become fetched manually
|
// if not logged in, all video information needs to become fetched manually
|
||||||
// Only do so with `MAX_CONCURRENT_IMPORT_CALLS` videos at once to prevent performance issues
|
// Only do so with `MAX_CONCURRENT_IMPORT_CALLS` videos at once to prevent performance issues
|
||||||
val streams = playlist.videos.chunked(
|
for (videoIdList in playlist.videos.chunked(MAX_CONCURRENT_IMPORT_CALLS)) {
|
||||||
MAX_CONCURRENT_IMPORT_CALLS
|
val streams = videoIdList.parallelMap {
|
||||||
).map { videos ->
|
|
||||||
videos.parallelMap {
|
|
||||||
runCatching { StreamsExtractor.extractStreams(it) }
|
runCatching { StreamsExtractor.extractStreams(it) }
|
||||||
.getOrNull()
|
.getOrNull()
|
||||||
?.toStreamItem(it)
|
?.toStreamItem(it)
|
||||||
}.filterNotNull()
|
}.filterNotNull()
|
||||||
}.flatten()
|
|
||||||
addToPlaylist(playlistId, *streams.toTypedArray())
|
addToPlaylist(playlistId, *streams.toTypedArray())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
suspend fun getAllPlaylistsWithVideos(playlistIds: List<String>? = null): List<Playlist> =
|
suspend fun getAllPlaylistsWithVideos(playlistIds: List<String>? = null): List<Playlist> =
|
||||||
withContext(Dispatchers.IO) {
|
withContext(Dispatchers.IO) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user