mirror of
https://github.com/SoPat712/allstarr.git
synced 2026-02-09 23:55:10 -05:00
I really hate time
This commit is contained in:
@@ -352,34 +352,19 @@ public class SpotifyMissingTracksFetcher : BackgroundService
|
||||
DateTime? foundFileTime = null;
|
||||
|
||||
// First search forward 24 hours (most likely to find newest files with timezone ahead)
|
||||
_logger.LogInformation(" Phase 1: Searching forward 24 hours (from {Start:HH:mm} to {End:HH:mm} UTC)...",
|
||||
now.AddMinutes(1), now.AddMinutes(1440));
|
||||
_logger.LogInformation(" Phase 1: Searching forward 24 hours...");
|
||||
|
||||
var lastLoggedMinute = -1;
|
||||
for (var minutesAhead = 1; minutesAhead <= 1440; minutesAhead++)
|
||||
{
|
||||
if (cancellationToken.IsCancellationRequested) break;
|
||||
|
||||
var time = now.AddMinutes(minutesAhead);
|
||||
|
||||
// Log every 10 minutes to show progress with actual filename
|
||||
if (minutesAhead % 10 == 0 && minutesAhead != lastLoggedMinute)
|
||||
{
|
||||
var sampleFilename = $"{playlistName}_missing_{time:yyyy-MM-dd_HH-mm}.json";
|
||||
_logger.LogInformation(" Checking around: {Filename}", sampleFilename);
|
||||
lastLoggedMinute = minutesAhead;
|
||||
}
|
||||
|
||||
var result = await TryFetchMissingTracksFile(playlistName, time, jellyfinUrl, apiKey, httpClient, cancellationToken);
|
||||
if (result.found)
|
||||
{
|
||||
found = true;
|
||||
foundFileTime = result.fileTime;
|
||||
if (foundFileTime.HasValue)
|
||||
{
|
||||
_logger.LogInformation(" ✓ Found file from {Time:yyyy-MM-dd HH:mm} UTC (+{Offset:F1}h ahead)",
|
||||
foundFileTime.Value, (foundFileTime.Value - now).TotalHours);
|
||||
}
|
||||
break; // Found newest file, stop searching
|
||||
}
|
||||
|
||||
@@ -393,34 +378,19 @@ public class SpotifyMissingTracksFetcher : BackgroundService
|
||||
// If not found forward, search backwards 48 hours
|
||||
if (!found)
|
||||
{
|
||||
_logger.LogInformation(" Phase 2: Searching backward 48 hours (from {Start:HH:mm} to {End:HH:mm} UTC)...",
|
||||
now, now.AddMinutes(-2880));
|
||||
_logger.LogInformation(" Phase 2: Searching backward 48 hours...");
|
||||
|
||||
lastLoggedMinute = -1;
|
||||
for (var minutesBehind = 0; minutesBehind <= 2880; minutesBehind++)
|
||||
{
|
||||
if (cancellationToken.IsCancellationRequested) break;
|
||||
|
||||
var time = now.AddMinutes(-minutesBehind);
|
||||
|
||||
// Log every 10 minutes to show progress with actual filename
|
||||
if (minutesBehind % 10 == 0 && minutesBehind != lastLoggedMinute)
|
||||
{
|
||||
var sampleFilename = $"{playlistName}_missing_{time:yyyy-MM-dd_HH-mm}.json";
|
||||
_logger.LogInformation(" Checking around: {Filename}", sampleFilename);
|
||||
lastLoggedMinute = minutesBehind;
|
||||
}
|
||||
|
||||
var result = await TryFetchMissingTracksFile(playlistName, time, jellyfinUrl, apiKey, httpClient, cancellationToken);
|
||||
if (result.found)
|
||||
{
|
||||
found = true;
|
||||
foundFileTime = result.fileTime;
|
||||
if (foundFileTime.HasValue)
|
||||
{
|
||||
_logger.LogInformation(" ✓ Found file from {Time:yyyy-MM-dd HH:mm} UTC (-{Offset:F1}h ago)",
|
||||
foundFileTime.Value, (now - foundFileTime.Value).TotalHours);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -488,7 +458,8 @@ public class SpotifyMissingTracksFetcher : BackgroundService
|
||||
|
||||
try
|
||||
{
|
||||
_logger.LogDebug("Checking: {Filename}", filename);
|
||||
// Log every request with the actual filename
|
||||
_logger.LogInformation("Checking: {Playlist} at {DateTime}", playlistName, time.ToString("yyyy-MM-dd HH:mm"));
|
||||
|
||||
var response = await httpClient.GetAsync(url, cancellationToken);
|
||||
if (response.IsSuccessStatusCode)
|
||||
@@ -506,7 +477,7 @@ public class SpotifyMissingTracksFetcher : BackgroundService
|
||||
await SaveToFileCache(playlistName, tracks);
|
||||
|
||||
_logger.LogInformation(
|
||||
"✓ Cached {Count} missing tracks for {Playlist} from {Filename} (no expiration until next Jellyfin job)",
|
||||
"✓ FOUND! Cached {Count} missing tracks for {Playlist} from {Filename}",
|
||||
tracks.Count, playlistName, filename);
|
||||
return (true, time);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user