mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-12 21:30:30 +05:30
Merge pull request #6846 from Bnyro/master
refactor: simplify ImportHelper#importPlaylists
This commit is contained in:
commit
26dd1c3c76
@ -191,9 +191,7 @@ object ImportHelper {
|
||||
ImportFormat.YOUTUBECSV -> {
|
||||
val playlist = PipedImportPlaylist()
|
||||
activity.contentResolver.openInputStream(uri)?.use { inputStream ->
|
||||
val lines = inputStream.bufferedReader().use { reader ->
|
||||
reader.lines().collect(Collectors.toList())
|
||||
}
|
||||
val lines = inputStream.bufferedReader().readLines()
|
||||
// invalid playlist file, hence returning
|
||||
if (lines.size < 2) return
|
||||
|
||||
@ -214,12 +212,13 @@ object ImportHelper {
|
||||
for (line in lines.subList(startIndex, lines.size)) {
|
||||
if (line.isBlank()) continue
|
||||
|
||||
line.split(",")
|
||||
val videoId = line.split(",")
|
||||
.firstOrNull()
|
||||
?.takeIf { it.isNotBlank() }
|
||||
?.let { videoId ->
|
||||
playlist.videos += videoId.trim()
|
||||
}
|
||||
|
||||
if (videoId != null) {
|
||||
playlist.videos += videoId.trim()
|
||||
}
|
||||
}
|
||||
importPlaylists.add(playlist)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user