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 b7bc0afd1ab0a..13d4792692085 100644
--- a/src/renderer/components/ft-list-video/ft-list-video.js
+++ b/src/renderer/components/ft-list-video/ft-list-video.js
@@ -10,6 +10,7 @@ import {
toLocalePublicationString,
toDistractionFreeTitle
} from '../../helpers/utils'
+import { deArrowData } from '../../helpers/sponsorblock'
export default defineComponent({
name: 'FtListVideo',
@@ -320,6 +321,14 @@ export default defineComponent({
currentLocale: function () {
return this.$i18n.locale.replace('_', '-')
},
+
+ useDeArrowTitles: function () {
+ return this.$store.getters.getUseDeArrowTitles
+ },
+
+ deArrowCache: function () {
+ return this.$store.getters.getDeArrowCache(this.id)
+ }
},
watch: {
historyIndex() {
@@ -331,6 +340,25 @@ export default defineComponent({
this.checkIfWatched()
},
methods: {
+ getDeArrowDataEntry: async function() {
+ // Read from local cache or remote
+ // Write to cache if read from remote
+ if (!this.useDeArrowTitles) { return null }
+
+ if (this.deArrowCache) { return this.deArrowCache }
+
+ const videoId = this.id
+ const data = await deArrowData(this.id)
+ const cacheData = { videoId, title: null }
+ if (Array.isArray(data?.titles) && data.titles.length > 0 && (data.titles[0].locked || data.titles[0].votes > 0)) {
+ cacheData.title = data.titles[0].title
+ }
+
+ // Save data to cache whether data available or not to prevent duplicate requests
+ this.$store.commit('addVideoToDeArrowCache', cacheData)
+ return cacheData
+ },
+
handleExternalPlayer: function () {
this.$emit('pause-player')
@@ -401,9 +429,9 @@ export default defineComponent({
}
},
- parseVideoData: function () {
+ parseVideoData: async function () {
this.id = this.data.videoId
- this.title = this.data.title
+ this.title = (await this.getDeArrowDataEntry())?.title ?? this.data.title
// this.thumbnail = this.data.videoThumbnails[4].url
this.channelName = this.data.author ?? null
diff --git a/src/renderer/components/sponsor-block-settings/sponsor-block-settings.js b/src/renderer/components/sponsor-block-settings/sponsor-block-settings.js
index af1fd5abf8ea5..4455e84208be6 100644
--- a/src/renderer/components/sponsor-block-settings/sponsor-block-settings.js
+++ b/src/renderer/components/sponsor-block-settings/sponsor-block-settings.js
@@ -38,6 +38,10 @@ export default defineComponent({
},
sponsorBlockShowSkippedToast: function () {
return this.$store.getters.getSponsorBlockShowSkippedToast
+ },
+
+ useDeArrowTitles: function () {
+ return this.$store.getters.getUseDeArrowTitles
}
},
methods: {
@@ -45,6 +49,10 @@ export default defineComponent({
this.updateUseSponsorBlock(value)
},
+ handleUpdateUseDeArrowTitles: function (value) {
+ this.updateUseDeArrowTitles(value)
+ },
+
handleUpdateSponsorBlockUrl: function (value) {
const sponsorBlockUrlWithoutTrailingSlash = value.replace(/\/$/, '')
const sponsorBlockUrlWithoutApiSuffix = sponsorBlockUrlWithoutTrailingSlash.replace(/\/api$/, '')
@@ -58,7 +66,8 @@ export default defineComponent({
...mapActions([
'updateUseSponsorBlock',
'updateSponsorBlockUrl',
- 'updateSponsorBlockShowSkippedToast'
+ 'updateSponsorBlockShowSkippedToast',
+ 'updateUseDeArrowTitles'
])
}
})
diff --git a/src/renderer/components/sponsor-block-settings/sponsor-block-settings.vue b/src/renderer/components/sponsor-block-settings/sponsor-block-settings.vue
index abda76eebd13e..44de745c5baaf 100644
--- a/src/renderer/components/sponsor-block-settings/sponsor-block-settings.vue
+++ b/src/renderer/components/sponsor-block-settings/sponsor-block-settings.vue
@@ -8,11 +8,20 @@
:default-value="useSponsorBlock"
@change="handleUpdateSponsorBlock"
/>
+