Skip to content

Commit

Permalink
Try to improve the "New Music" menu when used with online music servi…
Browse files Browse the repository at this point in the history
…ces.

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.
  • Loading branch information
michaelherger committed Oct 15, 2024
1 parent 2b29d40 commit 691aa9c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Slim/Schema.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand All @@ -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' );
}
}
Expand Down

1 comment on commit 691aa9c

@michaelherger
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should fix #1142

Please sign in to comment.