fix: crash when importing private videos in watch history

This commit is contained in:
Bnyro 2024-10-02 11:54:08 +02:00
parent acf05bac2d
commit 152012b440
2 changed files with 5 additions and 5 deletions

View File

@ -269,7 +269,7 @@ object ImportHelper {
JsonHelper.json.decodeFromStream<List<YouTubeWatchHistoryFileItem>>(it) JsonHelper.json.decodeFromStream<List<YouTubeWatchHistoryFileItem>>(it)
} }
.orEmpty() .orEmpty()
.filter { it.activityControls.contains("YouTube watch history") } .filter { it.activityControls.contains("YouTube watch history") && it.subtitles.isNotEmpty() }
.reversed() .reversed()
.map { .map {
val videoId = it.titleUrl.substring(it.titleUrl.length - 11) val videoId = it.titleUrl.substring(it.titleUrl.length - 11)

View File

@ -4,11 +4,11 @@ import kotlinx.serialization.Serializable
@Serializable @Serializable
data class YouTubeWatchHistoryFileItem( data class YouTubeWatchHistoryFileItem(
val activityControls: List<String>,
val header: String, val header: String,
val products: List<String>,
val subtitles: List<YouTubeWatchHistoryChannelInfo>,
val time: String, val time: String,
val title: String, val title: String,
val titleUrl: String val titleUrl: String,
val activityControls: List<String> = emptyList(),
val products: List<String> = emptyList(),
val subtitles: List<YouTubeWatchHistoryChannelInfo> = emptyList()
) )