From 1666e9ec1e8ccb492d7d32f29f4f82e24f1ada0d Mon Sep 17 00:00:00 2001 From: Bogdan Brinza Date: Mon, 1 Jul 2024 12:58:57 -0700 Subject: [PATCH] Adding new properties to watch properties section --- data/properties.go | 5 ----- rest/view_models/watch_view_model.go | 31 ++++++++++++---------------- 2 files changed, 13 insertions(+), 23 deletions(-) diff --git a/data/properties.go b/data/properties.go index 7d3d47c..e11a4fa 100644 --- a/data/properties.go +++ b/data/properties.go @@ -29,9 +29,6 @@ const ( VideoDownloadCompletedProperty = "video-download-completed" VideoDownloadCleanedUpProperty = "video-download-cleaned-up" - VideoWatchlistQueuedProperty = "video-watchlist-queued" - VideoWatchlistDequeuedProperty = "video-watchlist-dequeued" - VideoCaptionsLanguagesProperty = "video-captions-languages" VideoCaptionsKindsProperty = "video-captions-kinds" VideoCaptionsNamesProperty = "video-captions-names" @@ -78,8 +75,6 @@ func VideoProperties() []string { VideoDownloadStartedProperty, VideoDownloadCompletedProperty, VideoDownloadCleanedUpProperty, - VideoWatchlistQueuedProperty, - VideoWatchlistDequeuedProperty, VideoCaptionsLanguagesProperty, VideoCaptionsKindsProperty, VideoCaptionsNamesProperty, diff --git a/rest/view_models/watch_view_model.go b/rest/view_models/watch_view_model.go index 1d119cc..86d0b8c 100644 --- a/rest/view_models/watch_view_model.go +++ b/rest/view_models/watch_view_model.go @@ -13,6 +13,7 @@ import ( "os" "path/filepath" "slices" + "sort" "strconv" "strings" "time" @@ -41,7 +42,7 @@ var propertyTitles = map[string]string{ data.VideoViewCountProperty: "Views", data.VideoKeywordsProperty: "Keywords", data.VideoCategoryProperty: "Category", - data.VideoUploadDateProperty: " Uploaded", + data.VideoUploadDateProperty: "Uploaded", data.VideoPublishDateProperty: "Published", data.VideoDurationProperty: "Duration", data.VideoEndedDateProperty: "Ended Date", @@ -49,6 +50,7 @@ var propertyTitles = map[string]string{ data.VideoDownloadQueuedProperty: "Download Queued", data.VideoDownloadStartedProperty: "Download Started", data.VideoDownloadCompletedProperty: "Download Completed", + data.VideoDownloadCleanedUpProperty: "Download Cleaned Up", data.VideoForcedDownloadProperty: "Forced Download", data.VideoPreferSingleFormatProperty: "Prefer Single Format", } @@ -172,25 +174,10 @@ func GetWatchViewModel(videoId, currentTime string, rdx kvas.WriteableRedux) (*W data.VideoKeywordsProperty, data.VideoCategoryProperty, } - properties := []string{ - data.VideoViewCountProperty, - data.VideoKeywordsProperty, - data.VideoCategoryProperty, - data.VideoUploadDateProperty, - data.VideoPublishDateProperty, - data.VideoDownloadCompletedProperty, - data.VideoDurationProperty, - data.VideoEndedDateProperty, - data.VideoEndedReasonProperty, - data.VideoDownloadQueuedProperty, - data.VideoForcedDownloadProperty, - data.VideoPreferSingleFormatProperty, - } - videoProperties := make(map[string]string) - titles := make([]string, 0, len(properties)) + titles := make([]string, 0, len(propertyTitles)) - for _, p := range properties { + for p := range propertyTitles { title := propertyTitles[p] titles = append(titles, title) if slices.Contains(joinProperties, p) { @@ -204,6 +191,8 @@ func GetWatchViewModel(videoId, currentTime string, rdx kvas.WriteableRedux) (*W } } + sort.Strings(titles) + playlistId := "" if playlistIds := rdx.MatchAsset(data.PlaylistVideosProperty, []string{videoId}, nil); len(playlistIds) > 0 { playlistId = playlistIds[0] @@ -306,8 +295,14 @@ func fmtPropertyValue(property, value string) string { fallthrough case data.VideoPublishDateProperty: fallthrough + case data.VideoDownloadQueuedProperty: + fallthrough + case data.VideoDownloadStartedProperty: + fallthrough case data.VideoDownloadCompletedProperty: fallthrough + case data.VideoDownloadCleanedUpProperty: + fallthrough case data.VideoEndedDateProperty: if dt, err := time.Parse(time.RFC3339, value); err == nil { return dt.Format(time.RFC1123)