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' ); } }