Skip to content

Commit

Permalink
Fixing build breaks caused by deps bump
Browse files Browse the repository at this point in the history
  • Loading branch information
boggydigital committed Feb 6, 2025
1 parent 9ad6453 commit 3cc84df
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 57 deletions.
2 changes: 1 addition & 1 deletion cli/cleanup_ended_videos.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func CleanupEndedVideos(now bool, rdx redux.Writeable) error {

cleanupVideoIds := make([]string, 0)

for _, id := range rdx.Keys(data.VideoEndedDateProperty) {
for id := range rdx.Keys(data.VideoEndedDateProperty) {

// don't cleanup favorite videos
if rdx.HasKey(data.VideoFavoriteProperty, id) {
Expand Down
5 changes: 2 additions & 3 deletions cli/dehydrate_posters.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,13 @@ func DehydratePosters(force bool) error {
return dpa.EndWithError(err)
}

videoIds := rdx.Keys(data.VideoTitleProperty)
dpa.TotalInt(len(videoIds))
dpa.TotalInt(rdx.Len(data.VideoTitleProperty))

dehydratedPosters := make(map[string][]string)
dehydratedRepColors := make(map[string][]string)
dehydratedInputMissing := make(map[string][]string)

for _, videoId := range videoIds {
for videoId := range rdx.Keys(data.VideoTitleProperty) {

if rdx.HasKey(data.VideoDehydratedInputMissingProperty, videoId) && !force {
dpa.Increment()
Expand Down
2 changes: 1 addition & 1 deletion cli/process_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func getNextQueuedDownload(rdx redux.Writeable, force bool) (string, error) {
return "", err
}

for _, id := range rdx.Keys(data.VideoDownloadQueuedProperty) {
for id := range rdx.Keys(data.VideoDownloadQueuedProperty) {

vdqTime := ""
if vdq, ok := rdx.GetLastVal(data.VideoDownloadQueuedProperty, id); ok && vdq != "" {
Expand Down
5 changes: 2 additions & 3 deletions cli/queue_channels_downloads.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ func QueueChannelsDownloads(rdx redux.Writeable) error {
return qcda.EndWithError(err)
}

channelsIds := rdx.Keys(data.ChannelAutoDownloadProperty)
qcda.TotalInt(len(channelsIds))
qcda.TotalInt(rdx.Len(data.ChannelAutoDownloadProperty))

for _, channelId := range channelsIds {
for channelId := range rdx.Keys(data.ChannelAutoDownloadProperty) {

if err := queueChannelDownloads(rdx, channelId); err != nil {
return qcda.EndWithError(err)
Expand Down
5 changes: 2 additions & 3 deletions cli/queue_playlists_downloads.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ func QueuePlaylistsDownloads(rdx redux.Writeable) error {
return qpda.EndWithError(err)
}

playlistIds := rdx.Keys(data.PlaylistAutoDownloadProperty)
qpda.TotalInt(len(playlistIds))
qpda.TotalInt(rdx.Len(data.PlaylistAutoDownloadProperty))

for _, playlistId := range playlistIds {
for playlistId := range rdx.Keys(data.PlaylistAutoDownloadProperty) {

if err := queuePlaylistDownloads(rdx, playlistId); err != nil {
return qpda.EndWithError(err)
Expand Down
5 changes: 2 additions & 3 deletions cli/refresh_channels_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,13 @@ func RefreshChannelsMetadata(rdx redux.Writeable) error {
}

// update auto-refresh channels metadata
channelIds := rdx.Keys(data.ChannelAutoRefreshProperty)
ucma.TotalInt(len(channelIds))
ucma.TotalInt(rdx.Len(data.ChannelAutoRefreshProperty))

refreshOptions := &ChannelOptions{
Force: true,
}

for _, channelId := range channelIds {
for channelId := range rdx.Keys(data.ChannelAutoRefreshProperty) {

if err := GetChannelsMetadata(rdx, refreshOptions, channelId); err != nil {
return ucma.EndWithError(err)
Expand Down
5 changes: 2 additions & 3 deletions cli/refresh_playlists_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,13 @@ func RefreshPlaylistsMetadata(rdx redux.Writeable) error {
}

// update auto-refresh playlists metadata
playlistIds := rdx.Keys(data.PlaylistAutoRefreshProperty)
upma.TotalInt(len(playlistIds))
upma.TotalInt(rdx.Len(data.PlaylistAutoRefreshProperty))

refreshOptions := &PlaylistOptions{
Force: true,
}

for _, playlistId := range playlistIds {
for playlistId := range rdx.Keys(data.PlaylistAutoRefreshProperty) {

if err := GetPlaylistsMetadata(rdx, refreshOptions, playlistId); err != nil {
return upma.EndWithError(err)
Expand Down
9 changes: 4 additions & 5 deletions cli/scrub_deposition_properties.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,22 @@ func ScrubDepositionProperties(rdx redux.Writeable) error {

currentVideoIds := make(map[string]any)

for _, videoId := range rdx.Keys(data.VideoDownloadCompletedProperty) {
for videoId := range rdx.Keys(data.VideoDownloadCompletedProperty) {
if rdx.HasKey(data.VideoEndedDateProperty, videoId) {
continue
}
currentVideoIds[videoId] = nil
}

for _, channelId := range rdx.Keys(data.ChannelAutoRefreshProperty) {
for channelId := range rdx.Keys(data.ChannelAutoRefreshProperty) {
if videos, ok := rdx.GetAllValues(data.ChannelVideosProperty, channelId); ok {
for _, videoId := range videos {
currentVideoIds[videoId] = nil
}
}
}

for _, playlistId := range rdx.Keys(data.PlaylistAutoRefreshProperty) {
for playlistId := range rdx.Keys(data.PlaylistAutoRefreshProperty) {
if videos, ok := rdx.GetAllValues(data.PlaylistVideosProperty, playlistId); ok {
for _, videoId := range videos {
currentVideoIds[videoId] = nil
Expand All @@ -63,8 +63,7 @@ func ScrubDepositionProperties(rdx redux.Writeable) error {
sdpa.Increment()
continue
}
videos := rdx.Keys(vp)
for _, videoId := range videos {
for videoId := range rdx.Keys(vp) {
if _, ok := currentVideoIds[videoId]; !ok {
if rdx.HasKey(vp, videoId) {
if err := rdx.CutKeys(vp, videoId); err != nil {
Expand Down
6 changes: 2 additions & 4 deletions cli/scrub_ended_properties.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,9 @@ func ScrubEndedProperties(rdx redux.Writeable) error {
return sevpa.EndWithError(err)
}

endedVideos := rdx.Keys(data.VideoEndedDateProperty)
sevpa.TotalInt(rdx.Len(data.VideoEndedDateProperty))

sevpa.TotalInt(len(endedVideos))

for _, videoId := range endedVideos {
for videoId := range rdx.Keys(data.VideoEndedDateProperty) {

for _, vp := range data.VideoProperties() {
if slices.Contains(preserveVideoProperties, vp) {
Expand Down
3 changes: 1 addition & 2 deletions rest/get_compton.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ func GetCompton(w http.ResponseWriter, r *http.Request) {

p := compton.Page("compton test area")

videoIds := rdx.Keys(data.VideoTitleProperty)
slices.Sort(videoIds)
videoIds := slices.Sorted(rdx.Keys(data.VideoTitleProperty))
videoIds = videoIds[:20]

pageStack := compton.FlexItems(p, direction.Column)
Expand Down
7 changes: 4 additions & 3 deletions rest/get_history.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ func GetHistory(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/html")

whKeys := rdx.Keys(data.VideoEndedDateProperty)
whKeysLen := rdx.Len(data.VideoEndedDateProperty)

pageTitle := fmt.Sprintf("Last %d watched videos (out of %d)", endedVideosLimit, len(whKeys))
pageTitle := fmt.Sprintf("Last %d watched videos (out of %d)", endedVideosLimit, whKeysLen)
if showAll {
pageTitle = fmt.Sprintf("All %d watched videos", len(whKeys))
pageTitle = fmt.Sprintf("All %d watched videos", whKeysLen)
}

hvm := &HistoryViewModel{
Expand All @@ -55,7 +56,7 @@ func GetHistory(w http.ResponseWriter, r *http.Request) {
}

endedGroups := make(map[string][]string)
for _, id := range whKeys {
for id := range whKeys {
group := olderGroup
if ets, ok := rdx.GetLastVal(data.VideoEndedDateProperty, id); ok && ets != "" {
if et, err := time.Parse(time.RFC3339, ets); err == nil {
Expand Down
48 changes: 25 additions & 23 deletions rest/view_models/list_view_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/boggydigital/redux"
"github.com/boggydigital/yet/data"
"github.com/boggydigital/yet/yeti"
"slices"
)

type ListViewModel struct {
Expand Down Expand Up @@ -99,21 +100,20 @@ func GetListViewModel(rdx redux.Readable) (*ListViewModel, error) {
return nil, err
}

lvm.HasHistory = len(rdx.Keys(data.VideoEndedDateProperty)) > 0
lvm.HasHistory = rdx.Len(data.VideoEndedDateProperty) > 0

return lvm, nil
}

func getVideosProgress(rdx redux.Readable) ([]string, error) {
vpKeys := rdx.Keys(data.VideoProgressProperty)
cvs := make([]string, 0)
var err error

if len(vpKeys) == 0 {
if rdx.Len(data.VideoProgressProperty) == 0 {
return cvs, nil
}

for _, id := range vpKeys {
for id := range rdx.Keys(data.VideoProgressProperty) {
if et, ok := rdx.GetLastVal(data.VideoEndedDateProperty, id); ok && et != "" {
continue
}
Expand All @@ -129,10 +129,9 @@ func getVideosProgress(rdx redux.Readable) ([]string, error) {

func getVideoDownloads(rdx redux.Readable) ([]string, error) {

dcKeys := rdx.Keys(data.VideoDownloadCompletedProperty)
dvs := make([]string, 0, len(dcKeys))
dvs := make([]string, 0, rdx.Len(data.VideoDownloadCompletedProperty))

if len(dcKeys) == 0 {
if rdx.Len(data.VideoDownloadCompletedProperty) == 0 {
return dvs, nil
}

Expand All @@ -143,7 +142,7 @@ func getVideoDownloads(rdx redux.Readable) ([]string, error) {
// - in any auto-refreshing channel
// - in any auto-refreshing playlist

for _, id := range dcKeys {
for id := range rdx.Keys(data.VideoDownloadCompletedProperty) {

if rdx.HasKey(data.VideoEndedDateProperty, id) {
continue
Expand All @@ -157,7 +156,7 @@ func getVideoDownloads(rdx redux.Readable) ([]string, error) {

// check if this video is an auto-refreshing channel video
skip := false
for _, channelId := range rdx.Keys(data.ChannelAutoRefreshProperty) {
for channelId := range rdx.Keys(data.ChannelAutoRefreshProperty) {
if rdx.HasValue(data.ChannelVideosProperty, channelId, id) {
skip = true
break
Expand All @@ -169,7 +168,7 @@ func getVideoDownloads(rdx redux.Readable) ([]string, error) {

// check if this video is an auto-refreshing playlist video
skip = false
for _, playlistId := range rdx.Keys(data.PlaylistAutoRefreshProperty) {
for playlistId := range rdx.Keys(data.PlaylistAutoRefreshProperty) {
if rdx.HasValue(data.PlaylistVideosProperty, playlistId, id) {
skip = true
break
Expand All @@ -191,16 +190,17 @@ func getVideoDownloads(rdx redux.Readable) ([]string, error) {
}

func getChannelsVideos(rdx redux.Readable) (map[string][]string, error) {
chKeys := rdx.Keys(data.ChannelAutoRefreshProperty)
chs := make(map[string][]string)

if len(chKeys) == 0 {
chKeysLen := rdx.Len(data.ChannelAutoRefreshProperty)

if chKeysLen == 0 {
return chs, nil
}

chNewVideos, chNoNewVideos := make([]string, 0, len(chKeys)), make([]string, 0, len(chKeys))
chNewVideos, chNoNewVideos := make([]string, 0, chKeysLen), make([]string, 0, chKeysLen)

for _, channelId := range chKeys {
for channelId := range rdx.Keys(data.ChannelAutoRefreshProperty) {
if newVideos := yeti.ChannelNotEndedVideos(channelId, rdx); len(newVideos) > 0 {
chNewVideos = append(chNewVideos, channelId)
} else {
Expand All @@ -226,16 +226,17 @@ func getChannelsVideos(rdx redux.Readable) (map[string][]string, error) {
}

func getPlaylistsVideos(rdx redux.Readable) (map[string][]string, error) {
plKeys := rdx.Keys(data.PlaylistAutoRefreshProperty)
pls := make(map[string][]string)

if len(plKeys) == 0 {
plKeysLen := rdx.Len(data.PlaylistAutoRefreshProperty)

if plKeysLen == 0 {
return pls, nil
}

plNewVideos, plNoNewVideos := make([]string, 0, len(plKeys)), make([]string, 0, len(plKeys))
plNewVideos, plNoNewVideos := make([]string, 0, plKeysLen), make([]string, 0, plKeysLen)

for _, playlistId := range plKeys {
for playlistId := range rdx.Keys(data.PlaylistAutoRefreshProperty) {
if newVideos := yeti.PlaylistNotEndedVideos(playlistId, rdx); len(newVideos) > 0 {
plNewVideos = append(plNewVideos, playlistId)
} else {
Expand All @@ -262,14 +263,15 @@ func getPlaylistsVideos(rdx redux.Readable) (map[string][]string, error) {

func getQueuedDownloads(rdx redux.Readable) ([]string, error) {

dqKeys := rdx.Keys(data.VideoDownloadQueuedProperty)
qds := make([]string, 0, len(dqKeys))
qdLen := rdx.Len(data.VideoDownloadQueuedProperty)

qds := make([]string, 0, qdLen)

if len(dqKeys) == 0 {
if qdLen == 0 {
return qds, nil
}

for _, id := range dqKeys {
for id := range rdx.Keys(data.VideoDownloadQueuedProperty) {

dqTime := ""
if dqt, ok := rdx.GetLastVal(data.VideoDownloadQueuedProperty, id); ok {
Expand All @@ -294,7 +296,7 @@ func getQueuedDownloads(rdx redux.Readable) ([]string, error) {
}

func getFavoriteVideos(rdx redux.Readable) ([]string, error) {
fvs := rdx.Keys(data.VideoFavoriteProperty)
fvs := slices.Collect(rdx.Keys(data.VideoFavoriteProperty))
var err error
if fvs, err = rdx.Sort(fvs, false, data.VideoTitleProperty); err == nil {
return fvs, nil
Expand Down
10 changes: 7 additions & 3 deletions rest/view_models/watch_view_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,18 @@ func GetWatchViewModel(videoId, currentTime string, rdx redux.Writeable) (*Watch

allPlaylistsWithVideo := rdx.MatchAsset(data.PlaylistVideosProperty, []string{videoId}, nil)
playlistId := ""
for _, pid := range allPlaylistsWithVideo {
for pid := range allPlaylistsWithVideo {
if rdx.HasKey(data.PlaylistAutoRefreshProperty, pid) {
playlistId = pid
break
}
}
if playlistId == "" && len(allPlaylistsWithVideo) > 0 {
playlistId = allPlaylistsWithVideo[0]

if playlistId == "" {
for pid := range allPlaylistsWithVideo {
playlistId = pid
break
}
}

channelId := ""
Expand Down

0 comments on commit 3cc84df

Please sign in to comment.