From 3cf18b9f2dad2c2dc53fa92c4a4256b0a9dc5284 Mon Sep 17 00:00:00 2001 From: kuhaku Date: Thu, 7 Oct 2021 06:29:43 +0000 Subject: [PATCH] Add support for the 'defaultCustomArguments' external player mapping field (#1415) * feat(store/utils): add support for the `defaultCustomArguments` external player mapping field improve(store/utils): move custom arguments evaluation to the top in `openInExternalPlayer` improve(components/external-player-settings): conditionally append the default custom arguments to the tooltip Signed-off-by: Randshot * fix(components/external-player-settings): fix lint error chore(components/external-player-settings): remove unnecessary console log Signed-off-by: Randshot * chore(static/external-player-map): add new `defaultCustomArguments` field to vlc map Signed-off-by: Randshot --- .../external-player-settings.js | 12 ++++++++++++ .../external-player-settings.vue | 2 +- src/renderer/store/modules/utils.js | 16 ++++++++++------ static/external-player-map.json | 2 ++ static/locales/en-US.yaml | 2 ++ static/locales/en_GB.yaml | 2 ++ 6 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/renderer/components/external-player-settings/external-player-settings.js b/src/renderer/components/external-player-settings/external-player-settings.js index 62a15040..04d7bd26 100644 --- a/src/renderer/components/external-player-settings/external-player-settings.js +++ b/src/renderer/components/external-player-settings/external-player-settings.js @@ -40,6 +40,18 @@ export default Vue.extend({ }, externalPlayerCustomArgs: function () { return this.$store.getters.getExternalPlayerCustomArgs + }, + externalPlayerCustomArgsTooltip: function () { + const tooltip = this.$t('Tooltips.External Player Settings.Custom External Player Arguments') + + const cmdArgs = this.$store.getters.getExternalPlayerCmdArguments[this.externalPlayer] + if (cmdArgs && typeof cmdArgs.defaultCustomArguments === 'string' && cmdArgs.defaultCustomArguments !== '') { + const defaultArgs = this.$t('Tooltips.External Player Settings.DefaultCustomArgumentsTemplate') + .replace('$', cmdArgs.defaultCustomArguments) + return `${tooltip} ${defaultArgs}` + } + + return tooltip } }, methods: { diff --git a/src/renderer/components/external-player-settings/external-player-settings.vue b/src/renderer/components/external-player-settings/external-player-settings.vue index c2298dc2..8a296cab 100644 --- a/src/renderer/components/external-player-settings/external-player-settings.vue +++ b/src/renderer/components/external-player-settings/external-player-settings.vue @@ -44,7 +44,7 @@ :show-action-button="false" :show-label="true" :value="externalPlayerCustomArgs" - :tooltip="$t('Tooltips.External Player Settings.Custom External Player Arguments')" + :tooltip="externalPlayerCustomArgsTooltip" @input="updateExternalPlayerCustomArgs" /> diff --git a/src/renderer/store/modules/utils.js b/src/renderer/store/modules/utils.js index 9650981e..49b49618 100644 --- a/src/renderer/store/modules/utils.js +++ b/src/renderer/store/modules/utils.js @@ -674,6 +674,16 @@ const actions = { const ignoreWarnings = rootState.settings.externalPlayerIgnoreWarnings const customArgs = rootState.settings.externalPlayerCustomArgs + // Append custom user-defined arguments, + // or use the default ones specified for the external player. + if (typeof customArgs === 'string' && customArgs !== '') { + const custom = customArgs.split(';') + args.push(...custom) + } else if (typeof cmdArgs.defaultCustomArguments === 'string' && cmdArgs.defaultCustomArguments !== '') { + const defaultCustomArguments = cmdArgs.defaultCustomArguments.split(';') + args.push(...defaultCustomArguments) + } + if (payload.watchProgress > 0) { if (typeof cmdArgs.startOffset === 'string') { args.push(`${cmdArgs.startOffset}${payload.watchProgress}`) @@ -776,12 +786,6 @@ const actions = { } } - // Append custom user-defined arguments - if (customArgs !== null) { - const custom = customArgs.split(';') - args.push(...custom) - } - const openingToast = payload.strings.OpeningTemplate .replace('$', payload.playlistId === null || payload.playlistId === '' ? payload.strings.video diff --git a/static/external-player-map.json b/static/external-player-map.json index 08ef6c33..648bd98c 100644 --- a/static/external-player-map.json +++ b/static/external-player-map.json @@ -9,6 +9,7 @@ "value": "mpv", "cmdArguments": { "defaultExecutable": "mpv", + "defaultCustomArguments": null, "supportsYtdlProtocol": true, "videoUrl": "", "playlistUrl": "", @@ -25,6 +26,7 @@ "value": "vlc", "cmdArguments": { "defaultExecutable": "vlc", + "defaultCustomArguments": null, "supportsYtdlProtocol": false, "videoUrl": "", "playlistUrl": null, diff --git a/static/locales/en-US.yaml b/static/locales/en-US.yaml index 35420e6f..6b8aae3e 100644 --- a/static/locales/en-US.yaml +++ b/static/locales/en-US.yaml @@ -653,6 +653,8 @@ Tooltips: the current action (e.g. reversing playlists, etc.). Custom External Player Arguments: Any custom command line arguments, separated by semicolons (';'), you want to be passed to the external player. + # $ is replaced with the default custom arguments for the current player, if defined. + DefaultCustomArgumentsTemplate: '(Default: ''$'')' Subscription Settings: Fetch Feeds from RSS: When enabled, FreeTube will use RSS instead of its default method for grabbing your subscription feed. RSS is faster and prevents IP blocking, diff --git a/static/locales/en_GB.yaml b/static/locales/en_GB.yaml index c2e279a2..38906170 100644 --- a/static/locales/en_GB.yaml +++ b/static/locales/en_GB.yaml @@ -724,6 +724,8 @@ Tooltips: support the current action (e.g. reversing playlists, etc.). Custom External Player Arguments: Any custom command line arguments, separated by semicolons (';'), you want to be passed to the external player. + # $ is replaced with the default custom arguments for the current player, if defined. + DefaultCustomArgumentsTemplate: '(Default: ''$'')' Privacy Settings: Remove Video Meta Files: When enabled, FreeTube automatically deletes meta files created during video playback, when the watch page is closed.