favorite & view page & etc.
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using Gallery.Util;
|
||||
@ -8,14 +9,14 @@ using Xamarin.Forms;
|
||||
|
||||
namespace Gallery.Sources.Gelbooru
|
||||
{
|
||||
public class GallerySource : IGallerySource
|
||||
public class GallerySource : GallerySourceBase
|
||||
{
|
||||
public string Name => "Gelbooru";
|
||||
public string Route => "gelbooru";
|
||||
public string FlyoutIconKey => "Gelbooru";
|
||||
public string HomePage => "https://gelbooru.com";
|
||||
public override string Name => "Gelbooru";
|
||||
public override string Route => "gelbooru";
|
||||
public override string FlyoutIconKey => "Gelbooru";
|
||||
public override string HomePage => "https://gelbooru.com";
|
||||
|
||||
public async Task<GalleryItem[]> GetRecentItemsAsync(int page)
|
||||
public override async Task<IEnumerable<GalleryItem>> GetRecentItemsAsync(int page)
|
||||
{
|
||||
var offset = (page - 1) * 42;
|
||||
var url = $"https://gelbooru.com/index.php?page=post&s=list&tags=all&pid={offset}";
|
||||
@ -42,21 +43,54 @@ namespace Gallery.Sources.Gelbooru
|
||||
var g = matches[i].Groups;
|
||||
items[i] = new GalleryItem(int.Parse(g[2].Value))
|
||||
{
|
||||
RawUrl = g[3].Value,
|
||||
RawUrl = g[3].Value.Replace("&", "&"),
|
||||
PreviewUrl = g[5].Value,
|
||||
Tags = g[6].Value.Split(' '),
|
||||
Source = Route,
|
||||
IsRawPage = true
|
||||
};
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
public void SetCookie()
|
||||
public override async Task<string> ResolveImageUrl(GalleryItem item)
|
||||
{
|
||||
var (result, error) = await NetHelper.RequestObject(item.RawUrl, @return: content =>
|
||||
{
|
||||
var regex = new Regex(
|
||||
@"<section class=""image-container.+?" + // data-id=""(\d+?)"".+?data-tags=""([^""]+?)"".+?
|
||||
@"data-width=""(\d+?)"" data-height=""(\d+?)"".+?data-uploader-id=""([^""]*?)"" " +
|
||||
@"data-normalized-source=""([^""]+?)""(.|\n)*?<img .*?src=""([^""]+?)""",
|
||||
RegexOptions.Multiline);
|
||||
var m = regex.Match(content);
|
||||
if (m.Success)
|
||||
{
|
||||
var g = m.Groups;
|
||||
item.Width = int.Parse(g[1].Value);
|
||||
item.Height = int.Parse(g[2].Value);
|
||||
item.UserId = g[3].Value;
|
||||
item.SourceUrl = g[4].Value;
|
||||
item.RawUrl = g[6].Value;
|
||||
return item.RawUrl;
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
||||
if (result == null || !string.IsNullOrEmpty(error))
|
||||
{
|
||||
Log.Error("gelbooru.imageUrl.resolve", $"failed to load data, error: {error}");
|
||||
return null;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override void SetCookie()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void InitDynamicResources(string family, ResourceDictionary light, ResourceDictionary dark)
|
||||
public override void InitDynamicResources(string family, ResourceDictionary light, ResourceDictionary dark)
|
||||
{
|
||||
var icon = new FontImageSource
|
||||
{
|
||||
|
Reference in New Issue
Block a user