mirror of
https://github.com/SoPat712/allstarr.git
synced 2026-02-10 07:58:39 -05:00
Fix external track counting by checking matched tracks cache
- External tracks are injected on-the-fly, not stored in Jellyfin DB - Check spotify:matched:ordered cache to get accurate external count - Calculate external tracks as: total matched - local tracks - This will properly show the two-color progress bar (green local + orange external) - All 225 tests passing
This commit is contained in:
@@ -249,15 +249,12 @@ public class AdminController : ControllerBase
|
||||
var localCount = 0;
|
||||
var externalMatchedCount = 0;
|
||||
|
||||
// Count tracks in Jellyfin playlist
|
||||
var jellyfinTrackCount = items.GetArrayLength();
|
||||
|
||||
// Count local vs external tracks
|
||||
foreach (var item in items.EnumerateArray())
|
||||
{
|
||||
// External tracks from allstarr have ExternalProvider in ProviderIds
|
||||
// Local tracks have real filesystem paths
|
||||
var hasPath = item.TryGetProperty("Path", out var pathProp) &&
|
||||
pathProp.ValueKind == JsonValueKind.String &&
|
||||
!string.IsNullOrEmpty(pathProp.GetString());
|
||||
|
||||
// Check if it's an external track by looking at the ID format
|
||||
// External tracks have IDs like "deezer:123456" or "qobuz:123456"
|
||||
var isExternal = false;
|
||||
@@ -271,12 +268,28 @@ public class AdminController : ControllerBase
|
||||
{
|
||||
externalMatchedCount++;
|
||||
}
|
||||
else if (hasPath)
|
||||
else
|
||||
{
|
||||
localCount++;
|
||||
}
|
||||
}
|
||||
|
||||
// Check matched tracks cache to get accurate external count
|
||||
// External tracks are injected on-the-fly, not stored in Jellyfin
|
||||
var matchedTracksKey = $"spotify:matched:ordered:{config.Name}";
|
||||
var matchedTracks = await _cache.GetAsync<List<object>>(matchedTracksKey);
|
||||
|
||||
if (matchedTracks != null && matchedTracks.Count > 0)
|
||||
{
|
||||
// Count how many matched tracks are external (not local)
|
||||
// Assume tracks beyond local count are external
|
||||
var totalMatched = matchedTracks.Count;
|
||||
if (totalMatched > localCount)
|
||||
{
|
||||
externalMatchedCount = totalMatched - localCount;
|
||||
}
|
||||
}
|
||||
|
||||
var totalInJellyfin = localCount + externalMatchedCount;
|
||||
var externalMissingCount = Math.Max(0, spotifyTrackCount - totalInJellyfin);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user