Proxy video thumbnails through Invidious based on backend preference

This commit is contained in:
Preston 2020-06-02 22:27:55 -04:00
parent 42046a00de
commit 47593618cf
2 changed files with 30 additions and 8 deletions

View File

@ -42,16 +42,31 @@ export default Vue.extend({
return this.$store.getters.getThumbnailPreference
},
backendPreference: function () {
return this.$store.getters.getBackendPreference
},
invidiousInstance: function () {
return this.$store.getters.getInvidiousInstance
},
thumbnail: function () {
let baseUrl
if (this.backendPreference === 'invidious') {
baseUrl = this.invidiousInstance
} else {
baseUrl = 'https://i.ytimg.com'
}
switch (this.thumbnailPreference) {
case 'start':
return `https://i.ytimg.com/vi/${this.id}/mq1.jpg`
return `${baseUrl}/vi/${this.id}/mq1.jpg`
case 'middle':
return `https://i.ytimg.com/vi/${this.id}/mq2.jpg`
return `${baseUrl}/vi/${this.id}/mq2.jpg`
case 'end':
return `https://i.ytimg.com/vi/${this.id}/mq3.jpg`
return `${baseUrl}/vi/${this.id}/mq3.jpg`
default:
return `https://i.ytimg.com/vi/${this.id}/mqdefault.jpg`
return `${baseUrl}/vi/${this.id}/mqdefault.jpg`
}
}
},

View File

@ -98,15 +98,22 @@ export default Vue.extend({
},
thumbnail: function () {
let baseUrl
if (this.backendPreference === 'invidious') {
baseUrl = this.invidiousInstance
} else {
baseUrl = 'https://i.ytimg.com'
}
switch (this.thumbnailPreference) {
case 'start':
return `https://i.ytimg.com/vi/${this.videoId}/mq1.jpg`
return `${baseUrl}/vi/${this.videoId}/maxres1.jpg`
case 'middle':
return `https://i.ytimg.com/vi/${this.videoId}/mq2.jpg`
return `${baseUrl}/vi/${this.videoId}/maxres2.jpg`
case 'end':
return `https://i.ytimg.com/vi/${this.videoId}/mq3.jpg`
return `${baseUrl}/vi/${this.videoId}/maxres3.jpg`
default:
return `https://i.ytimg.com/vi/${this.videoId}/mqdefault.jpg`
return `${baseUrl}/vi/${this.videoId}/maxresdefault.jpg`
}
},