fix: ignore youtube import entries with missing title url

This commit is contained in:
Bnyro 2024-11-17 23:07:00 +01:00
parent f4a8d7b6b1
commit 2c463da52a
2 changed files with 16 additions and 15 deletions

View File

@ -162,7 +162,8 @@ object ImportHelper {
}
ImportFormat.FREETUBE -> {
val playlistFile = activity.contentResolver.openInputStream(uri)?.use { inputStream ->
val playlistFile =
activity.contentResolver.openInputStream(uri)?.use { inputStream ->
val text = inputStream.bufferedReader().readText()
runCatching {
text.lines().map { line ->
@ -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)

View File

@ -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()