Merge pull request #6865 from Bnyro/master

refactor: directly add loaded videos to playlist to improve UX
This commit is contained in:
Bnyro 2024-12-07 20:29:51 +01:00 committed by GitHub
commit 589bd45c01
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -184,16 +184,15 @@ 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())
addToPlaylist(playlistId, *streams.toTypedArray())
}
}
}
}