fix duplicated importing

This commit is contained in:
Bnyro 2022-12-01 15:05:57 +01:00
parent b4100bd27c
commit 7c775f4937
2 changed files with 6 additions and 7 deletions

View File

@ -185,6 +185,7 @@ object PlaylistsHelper {
suspend fun importPlaylists(appContext: Context, playlists: List<ImportPlaylist>) {
for (playlist in playlists) {
Log.e("playlist", playlist.toString())
val playlistId = createPlaylist(playlist.name!!, appContext) ?: continue
runBlocking {
val tasks = playlist.videos.map { videoId ->
@ -210,7 +211,7 @@ object PlaylistsHelper {
type = "playlist",
visibility = "private",
videos = list.relatedStreams.orEmpty().map {
YOUTUBE_FRONTEND_URL + it.url!!.toID()
YOUTUBE_FRONTEND_URL + "/watch?v=" + it.url!!.toID()
}
)
)

View File

@ -114,15 +114,13 @@ class ImportHelper(
val playlistFile = ObjectMapper().readValue(uri.readText(), ImportPlaylistFile::class.java)
playlistFile.playlists.orEmpty().forEach {
CoroutineScope(Dispatchers.IO).launch {
playlistFile.playlists?.let {
PlaylistsHelper.importPlaylists(activity, it)
}
CoroutineScope(Dispatchers.IO).launch {
playlistFile.playlists?.let {
PlaylistsHelper.importPlaylists(activity, it)
}
}
activity.toastFromMainThread(R.string.importsuccess)
activity.toastFromMainThread(R.string.success)
}
/**