mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-01-06 01:20:29 +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 -> {
|
ImportFormat.YOUTUBECSV -> {
|
||||||
val playlist = PipedImportPlaylist()
|
val playlist = PipedImportPlaylist()
|
||||||
activity.contentResolver.openInputStream(uri)?.use { inputStream ->
|
activity.contentResolver.openInputStream(uri)?.use { inputStream ->
|
||||||
val lines = inputStream.bufferedReader().use { reader ->
|
val lines = inputStream.bufferedReader().readLines()
|
||||||
reader.lines().collect(Collectors.toList())
|
|
||||||
}
|
|
||||||
// invalid playlist file, hence returning
|
// invalid playlist file, hence returning
|
||||||
if (lines.size < 2) return
|
if (lines.size < 2) return
|
||||||
|
|
||||||
@ -214,12 +212,13 @@ object ImportHelper {
|
|||||||
for (line in lines.subList(startIndex, lines.size)) {
|
for (line in lines.subList(startIndex, lines.size)) {
|
||||||
if (line.isBlank()) continue
|
if (line.isBlank()) continue
|
||||||
|
|
||||||
line.split(",")
|
val videoId = line.split(",")
|
||||||
.firstOrNull()
|
.firstOrNull()
|
||||||
?.takeIf { it.isNotBlank() }
|
?.takeIf { it.isNotBlank() }
|
||||||
?.let { videoId ->
|
|
||||||
playlist.videos += videoId.trim()
|
if (videoId != null) {
|
||||||
}
|
playlist.videos += videoId.trim()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
importPlaylists.add(playlist)
|
importPlaylists.add(playlist)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user