Skip to content

Commit

Permalink
! Fix thumbnail not respecting backend preference
Browse files Browse the repository at this point in the history
  • Loading branch information
PikachuEXE committed Sep 5, 2023
1 parent 762ab33 commit 4b2ba55
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 15 deletions.
27 changes: 16 additions & 11 deletions src/renderer/components/ft-list-playlist/ft-list-playlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@ export default defineComponent({
playlistId: '',
channelId: '',
title: 'Pop Music Playlist - Timeless Pop Songs (Updated Weekly 2020)',
thumbnail: 'https://i.ytimg.com/vi/JGwWNGJdvx8/mqdefault.jpg',
thumbnail: require('../../assets/img/thumbnail_placeholder.svg'),
channelName: '#RedMusic: Just Hits',
videoCount: 200,
}
},
computed: {
backendPreference: function () {
return this.$store.getters.getBackendPreference
},
currentInvidiousInstance: function () {
return this.$store.getters.getCurrentInvidiousInstance
},
Expand Down Expand Up @@ -62,6 +65,9 @@ export default defineComponent({
thumbnailPreference: function () {
return this.$store.getters.getThumbnailPreference
},
thumbnailCanBeShown() {
return this.thumbnailPreference !== 'hidden'
},
},
created: function () {
if (this.data._id != null) {
Expand All @@ -88,9 +94,7 @@ export default defineComponent({

parseInvidiousData: function () {
this.title = this.data.title
if (this.thumbnailPreference === 'hidden') {
this.thumbnail = require('../../assets/img/thumbnail_placeholder.svg')
} else {
if (this.thumbnailCanBeShown) {
this.thumbnail = this.data.playlistThumbnail.replace('https://i.ytimg.com', this.currentInvidiousInstance).replace('hqdefault', 'mqdefault')
}
this.channelName = this.data.author
Expand All @@ -105,9 +109,7 @@ export default defineComponent({

parseLocalData: function () {
this.title = this.data.title
if (this.thumbnailPreference === 'hidden') {
this.thumbnail = require('../../assets/img/thumbnail_placeholder.svg')
} else {
if (this.thumbnailCanBeShown) {
this.thumbnail = this.data.thumbnail
}
this.channelName = this.data.channelName
Expand All @@ -118,10 +120,13 @@ export default defineComponent({

parseUserData: function () {
this.title = this.data.playlistName
if (this.thumbnailPreference === 'hidden' || this.data.videos.length === 0) {
this.thumbnail = require('../../assets/img/thumbnail_placeholder.svg')
} else {
this.thumbnail = `https://i.ytimg.com/vi/${this.data.videos[0].videoId}/mqdefault.jpg`
if (this.thumbnailCanBeShown && this.data.videos.length > 0) {
const thumbnailURL = `https://i.ytimg.com/vi/${this.data.videos[0].videoId}/mqdefault.jpg`
if (this.backendPreference === 'invidious') {
this.thumbnail = thumbnailURL.replace('https://i.ytimg.com', this.currentInvidiousInstance)
} else {
this.thumbnail = thumbnailURL
}
}
this.channelName = ''
this.channelId = ''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,14 @@ export default Vue.extend({
data: function () {
return {
title: '',
thumbnail: '',
thumbnail: require('../../assets/img/thumbnail_placeholder.svg'),
videoCount: 0,
}
},
computed: {
backendPreference: function () {
return this.$store.getters.getBackendPreference
},
currentInvidiousInstance: function () {
return this.$store.getters.getCurrentInvidiousInstance
},
Expand All @@ -51,9 +54,12 @@ export default Vue.extend({
parseUserData: function () {
this.title = this.data.playlistName
if (this.data.videos.length > 0) {
this.thumbnail = `https://i.ytimg.com/vi/${this.data.videos[0].videoId}/mqdefault.jpg`
} else {
this.thumbnail = 'https://i.ytimg.com/vi/aaaaaa/mqdefault.jpg'
const thumbnailURL = `https://i.ytimg.com/vi/${this.data.videos[0].videoId}/mqdefault.jpg`
if (this.backendPreference === 'invidious') {
this.thumbnail = thumbnailURL.replace('https://i.ytimg.com', this.currentInvidiousInstance)
} else {
this.thumbnail = thumbnailURL
}
}
this.videoCount = this.data.videos.length
},
Expand Down

0 comments on commit 4b2ba55

Please sign in to comment.