using System; using System.Text.RegularExpressions; using System.Threading.Tasks; using Gallery.Util; using Gallery.Util.Interface; using Gallery.Util.Model; using Xamarin.Forms; namespace Gallery.Sources.Danbooru { public class GallerySource : IGallerySource { public string Name => "Danbooru"; public string Route => "danbooru"; public string FlyoutIconKey => "Danbooru"; public string HomePage => "https://danbooru.donmai.us"; public async Task GetRecentItemsAsync(int page) { var url = $"https://danbooru.donmai.us/posts?page={page}"; var (result, error) = await NetHelper.RequestObject(url, @return: content => ResolveGalleryItems(content)); if (result == null || !string.IsNullOrEmpty(error)) { Log.Error("danbooru.content.load", $"failed to load content array, error: {error}"); return null; } return result; } private GalleryItem[] ResolveGalleryItems(string content) { var regex = new Regex( @"