forked from extern/GetMoarFediverse
parent
6dcc1a0327
commit
fe7703bd9f
@ -2,6 +2,7 @@
|
|||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using GetMoarFediverse;
|
using GetMoarFediverse;
|
||||||
using GetMoarFediverse.Configuration;
|
using GetMoarFediverse.Configuration;
|
||||||
|
using GetMoarFediverse.Responses;
|
||||||
using TurnerSoftware.RobotsExclusionTools;
|
using TurnerSoftware.RobotsExclusionTools;
|
||||||
|
|
||||||
var configPath = Environment.GetEnvironmentVariable("CONFIG_PATH");
|
var configPath = Environment.GetEnvironmentVariable("CONFIG_PATH");
|
||||||
@ -109,10 +110,12 @@ await Parallel.ForEachAsync(sitesTags, new ParallelOptions{MaxDegreeOfParallelis
|
|||||||
}
|
}
|
||||||
|
|
||||||
HttpResponseMessage? response = null;
|
HttpResponseMessage? response = null;
|
||||||
|
string? json = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
response = await client.GetAsync(url);
|
response = await client.GetAsync(url);
|
||||||
response.EnsureSuccessStatusCode();
|
response.EnsureSuccessStatusCode();
|
||||||
|
json = await response.Content.ReadAsStringAsync();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@ -120,9 +123,18 @@ await Parallel.ForEachAsync(sitesTags, new ParallelOptions{MaxDegreeOfParallelis
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var json = await response.Content.ReadAsStringAsync();
|
StatusResponse[]? data;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
data = JsonSerializer.Deserialize(json, CamelCaseJsonContext.Default.StatusResponseArray);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Error deserializing the response when pulling #{tag} posts from {site}. Error: {e.Message}");
|
||||||
|
Console.WriteLine($"Got the following response while I expected json content: {json}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var data = JsonSerializer.Deserialize(json, CamelCaseJsonContext.Default.StatusResponseArray);
|
|
||||||
if (data == null)
|
if (data == null)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Error deserializing the response when pulling #{tag} posts from {site}");
|
Console.WriteLine($"Error deserializing the response when pulling #{tag} posts from {site}");
|
||||||
|
Loading…
Reference in New Issue
Block a user