Merge pull request #2400 from Bnyro/master

Make YT playlist import language independent
This commit is contained in:
Bnyro 2022-12-16 16:29:10 +01:00 committed by GitHub
commit bebb0d465e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -121,8 +121,8 @@ class ImportHelper(
activity.contentResolver.openInputStream(uri)?.use { activity.contentResolver.openInputStream(uri)?.use {
val lines = it.bufferedReader().readLines() val lines = it.bufferedReader().readLines()
playlist.name = lines[1].split(",").reversed()[2] playlist.name = lines[1].split(",").reversed()[2]
val splitIndex = lines.indexOfFirst { line -> line.startsWith("Video ID") } val splitIndex = lines.indexOfFirst { line -> line.isBlank() }
lines.subList(splitIndex + 1, lines.size).forEach { line -> lines.subList(splitIndex + 2, lines.size).forEach { line ->
line.split(",").firstOrNull()?.let { videoId -> line.split(",").firstOrNull()?.let { videoId ->
if (videoId.isNotBlank()) playlist.videos = playlist.videos + videoId if (videoId.isNotBlank()) playlist.videos = playlist.videos + videoId
} }