File tree Expand file tree Collapse file tree 2 files changed +16
-15
lines changed
app/src/main/java/com/github/libretube Expand file tree Collapse file tree 2 files changed +16
-15
lines changed Original file line number Diff line number Diff line change @@ -162,16 +162,17 @@ object ImportHelper {
162162 }
163163
164164 ImportFormat .FREETUBE -> {
165- val playlistFile = activity.contentResolver.openInputStream(uri)?.use { inputStream ->
166- val text = inputStream.bufferedReader().readText()
167- runCatching {
168- text.lines().map { line ->
169- JsonHelper .json.decodeFromString<FreeTubeImportPlaylist >(line)
170- }
171- }.getOrNull() ? : runCatching {
172- listOf (JsonHelper .json.decodeFromString<FreeTubeImportPlaylist >(text))
173- }.getOrNull()
174- }
165+ val playlistFile =
166+ activity.contentResolver.openInputStream(uri)?.use { inputStream ->
167+ val text = inputStream.bufferedReader().readText()
168+ runCatching {
169+ text.lines().map { line ->
170+ JsonHelper .json.decodeFromString<FreeTubeImportPlaylist >(line)
171+ }
172+ }.getOrNull() ? : runCatching {
173+ listOf (JsonHelper .json.decodeFromString<FreeTubeImportPlaylist >(text))
174+ }.getOrNull()
175+ }
175176
176177 val playlists = playlistFile.orEmpty().map { playlist ->
177178 // convert FreeTube videos to list of string
@@ -287,7 +288,7 @@ object ImportHelper {
287288 JsonHelper .json.decodeFromStream<List <YouTubeWatchHistoryFileItem >>(it)
288289 }
289290 .orEmpty()
290- .filter { it.activityControls.contains(" YouTube watch history" ) && it.subtitles.isNotEmpty() }
291+ .filter { it.activityControls.contains(" YouTube watch history" ) && it.subtitles.isNotEmpty() && it.titleUrl.isNotEmpty() }
291292 .reversed()
292293 .map {
293294 val videoId = it.titleUrl.substring(it.titleUrl.length - 11 )
Original file line number Diff line number Diff line change @@ -4,10 +4,10 @@ import kotlinx.serialization.Serializable
44
55@Serializable
66data class YouTubeWatchHistoryFileItem (
7- val header : String ,
8- val time : String ,
9- val title : String ,
10- val titleUrl : String ,
7+ val header : String = " " ,
8+ val time : String = " " ,
9+ val title : String = " " ,
10+ val titleUrl : String = " " ,
1111 val activityControls : List <String > = emptyList(),
1212 val products : List <String > = emptyList(),
1313 val subtitles : List <YouTubeWatchHistoryChannelInfo > = emptyList()
You can’t perform that action at this time.
0 commit comments