mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-29 16:30:31 +05:30
Fix playlist importing issues
This commit is contained in:
parent
a096247c94
commit
296ca42a19
@ -157,8 +157,9 @@ object PlaylistsHelper {
|
|||||||
|
|
||||||
suspend fun importPlaylists(playlists: List<ImportPlaylist>) = withContext(Dispatchers.IO) {
|
suspend fun importPlaylists(playlists: List<ImportPlaylist>) = withContext(Dispatchers.IO) {
|
||||||
playlists.map { playlist ->
|
playlists.map { playlist ->
|
||||||
|
val playlistId = createPlaylist(playlist.name!!, null)
|
||||||
async {
|
async {
|
||||||
val playlistId = createPlaylist(playlist.name!!, null) ?: return@async
|
playlistId ?: return@async
|
||||||
// if logged in, add the playlists by their ID via an api call
|
// if logged in, add the playlists by their ID via an api call
|
||||||
if (loggedIn) {
|
if (loggedIn) {
|
||||||
addToPlaylist(
|
addToPlaylist(
|
||||||
@ -171,8 +172,17 @@ object PlaylistsHelper {
|
|||||||
// if not logged in, all video information needs to become fetched manually
|
// if not logged in, all video information needs to become fetched manually
|
||||||
runCatching {
|
runCatching {
|
||||||
val streamItems = playlist.videos.map {
|
val streamItems = playlist.videos.map {
|
||||||
async { RetrofitInstance.api.getStreams(it).toStreamItem(it) }
|
async {
|
||||||
}.awaitAll()
|
try {
|
||||||
|
RetrofitInstance.api.getStreams(it).toStreamItem(it)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.awaitAll()
|
||||||
|
.filterNotNull()
|
||||||
|
|
||||||
addToPlaylist(playlistId, *streamItems.toTypedArray())
|
addToPlaylist(playlistId, *streamItems.toTypedArray())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user