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.Gelbooru { public class GallerySource : IGallerySource { public string Name => "Gelbooru"; public string Route => "gelbooru"; public string FlyoutIconKey => "Gelbooru"; public string HomePage => "https://gelbooru.com"; public async Task GetRecentItemsAsync(int page) { var offset = (page - 1) * 42; var url = $"https://gelbooru.com/index.php?page=post&s=list&tags=all&pid={offset}"; var (result, error) = await NetHelper.RequestObject(url, @return: content => ResolveGalleryItems(content)); if (result == null || !string.IsNullOrEmpty(error)) { Log.Error("gelbooru.content.load", $"failed to load content array, error: {error}"); return null; } return result; } private GalleryItem[] ResolveGalleryItems(string content) { var regex = new Regex( @"(.|\n)+?