Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix saving Invidious thumbnail URLs for subscriptions #5662

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,8 @@ export default defineComponent({
let thumbnailUrl = post.authorThumbnails?.[0]?.url

if (name || thumbnailUrl) {
if (thumbnailUrl) {
if (thumbnailUrl.startsWith('//')) {
thumbnailUrl = 'https:' + thumbnailUrl
} else if (thumbnailUrl.startsWith(`${this.currentInvidiousInstanceUrl}/ggpht`)) {
thumbnailUrl = thumbnailUrl.replace(`${this.currentInvidiousInstanceUrl}/ggpht`, 'https://yt3.googleusercontent.com')
}
if (thumbnailUrl?.startsWith('//')) {
thumbnailUrl = 'https:' + thumbnailUrl
}

subscriptionUpdates.push({
Expand Down
18 changes: 16 additions & 2 deletions src/renderer/store/modules/profiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,11 @@ const actions = {
}

if (channelThumbnailUrl) {
const thumbnail = channelThumbnailUrl.replace(/=s\d*/, '=s176') // change thumbnail size if different
const thumbnail = channelThumbnailUrl
// change thumbnail size if different
.replace(/=s\d*/, '=s176')
// If this is an Invidious URL, convert it to a YouTube one
.replace(/^https?:\/\/[^/]+\/ggpht/, 'https://yt3.googleusercontent.com')

if (channel.thumbnail !== thumbnail) {
channel.thumbnail = thumbnail
Expand All @@ -129,7 +133,12 @@ const actions = {
},

async updateSubscriptionDetails({ dispatch, state }, { channelThumbnailUrl, channelName, channelId }) {
const thumbnail = channelThumbnailUrl?.replace(/=s\d*/, '=s176') ?? null // change thumbnail size if different
const thumbnail = channelThumbnailUrl
// change thumbnail size if different
?.replace(/=s\d*/, '=s176')
// If this is an Invidious URL, convert it to a YouTube one
.replace(/^https?:\/\/[^/]+\/ggpht/, 'https://yt3.googleusercontent.com') ??
null
const profileList = state.profileList
for (const profile of profileList) {
const currentProfileCopy = deepCopy(profile)
Expand Down Expand Up @@ -173,6 +182,11 @@ const actions = {
},

async addChannelToProfiles({ commit }, { channel, profileIds }) {
// If this is an Invidious URL, convert it to a YouTube one
if (!channel.thumbnail.startsWith('https://yt3.googleusercontent.com/')) {
channel.thumbnail = channel.thumbnail.replace(/^https?:\/\/[^/]+\/ggpht/, 'https://yt3.googleusercontent.com')
}

try {
await DBProfileHandlers.addChannelToProfiles(channel, profileIds)
commit('addChannelToProfiles', { channel, profileIds })
Expand Down