mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-29 08:20:32 +05:30
add possibility to backup and restore local playlists
This commit is contained in:
parent
0aaf68ede6
commit
08bbb839aa
@ -7,7 +7,7 @@ import androidx.room.PrimaryKey
|
|||||||
@Entity
|
@Entity
|
||||||
data class LocalPlaylistItem(
|
data class LocalPlaylistItem(
|
||||||
@PrimaryKey(autoGenerate = true) val id: Int = 0,
|
@PrimaryKey(autoGenerate = true) val id: Int = 0,
|
||||||
@ColumnInfo val playlistId: Int,
|
@ColumnInfo var playlistId: Int,
|
||||||
@ColumnInfo val videoId: String,
|
@ColumnInfo val videoId: String,
|
||||||
@ColumnInfo val title: String? = null,
|
@ColumnInfo val title: String? = null,
|
||||||
@ColumnInfo val uploadDate: String? = null,
|
@ColumnInfo val uploadDate: String? = null,
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.github.libretube.obj
|
package com.github.libretube.obj
|
||||||
|
|
||||||
import com.github.libretube.db.obj.CustomInstance
|
import com.github.libretube.db.obj.CustomInstance
|
||||||
|
import com.github.libretube.db.obj.LocalPlaylistWithVideos
|
||||||
import com.github.libretube.db.obj.LocalSubscription
|
import com.github.libretube.db.obj.LocalSubscription
|
||||||
import com.github.libretube.db.obj.PlaylistBookmark
|
import com.github.libretube.db.obj.PlaylistBookmark
|
||||||
import com.github.libretube.db.obj.SearchHistoryItem
|
import com.github.libretube.db.obj.SearchHistoryItem
|
||||||
@ -14,5 +15,6 @@ data class BackupFile(
|
|||||||
var localSubscriptions: List<LocalSubscription>? = null,
|
var localSubscriptions: List<LocalSubscription>? = null,
|
||||||
var customInstances: List<CustomInstance>? = null,
|
var customInstances: List<CustomInstance>? = null,
|
||||||
var playlistBookmarks: List<PlaylistBookmark>? = null,
|
var playlistBookmarks: List<PlaylistBookmark>? = null,
|
||||||
|
var localPlaylists: List<LocalPlaylistWithVideos>? = null,
|
||||||
var preferences: List<PreferenceItem>? = null
|
var preferences: List<PreferenceItem>? = null
|
||||||
)
|
)
|
||||||
|
@ -40,6 +40,10 @@ class BackupDialog(
|
|||||||
it.playlistBookmarks = Database.playlistBookmarkDao().getAll()
|
it.playlistBookmarks = Database.playlistBookmarkDao().getAll()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
object LocalPlaylists : BackupOption(R.string.local_playlists, onSelected = {
|
||||||
|
it.localPlaylists = Database.localPlaylistsDao().getAll()
|
||||||
|
})
|
||||||
|
|
||||||
object Preferences : BackupOption(R.string.preferences, onSelected = {
|
object Preferences : BackupOption(R.string.preferences, onSelected = {
|
||||||
it.preferences = PreferenceHelper.settings.all.map {
|
it.preferences = PreferenceHelper.settings.all.map {
|
||||||
PreferenceItem(it.key, it.value)
|
PreferenceItem(it.key, it.value)
|
||||||
@ -54,6 +58,7 @@ class BackupDialog(
|
|||||||
BackupOption.LocalSubscriptions,
|
BackupOption.LocalSubscriptions,
|
||||||
BackupOption.CustomInstances,
|
BackupOption.CustomInstances,
|
||||||
BackupOption.PlaylistBookmarks,
|
BackupOption.PlaylistBookmarks,
|
||||||
|
BackupOption.LocalPlaylists,
|
||||||
BackupOption.Preferences
|
BackupOption.Preferences
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -66,6 +66,15 @@ class BackupHelper(private val context: Context) {
|
|||||||
*backupFile.playlistBookmarks.orEmpty().toTypedArray()
|
*backupFile.playlistBookmarks.orEmpty().toTypedArray()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
backupFile.localPlaylists?.forEach {
|
||||||
|
Database.localPlaylistsDao().createPlaylist(it.playlist)
|
||||||
|
val playlistId = Database.localPlaylistsDao().getAll().last().playlist.id
|
||||||
|
it.videos.forEach {
|
||||||
|
it.playlistId = playlistId
|
||||||
|
Database.localPlaylistsDao().addPlaylistVideo(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
restorePreferences(backupFile.preferences)
|
restorePreferences(backupFile.preferences)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -386,6 +386,7 @@
|
|||||||
<string name="clear_bookmarks">Clear bookmarks</string>
|
<string name="clear_bookmarks">Clear bookmarks</string>
|
||||||
<string name="bookmarks_empty">No bookmarks yet!</string>
|
<string name="bookmarks_empty">No bookmarks yet!</string>
|
||||||
<string name="queue_insert_related_videos">Insert related videos</string>
|
<string name="queue_insert_related_videos">Insert related videos</string>
|
||||||
|
<string name="local_playlists">Local playlists</string>
|
||||||
|
|
||||||
<!-- Notification channel strings -->
|
<!-- Notification channel strings -->
|
||||||
<string name="download_channel_name">Download Service</string>
|
<string name="download_channel_name">Download Service</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user