-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Added functionality to export a single playlist #5779
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b0ad1f5
cc80b9e
563c1ac
14b9a0d
ce443a8
d882071
a530db6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -10,6 +10,9 @@ import { | |||
| ctrlFHandler, | ||||
| formatNumber, | ||||
| showToast, | ||||
| getTodayDateStrLocalTimezone, | ||||
| writeFileFromDialog, | ||||
| showSaveDialog, | ||||
| } from '../../helpers/utils' | ||||
| import debounce from 'lodash.debounce' | ||||
|
|
||||
|
|
@@ -262,6 +265,13 @@ export default defineComponent({ | |||
| return this.selectedUserPlaylist.videos.length - this.userPlaylistUniqueVideoIds.size | ||||
| }, | ||||
|
|
||||
| exportPlaylistButtonVisible: function() { | ||||
| // Only online playlists can be shared | ||||
| if (!this.isUserPlaylist) { return false } | ||||
|
|
||||
| return this.videoCount > 0 | ||||
| }, | ||||
|
|
||||
| deletePlaylistButtonVisible: function() { | ||||
| if (!this.isUserPlaylist) { return false } | ||||
| // Cannot delete during edit | ||||
|
|
@@ -275,7 +285,6 @@ export default defineComponent({ | |||
| // Only online playlists can be shared | ||||
| if (this.isUserPlaylist) { return false } | ||||
|
|
||||
| // Cannot delete protected playlist | ||||
| return !this.hideSharingActions | ||||
| }, | ||||
|
|
||||
|
|
@@ -412,6 +421,41 @@ export default defineComponent({ | |||
| showToast(this.playlistDeletionDisabledLabel) | ||||
| }, | ||||
|
|
||||
| handlePlaylistExport: async function () { | ||||
| const dateStr = getTodayDateStrLocalTimezone() | ||||
| const title = this.selectedUserPlaylist.playlistName.replaceAll(' ', '_').replaceAll(/["%*/:<>?\\|]/g, '_') | ||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Might need to replace more chars I use
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @PikachuEXE I thought that the characters I listed in the Regexp would be those that are absolutely illegal for use in certain OS’s. The guide you linked calls some absolutely common, usual and legal characters "illegal" and "forbidden". So, just to confirm, this is more about conventions, right? Thanks for having a look at it.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On windows I have
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Non-blocking: Maybe we should merge the logic here with the logic for replacing the names of files created for screenshots? FreeTube/src/renderer/helpers/utils.js Line 565 in 94fe62a
|
||||
| const exportFileName = 'freetube-playlist-' + title + '-' + dateStr + '.db' | ||||
|
|
||||
| const options = { | ||||
| defaultPath: exportFileName, | ||||
| filters: [ | ||||
| { | ||||
| name: 'Database File', | ||||
| extensions: ['db'] | ||||
| } | ||||
| ] | ||||
| } | ||||
|
|
||||
| const data = JSON.stringify(this.selectedUserPlaylist) + '\n' | ||||
|
|
||||
| // See data-settings.js `promptAndWriteToFile` | ||||
| const response = await showSaveDialog(options) | ||||
| if (response.canceled || response.filePath === '') { | ||||
| // User canceled the save dialog | ||||
| return | ||||
| } | ||||
|
|
||||
| try { | ||||
| await writeFileFromDialog(response, data) | ||||
| } catch (writeErr) { | ||||
| const message = this.$t('Settings.Data Settings.Unable to write file') | ||||
| showToast(`${message}: ${writeErr}`) | ||||
| return | ||||
| } | ||||
|
|
||||
| showToast(this.$t('User Playlists.The playlist has been successfully exported')) | ||||
| }, | ||||
|
|
||||
| exitEditMode: function () { | ||||
| this.editMode = false | ||||
|
|
||||
|
|
||||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why was this removed?