-
Notifications
You must be signed in to change notification settings - Fork 902
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
Added functionality to export a single playlist #5779
Merged
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b0ad1f5
Added functionality to export a single playlist
Zeabyte cc80b9e
Changed whitespace replacement in export file names to underscore
Zeabyte 563c1ac
Added regular expression to replace common forbidden characters in ex…
Zeabyte 14b9a0d
Optimized regex for replacing illegal characters in file names
Zeabyte ce443a8
Prefer replaceAll over replace
Zeabyte d882071
Merge branch 'development' into Zeabyte/development
PikachuEXE a530db6
* Make button hidden for online playlist, local playlist w/o video, m…
PikachuEXE File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||||
|
||||
|
@@ -412,6 +415,41 @@ export default defineComponent({ | |||
showToast(this.playlistDeletionDisabledLabel) | ||||
}, | ||||
|
||||
handlePlaylistExport: async function () { | ||||
const dateStr = getTodayDateStrLocalTimezone() | ||||
const title = this.selectedUserPlaylist.playlistName.replaceAll(' ', '_').replaceAll(/["%*/:<>?\\|]/g, '_') | ||||
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 | ||||
|
||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Might need to replace more chars
See
https://www.mtu.edu/umc/services/websites/writing/characters-avoid/
I use
Special !@#$%^&*()-_=+[]{};:'".>/?\| List
as test name and I gotfreetube-playlist-Special_!@#$_^&_()-_=+[]{};_'_.______List-2024-10-07
on MacOSNeed a windows guy to test the result
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.
@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.
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.
I didn't have access to Windows machine so I can't test it
![2024-10-07 18_55_11-重新命名](https://private-user-images.githubusercontent.com/1018543/374140322-26cf73a6-60af-4137-8705-5d79508accb0.jpg?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk0ODAwODcsIm5iZiI6MTczOTQ3OTc4NywicGF0aCI6Ii8xMDE4NTQzLzM3NDE0MDMyMi0yNmNmNzNhNi02MGFmLTQxMzctODcwNS01ZDc5NTA4YWNjYjAuanBnP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTNUMjA0OTQ3WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9Mzk5OGE3OGMyMGEwYjg3M2IxY2Q2YzE2YzQwMDU3NzNmMjcyZmFlMmM0MmZmNDczNTAxZWY4YWNiZmRkMDc4YyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.akdhYV0rex6AAnhp2NdAw0kUXEeiJcYZf8ZhuWZgZ-Y)
Here is a screenshot of forbidden char message
I will create a custom build to test on Windows machine later
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.
On windows I have
freetube-playlist-Special_!@#$_^&_()-_=+[]{};_'_.______List-2024-10-07.db
, same as MacOS