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.Danbooru
|
||||
{
|
||||
public class GallerySource : IGallerySource
|
||||
public class GallerySource : GallerySourceBase
|
||||
{
|
||||
public string Name => "Danbooru";
|
||||
public string Route => "danbooru";
|
||||
public string FlyoutIconKey => "Danbooru";
|
||||
public string HomePage => "https://danbooru.donmai.us";
|
||||
public override string Name => "Danbooru";
|
||||
public override string Route => "danbooru";
|
||||
public override string FlyoutIconKey => "Danbooru";
|
||||
public override string HomePage => "https://danbooru.donmai.us";
|
||||
|
||||
public async Task<GalleryItem[]> GetRecentItemsAsync(int page)
|
||||
public override async Task<IEnumerable<GalleryItem>> GetRecentItemsAsync(int page)
|
||||
{
|
||||
var url = $"https://danbooru.donmai.us/posts?page={page}";
|
||||
var (result, error) = await NetHelper.RequestObject(url, @return: content => ResolveGalleryItems(content));
|
||||
@ -47,7 +48,8 @@ namespace Gallery.Sources.Danbooru
|
||||
Width = int.Parse(g[3].Value),
|
||||
Height = int.Parse(g[4].Value),
|
||||
UserId = g[6].Value,
|
||||
Source = g[7].Value,
|
||||
Source = Route,
|
||||
SourceUrl = g[7].Value,
|
||||
RawUrl = g[8].Value,
|
||||
PreviewUrl = g[9].Value
|
||||
};
|
||||
@ -55,12 +57,12 @@ namespace Gallery.Sources.Danbooru
|
||||
return items;
|
||||
}
|
||||
|
||||
public void SetCookie()
|
||||
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
|
||||
{
|
||||
|
41
Gallery.Share/Sources/FavoriteGallerySource.cs
Normal file
41
Gallery.Share/Sources/FavoriteGallerySource.cs
Normal file
@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Gallery.Util;
|
||||
using Gallery.Util.Interface;
|
||||
using Gallery.Util.Model;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace Gallery.Sources
|
||||
{
|
||||
public class FavoriteGallerySource : GallerySourceBase
|
||||
{
|
||||
public override string Name => "Favorite";
|
||||
public override string Route => Routes.Favorite;
|
||||
public override string FlyoutIconKey => "Favorite";
|
||||
public override string HomePage => null;
|
||||
public override bool IsScrollable => false;
|
||||
|
||||
public override Task<IEnumerable<GalleryItem>> GetRecentItemsAsync(int page)
|
||||
{
|
||||
return Task.FromResult((IEnumerable<GalleryItem>)Store.FavoriteList);
|
||||
}
|
||||
|
||||
public override void SetCookie()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void InitDynamicResources(string family, ResourceDictionary light, ResourceDictionary dark)
|
||||
{
|
||||
var icon = new FontImageSource
|
||||
{
|
||||
FontFamily = family,
|
||||
Glyph = "\uf02e",
|
||||
Size = 18.0
|
||||
};
|
||||
light.Add(FlyoutIconKey, icon);
|
||||
dark.Add(FlyoutIconKey, icon);
|
||||
}
|
||||
}
|
||||
}
|
@ -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
|
||||
{
|
||||
|
@ -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.Yandere
|
||||
{
|
||||
public class GallerySource : IGallerySource
|
||||
public class GallerySource : GallerySourceBase
|
||||
{
|
||||
public string Name => "Yande.re";
|
||||
public string Route => "yandere";
|
||||
public string FlyoutIconKey => "Yandere";
|
||||
public string HomePage => "https://yande.re";
|
||||
public override string Name => "Yande.re";
|
||||
public override string Route => "yandere";
|
||||
public override string FlyoutIconKey => "Yandere";
|
||||
public override string HomePage => "https://yande.re";
|
||||
|
||||
public async Task<GalleryItem[]> GetRecentItemsAsync(int page)
|
||||
public override async Task<IEnumerable<GalleryItem>> GetRecentItemsAsync(int page)
|
||||
{
|
||||
var url = $"https://yande.re/post?page={page}";
|
||||
var (result, error) = await NetHelper.RequestObject<YandereItem[]>(url, contentHandler: ContentHandler);
|
||||
@ -37,7 +38,8 @@ namespace Gallery.Sources.Yandere
|
||||
UpdatedTime = y.updated_at.ToLocalTime(),
|
||||
UserId = y.creator_id.ToString(),
|
||||
UserName = y.author,
|
||||
Source = y.source,
|
||||
Source = Route,
|
||||
SourceUrl = y.source,
|
||||
PreviewUrl = y.preview_url,
|
||||
RawUrl = y.file_url,
|
||||
Width = y.width,
|
||||
@ -60,12 +62,12 @@ namespace Gallery.Sources.Yandere
|
||||
return $"[{string.Join(',', array)}]";
|
||||
}
|
||||
|
||||
public void SetCookie()
|
||||
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