From 19402cf4d0f46bc445fb0d64f5cc72de54d94012 Mon Sep 17 00:00:00 2001 From: GLEBR1K <28905234+GLEBR1K@users.noreply.github.com> Date: Fri, 6 Dec 2024 09:43:28 +0300 Subject: [PATCH] playlist: fix published date formatting for upcoming videos --- src/renderer/components/ft-list-video/ft-list-video.js | 8 ++++++++ .../components/watch-video-info/watch-video-info.js | 8 ++++++-- src/renderer/views/Watch/Watch.js | 3 +++ src/renderer/views/Watch/Watch.vue | 1 + 4 files changed, 18 insertions(+), 2 deletions(-) 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 b8fce3eb7c922..04f497026779a 100644 --- a/src/renderer/components/ft-list-video/ft-list-video.js +++ b/src/renderer/components/ft-list-video/ft-list-video.js @@ -679,6 +679,8 @@ export default defineComponent({ }, parseVideoData: function () { + const currentTime = new Date().getTime() + this.id = this.data.videoId this.title = this.data.title // this.thumbnail = this.data.videoThumbnails[4].url @@ -722,8 +724,14 @@ export default defineComponent({ } else if (typeof this.data.published === 'number' && !this.isLive) { this.published = this.data.published + if (this.published > currentTime) { + this.isUpcoming = true + } + if (this.inHistory) { this.uploadedTime = new Date(this.data.published).toLocaleDateString([this.currentLocale, 'en']) + } else if (this.isUpcoming) { + this.uploadedTime = new Date(this.data.published).toLocaleString([this.currentLocale, 'en']) } else { // Use 30 days per month, just like calculatePublishedDate this.uploadedTime = getRelativeTimeFromDate(this.data.published, false) diff --git a/src/renderer/components/watch-video-info/watch-video-info.js b/src/renderer/components/watch-video-info/watch-video-info.js index 36096b6b2e9d8..55590842370c8 100644 --- a/src/renderer/components/watch-video-info/watch-video-info.js +++ b/src/renderer/components/watch-video-info/watch-video-info.js @@ -39,6 +39,10 @@ export default defineComponent({ type: Number, required: true }, + premiere: { + type: Number, + required: true + }, viewCount: { type: Number, required: true @@ -348,7 +352,7 @@ export default defineComponent({ description: this.description, viewCount: this.viewCount, lengthSeconds: this.lengthSeconds, - published: this.published, + published: this.isUpcoming ? this.premiere : this.published, } this.showAddToPlaylistPromptForManyVideos({ videos: [videoData] }) @@ -373,7 +377,7 @@ export default defineComponent({ author: this.channelName, authorId: this.channelId, lengthSeconds: this.lengthSeconds, - published: this.published, + published: this.isUpcoming ? this.premiere : this.published, } this.addVideo({ diff --git a/src/renderer/views/Watch/Watch.js b/src/renderer/views/Watch/Watch.js index e9ff3c753a49e..dc7e7f32456dc 100644 --- a/src/renderer/views/Watch/Watch.js +++ b/src/renderer/views/Watch/Watch.js @@ -99,6 +99,7 @@ export default defineComponent({ channelId: '', channelSubscriptionCountText: '', videoPublished: 0, + premiere: 0, videoStoryboardSrc: '', /** @type {string|null} */ manifestSrc: null, @@ -582,6 +583,7 @@ export default defineComponent({ } } else if (this.isUpcoming) { const upcomingTimestamp = result.basic_info.start_timestamp + this.premiere = upcomingTimestamp.getTime() if (upcomingTimestamp) { const timestampOptions = { @@ -628,6 +630,7 @@ export default defineComponent({ this.upcomingTimeLeft = new Intl.RelativeTimeFormat(this.currentLocale).format(upcomingTimeLeft, timeUnit) } } else { + this.premiere = 0 this.upcomingTimestamp = null this.upcomingTimeLeft = null } diff --git a/src/renderer/views/Watch/Watch.vue b/src/renderer/views/Watch/Watch.vue index 223fad2c21f12..0484ea1b2f622 100644 --- a/src/renderer/views/Watch/Watch.vue +++ b/src/renderer/views/Watch/Watch.vue @@ -122,6 +122,7 @@ :channel-name="channelName" :channel-thumbnail="channelThumbnail" :published="videoPublished" + :premiere="premiere" :subscription-count-text="channelSubscriptionCountText" :like-count="videoLikeCount" :dislike-count="videoDislikeCount"