From 691aa9ca054130cb7de2712285626e9a38ef78c6 Mon Sep 17 00:00:00 2001 From: Michael Herger Date: Tue, 15 Oct 2024 17:15:39 +0200 Subject: [PATCH] Try to improve the "New Music" menu when used with online music services. As we don't have a good "first seen" for online music, let's use the timestamp when an album was added to the user's collection on a given music service as the addition time. This should put online albums in the right place inside the New Music menu. --- Slim/Schema.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Slim/Schema.pm b/Slim/Schema.pm index 472073d012..964530bf72 100644 --- a/Slim/Schema.pm +++ b/Slim/Schema.pm @@ -1528,9 +1528,11 @@ sub _createTrack { $columnValueHash->{urlmd5}, ); + my $externalTrack = $columnValueHash->{extid} && $columnValueHash->{url} eq $columnValueHash->{extid}; + # retrievePersistent will always return undef or a track metadata object if ( !$trackPersistentHash ) { - $persistentColumnValueHash->{added} = time(); + $persistentColumnValueHash->{added} = ($externalTrack && $columnValueHash->{timestamp}) || time(); $persistentColumnValueHash->{url} = $columnValueHash->{url}; $persistentColumnValueHash->{urlmd5} = $columnValueHash->{urlmd5}; @@ -1552,6 +1554,10 @@ sub _createTrack { $trackPersistentHash->{url} = $columnValueHash->{url}; $trackPersistentHash->{urlmd5} = $columnValueHash->{urlmd5}; + if ($externalTrack && $columnValueHash->{timestamp}) { + $trackPersistentHash->{added} = $columnValueHash->{timestamp} + } + $self->_updateHash( tracks_persistent => $trackPersistentHash, 'id' ); } }