From ba571eb30445c8a8f0f0e97e41ba72b19217fba6 Mon Sep 17 00:00:00 2001 From: GLEBR1K <28905234+GLEBR1K@users.noreply.github.com> Date: Fri, 6 Dec 2024 22:06:56 +0300 Subject: [PATCH] playlist: add `premiereDate` to the metadata --- .../components/ft-list-video/ft-list-video.js | 12 ++++-------- .../components/watch-video-info/watch-video-info.js | 12 +++++++----- src/renderer/views/Watch/Watch.js | 7 ++++--- src/renderer/views/Watch/Watch.vue | 2 +- 4 files changed, 16 insertions(+), 17 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 04f497026779a..588597080b806 100644 --- a/src/renderer/components/ft-list-video/ft-list-video.js +++ b/src/renderer/components/ft-list-video/ft-list-video.js @@ -679,8 +679,6 @@ 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 @@ -724,14 +722,8 @@ 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) @@ -784,6 +776,8 @@ export default defineComponent({ viewCount: this.viewCount, lengthSeconds: this.data.lengthSeconds, published: this.published, + premiereDate: this.data.premiereDate, + premiereTimestamp: this.data.premiereTimestamp, } this.showAddToPlaylistPromptForManyVideos({ videos: [videoData] }) @@ -834,6 +828,8 @@ export default defineComponent({ authorId: this.channelId, lengthSeconds: this.data.lengthSeconds, published: this.published, + premiereDate: this.data.premiereDate, + premiereTimestamp: this.data.premiereTimestamp, } this.addVideo({ 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 55590842370c8..71cdf1346d26a 100644 --- a/src/renderer/components/watch-video-info/watch-video-info.js +++ b/src/renderer/components/watch-video-info/watch-video-info.js @@ -39,9 +39,9 @@ export default defineComponent({ type: Number, required: true }, - premiere: { - type: Number, - required: true + premiereDate: { + type: Date, + default: undefined }, viewCount: { type: Number, @@ -352,7 +352,8 @@ export default defineComponent({ description: this.description, viewCount: this.viewCount, lengthSeconds: this.lengthSeconds, - published: this.isUpcoming ? this.premiere : this.published, + published: this.published, + premiereDate: this.premiereDate, } this.showAddToPlaylistPromptForManyVideos({ videos: [videoData] }) @@ -377,7 +378,8 @@ export default defineComponent({ author: this.channelName, authorId: this.channelId, lengthSeconds: this.lengthSeconds, - published: this.isUpcoming ? this.premiere : this.published, + published: this.published, + premiereDate: this.premiereDate, } this.addVideo({ diff --git a/src/renderer/views/Watch/Watch.js b/src/renderer/views/Watch/Watch.js index dc7e7f32456dc..7e6c2a90910b5 100644 --- a/src/renderer/views/Watch/Watch.js +++ b/src/renderer/views/Watch/Watch.js @@ -99,7 +99,7 @@ export default defineComponent({ channelId: '', channelSubscriptionCountText: '', videoPublished: 0, - premiere: 0, + premiereDate: undefined, videoStoryboardSrc: '', /** @type {string|null} */ manifestSrc: null, @@ -583,7 +583,6 @@ export default defineComponent({ } } else if (this.isUpcoming) { const upcomingTimestamp = result.basic_info.start_timestamp - this.premiere = upcomingTimestamp.getTime() if (upcomingTimestamp) { const timestampOptions = { @@ -629,10 +628,12 @@ export default defineComponent({ // TODO a I18n entry for time format might be needed here this.upcomingTimeLeft = new Intl.RelativeTimeFormat(this.currentLocale).format(upcomingTimeLeft, timeUnit) } + + this.premiereDate = upcomingTimestamp } else { - this.premiere = 0 this.upcomingTimestamp = null this.upcomingTimeLeft = null + this.premiereDate = undefined } } else { this.videoLengthSeconds = result.basic_info.duration diff --git a/src/renderer/views/Watch/Watch.vue b/src/renderer/views/Watch/Watch.vue index 0484ea1b2f622..d96fc7fa98ddf 100644 --- a/src/renderer/views/Watch/Watch.vue +++ b/src/renderer/views/Watch/Watch.vue @@ -122,7 +122,7 @@ :channel-name="channelName" :channel-thumbnail="channelThumbnail" :published="videoPublished" - :premiere="premiere" + :premiere-date="premiereDate" :subscription-count-text="channelSubscriptionCountText" :like-count="videoLikeCount" :dislike-count="videoDislikeCount"