mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-29 16:30:31 +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 -> {
|
ImportFormat.FREETUBE -> {
|
||||||
val playlistFile = activity.contentResolver.openInputStream(uri)?.use { inputStream ->
|
val playlistFile =
|
||||||
val text = inputStream.bufferedReader().readText()
|
activity.contentResolver.openInputStream(uri)?.use { inputStream ->
|
||||||
runCatching {
|
val text = inputStream.bufferedReader().readText()
|
||||||
text.lines().map { line ->
|
runCatching {
|
||||||
JsonHelper.json.decodeFromString<FreeTubeImportPlaylist>(line)
|
text.lines().map { line ->
|
||||||
}
|
JsonHelper.json.decodeFromString<FreeTubeImportPlaylist>(line)
|
||||||
}.getOrNull() ?: runCatching {
|
}
|
||||||
listOf(JsonHelper.json.decodeFromString<FreeTubeImportPlaylist>(text))
|
}.getOrNull() ?: runCatching {
|
||||||
}.getOrNull()
|
listOf(JsonHelper.json.decodeFromString<FreeTubeImportPlaylist>(text))
|
||||||
}
|
}.getOrNull()
|
||||||
|
}
|
||||||
|
|
||||||
val playlists = playlistFile.orEmpty().map { playlist ->
|
val playlists = playlistFile.orEmpty().map { playlist ->
|
||||||
// convert FreeTube videos to list of string
|
// convert FreeTube videos to list of string
|
||||||
@ -287,7 +288,7 @@ object ImportHelper {
|
|||||||
JsonHelper.json.decodeFromStream<List<YouTubeWatchHistoryFileItem>>(it)
|
JsonHelper.json.decodeFromStream<List<YouTubeWatchHistoryFileItem>>(it)
|
||||||
}
|
}
|
||||||
.orEmpty()
|
.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()
|
.reversed()
|
||||||
.map {
|
.map {
|
||||||
val videoId = it.titleUrl.substring(it.titleUrl.length - 11)
|
val videoId = it.titleUrl.substring(it.titleUrl.length - 11)
|
||||||
|
@ -4,10 +4,10 @@ import kotlinx.serialization.Serializable
|
|||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class YouTubeWatchHistoryFileItem(
|
data class YouTubeWatchHistoryFileItem(
|
||||||
val header: String,
|
val header: String = "",
|
||||||
val time: String,
|
val time: String = "",
|
||||||
val title: String,
|
val title: String = "",
|
||||||
val titleUrl: String,
|
val titleUrl: String = "",
|
||||||
val activityControls: List<String> = emptyList(),
|
val activityControls: List<String> = emptyList(),
|
||||||
val products: List<String> = emptyList(),
|
val products: List<String> = emptyList(),
|
||||||
val subtitles: List<YouTubeWatchHistoryChannelInfo> = emptyList()
|
val subtitles: List<YouTubeWatchHistoryChannelInfo> = emptyList()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user