using ImportDataAsRelay.Helpers; using Jil; var interestingTagsEverywhere = new[] { "dotnet", "csharp" }; var sources = new Dictionary { ["hachyderm.io"] = new [] { "hachyderm" }, ["mastodon.social"] = Array.Empty(), ["dotnet.social"] = Array.Empty(), }; var client = new HttpClient(); foreach (var (site, specificTags) in sources) { var tags = specificTags.Concat(interestingTagsEverywhere).ToList(); foreach (var tag in tags) { Console.WriteLine($"Fetching tag #{tag} from {site}"); var response = await client.GetAsync($"https://{site}/tags/{tag}.json"); try { response.EnsureSuccessStatusCode(); } catch (Exception e) { Console.WriteLine($"Error fetching tag, status code: {response.StatusCode}. Error: {e.Message}"); continue; } var json = await response.Content.ReadAsStringAsync(); var data = JSON.Deserialize(json, Options.CamelCase); foreach (var statusLink in data.OrderedItems) { Console.WriteLine($"Bringing in {statusLink}"); try { await MastodonHelper.EnqueueStatusToFetch(statusLink); await Task.Delay(500); } catch (Exception e) { Console.WriteLine($"{e.Message}"); } } } } public class TagResponse { public string[] OrderedItems { get; private set; } }