mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-12 21:30:30 +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 {
|
||||
// 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
|
||||
val streams = playlist.videos.chunked(
|
||||
MAX_CONCURRENT_IMPORT_CALLS
|
||||
).map { videos ->
|
||||
videos.parallelMap {
|
||||
for (videoIdList in playlist.videos.chunked(MAX_CONCURRENT_IMPORT_CALLS)) {
|
||||
val streams = videoIdList.parallelMap {
|
||||
runCatching { StreamsExtractor.extractStreams(it) }
|
||||
.getOrNull()
|
||||
?.toStreamItem(it)
|
||||
}.filterNotNull()
|
||||
}.flatten()
|
||||
|
||||
addToPlaylist(playlistId, *streams.toTypedArray())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getAllPlaylistsWithVideos(playlistIds: List<String>? = null): List<Playlist> =
|
||||
withContext(Dispatchers.IO) {
|
||||
|
Loading…
Reference in New Issue
Block a user