Skip to content

Commit

Permalink
playlist: add premiereDate to the metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
GLEBR1K committed Dec 6, 2024
1 parent 19402cf commit ba571eb
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
12 changes: 4 additions & 8 deletions src/renderer/components/ft-list-video/ft-list-video.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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] })
Expand Down Expand Up @@ -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({
Expand Down
12 changes: 7 additions & 5 deletions src/renderer/components/watch-video-info/watch-video-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ export default defineComponent({
type: Number,
required: true
},
premiere: {
type: Number,
required: true
premiereDate: {
type: Date,
default: undefined
},
viewCount: {
type: Number,
Expand Down Expand Up @@ -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] })
Expand All @@ -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({
Expand Down
7 changes: 4 additions & 3 deletions src/renderer/views/Watch/Watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export default defineComponent({
channelId: '',
channelSubscriptionCountText: '',
videoPublished: 0,
premiere: 0,
premiereDate: undefined,
videoStoryboardSrc: '',
/** @type {string|null} */
manifestSrc: null,
Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/views/Watch/Watch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit ba571eb

Please sign in to comment.