Skip to content

Commit

Permalink
Adding new properties to watch properties section
Browse files Browse the repository at this point in the history
  • Loading branch information
boggydigital committed Jul 1, 2024
1 parent 9cd76fd commit 1666e9e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 23 deletions.
5 changes: 0 additions & 5 deletions data/properties.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -78,8 +75,6 @@ func VideoProperties() []string {
VideoDownloadStartedProperty,
VideoDownloadCompletedProperty,
VideoDownloadCleanedUpProperty,
VideoWatchlistQueuedProperty,
VideoWatchlistDequeuedProperty,
VideoCaptionsLanguagesProperty,
VideoCaptionsKindsProperty,
VideoCaptionsNamesProperty,
Expand Down
31 changes: 13 additions & 18 deletions rest/view_models/watch_view_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"os"
"path/filepath"
"slices"
"sort"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -41,14 +42,15 @@ 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",
data.VideoEndedReasonProperty: "Ended Reason",
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",
}
Expand Down Expand Up @@ -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) {
Expand All @@ -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]
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 1666e9e

Please sign in to comment.