mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-29 08:20:32 +05:30
fix: ignore youtube import entries with missing title url
This commit is contained in:
parent
f4a8d7b6b1
commit
2c463da52a
@ -162,16 +162,17 @@ object ImportHelper {
|
||||
}
|
||||
|
||||
ImportFormat.FREETUBE -> {
|
||||
val playlistFile = activity.contentResolver.openInputStream(uri)?.use { inputStream ->
|
||||
val text = inputStream.bufferedReader().readText()
|
||||
runCatching {
|
||||
text.lines().map { line ->
|
||||
JsonHelper.json.decodeFromString<FreeTubeImportPlaylist>(line)
|
||||
}
|
||||
}.getOrNull() ?: runCatching {
|
||||
listOf(JsonHelper.json.decodeFromString<FreeTubeImportPlaylist>(text))
|
||||
}.getOrNull()
|
||||
}
|
||||
val playlistFile =
|
||||
activity.contentResolver.openInputStream(uri)?.use { inputStream ->
|
||||
val text = inputStream.bufferedReader().readText()
|
||||
runCatching {
|
||||
text.lines().map { line ->
|
||||
JsonHelper.json.decodeFromString<FreeTubeImportPlaylist>(line)
|
||||
}
|
||||
}.getOrNull() ?: runCatching {
|
||||
listOf(JsonHelper.json.decodeFromString<FreeTubeImportPlaylist>(text))
|
||||
}.getOrNull()
|
||||
}
|
||||
|
||||
val playlists = playlistFile.orEmpty().map { playlist ->
|
||||
// convert FreeTube videos to list of string
|
||||
@ -287,7 +288,7 @@ object ImportHelper {
|
||||
JsonHelper.json.decodeFromStream<List<YouTubeWatchHistoryFileItem>>(it)
|
||||
}
|
||||
.orEmpty()
|
||||
.filter { it.activityControls.contains("YouTube watch history") && it.subtitles.isNotEmpty() }
|
||||
.filter { it.activityControls.contains("YouTube watch history") && it.subtitles.isNotEmpty() && it.titleUrl.isNotEmpty() }
|
||||
.reversed()
|
||||
.map {
|
||||
val videoId = it.titleUrl.substring(it.titleUrl.length - 11)
|
||||
|
@ -4,10 +4,10 @@ import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class YouTubeWatchHistoryFileItem(
|
||||
val header: String,
|
||||
val time: String,
|
||||
val title: String,
|
||||
val titleUrl: String,
|
||||
val header: String = "",
|
||||
val time: String = "",
|
||||
val title: String = "",
|
||||
val titleUrl: String = "",
|
||||
val activityControls: List<String> = emptyList(),
|
||||
val products: List<String> = emptyList(),
|
||||
val subtitles: List<YouTubeWatchHistoryChannelInfo> = emptyList()
|
||||
|
Loading…
x
Reference in New Issue
Block a user