diff --git a/src/renderer/components/distraction-settings/distraction-settings.js b/src/renderer/components/distraction-settings/distraction-settings.js index 90870b5b38289..939ecba67f54e 100644 --- a/src/renderer/components/distraction-settings/distraction-settings.js +++ b/src/renderer/components/distraction-settings/distraction-settings.js @@ -65,6 +65,9 @@ export default Vue.extend({ hideChapters: function () { return this.$store.getters.getHideChapters }, + showDistractionFreeTitles: function () { + return this.$store.getters.getShowDistractionFreeTitles + }, channelsHidden: function () { return JSON.parse(this.$store.getters.getChannelsHidden) } @@ -100,7 +103,8 @@ export default Vue.extend({ 'updateHideUpcomingPremieres', 'updateHideSharingActions', 'updateHideChapters', - 'updateChannelsHidden' + 'updateChannelsHidden', + 'updateShowDistractionFreeTitles' ]) } }) diff --git a/src/renderer/components/distraction-settings/distraction-settings.vue b/src/renderer/components/distraction-settings/distraction-settings.vue index 2603f3022eaa9..81659956d3c2b 100644 --- a/src/renderer/components/distraction-settings/distraction-settings.vue +++ b/src/renderer/components/distraction-settings/distraction-settings.vue @@ -102,6 +102,12 @@ :default-value="hideComments" @change="updateHideComments" /> +
diff --git a/src/renderer/components/ft-list-video/ft-list-video.js b/src/renderer/components/ft-list-video/ft-list-video.js index 5c31573c64e14..8111889d7be09 100644 --- a/src/renderer/components/ft-list-video/ft-list-video.js +++ b/src/renderer/components/ft-list-video/ft-list-video.js @@ -7,7 +7,9 @@ import { formatDurationAsTimestamp, openExternalLink, showToast, - toLocalePublicationString + toLocalePublicationString, + toDistractionFreeTitle, + } from '../../helpers/utils' export default Vue.extend({ @@ -282,7 +284,17 @@ export default Vue.extend({ currentLocale: function () { return i18n.locale.replace('_', '-') - } + }, + showDistractionFreeTitles: function () { + return this.$store.getters.getShowDistractionFreeTitles + }, + displayTitle: function () { + if (this.showDistractionFreeTitles) { + return toDistractionFreeTitle(this.data.title) + } else { + return this.data.title + } + }, }, mounted: function () { this.parseVideoData() diff --git a/src/renderer/components/ft-list-video/ft-list-video.vue b/src/renderer/components/ft-list-video/ft-list-video.vue index 87ba4b5b52207..87fb220e1ae38 100644 --- a/src/renderer/components/ft-list-video/ft-list-video.vue +++ b/src/renderer/components/ft-list-video/ft-list-video.vue @@ -82,7 +82,7 @@ query: playlistId ? {playlistId} : {} }" > - {{ title }} + {{ displayTitle }}
a || c(), null) || paramsObject } + +/** + * This will match sequences of upper case characters and convert them into title cased words. + * @param {string} title the title to process + * @param {number} minUpperCase the minimum number of consecutive upper case characters to match + * @returns {string} the title with upper case characters removed + */ +export function toDistractionFreeTitle(title, minUpperCase = 3) { + const firstValidCharIndex = (word) => { + const reg = /[\p{L}]/u + return word.search(reg) + } + + const capitalizedWord = (word) => { + const chars = word.split('') + const index = firstValidCharIndex(word) + chars[index] = chars[index].toUpperCase() + return chars.join('') + } + + const reg = RegExp(`[\\p{Lu}|']{${minUpperCase},}`, 'ug') + return title.replace(reg, x => capitalizedWord(x.toLowerCase())) +} diff --git a/src/renderer/store/modules/settings.js b/src/renderer/store/modules/settings.js index 141ebd4f8c870..f5e1aba23e071 100644 --- a/src/renderer/store/modules/settings.js +++ b/src/renderer/store/modules/settings.js @@ -213,6 +213,7 @@ const state = { hideWatchedSubs: false, hideLabelsSideBar: false, hideChapters: false, + showDistractionFreeTitles: false, landingPage: 'subscriptions', listType: 'grid', maxVideoPlaybackRate: 3, diff --git a/static/locales/en-US.yaml b/static/locales/en-US.yaml index da7f537efdf4a..432a263a5c1e4 100644 --- a/static/locales/en-US.yaml +++ b/static/locales/en-US.yaml @@ -323,6 +323,7 @@ Settings: Hide Active Subscriptions: Hide Active Subscriptions Hide Video Description: Hide Video Description Hide Comments: Hide Comments + Display Titles Without Excessive Capitalisation: Display Titles Without Excessive Capitalisation Hide Live Streams: Hide Live Streams Hide Upcoming Premieres: Hide Upcoming Premieres Hide Sharing Actions: Hide Sharing Actions