Skip to content

Commit

Permalink
Fix silly error.
Browse files Browse the repository at this point in the history
  • Loading branch information
giorgi1324 committed Nov 14, 2024
1 parent 06d0281 commit 95c3b28
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,10 @@ await Parallel.ForEachAsync(batchProcessables.Select(t => t.InfoHash), options,

var decodedJson = LZString.DecompressFromEncodedURIComponent(encodedJson.Value);

List<ExtractedDMMContent?> torrents = new();
JsonElement arrayToProcess;
try
{
var json = JsonDocument.Parse(decodedJson);
JsonElement arrayToProcess;

if (json.RootElement.ValueKind == JsonValueKind.Object &&
json.RootElement.TryGetProperty("torrents", out var torrentsProperty) &&
Expand All @@ -125,7 +124,7 @@ await Parallel.ForEachAsync(batchProcessables.Select(t => t.InfoHash), options,
else
{
logger.LogWarning("Unexpected JSON format in {Name}", name);
return null;
return [];
}
}
catch (Exception ex)
Expand All @@ -134,6 +133,12 @@ await Parallel.ForEachAsync(batchProcessables.Select(t => t.InfoHash), options,
return [];
}

var torrents = await arrayToProcess.EnumerateArray()
.ToAsyncEnumerable()
.Select(ParsePageContent)
.Where(t => t is not null)
.ToListAsync();

if (torrents.Count == 0)
{
logger.LogWarning("No torrents found in {Name}", name);
Expand Down

0 comments on commit 95c3b28

Please sign in to comment.