fix: incorrect FreeTube playlist export

This commit is contained in:
Bnyro 2024-10-24 16:45:47 +02:00
parent 5b8f3093bf
commit 551a69535f
3 changed files with 15 additions and 9 deletions

View File

@ -218,13 +218,17 @@ object PlaylistsHelper {
getPlaylists()
.map { async { getPlaylist(it.id!!) } }
.awaitAll()
.map {
val videos = it.relatedStreams.map { item ->
item.url.orEmpty().replace("$YOUTUBE_FRONTEND_URL/watch?v=${item.url}", "")
}.map { id ->
FreeTubeVideo(id, it.name.orEmpty(), "", "")
.map { playlist ->
val videos = playlist.relatedStreams.map { videoInfo ->
FreeTubeVideo(
videoId = videoInfo.url.orEmpty().toID(),
title = videoInfo.title.orEmpty(),
author = videoInfo.uploaderName.orEmpty(),
authorId = videoInfo.uploaderUrl.orEmpty().toID(),
lengthSeconds = videoInfo.duration ?: 0L
)
}
FreeTubeImportPlaylist(it.name.orEmpty(), videos)
FreeTubeImportPlaylist(playlist.name.orEmpty(), videos)
}
}

View File

@ -6,6 +6,6 @@ import kotlinx.serialization.Serializable
@Serializable
data class FreeTubeImportPlaylist(
@SerialName("playlistName") val name: String = "",
// if type is `video` -> https://www.youtube.com/watch?v=IT734HriiHQ, works with shorts too
var videos: List<FreeTubeVideo> = listOf()
var videos: List<FreeTubeVideo> = listOf(),
var protected: Boolean = true
)

View File

@ -7,5 +7,7 @@ data class FreeTubeVideo(
val videoId: String,
val title: String,
val author: String,
val authorId: String
val authorId: String,
val lengthSeconds: Long,
val type: String = "video"
)