resolved bookmark issue, related illusts issue.

This commit is contained in:
Tsanie 2021-08-02 17:22:36 +08:00
parent 23202abd98
commit 98676ce8b2
11 changed files with 80 additions and 112 deletions

View File

@ -29,8 +29,8 @@
<string>com.apple.share-services</string> <string>com.apple.share-services</string>
</dict> </dict>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>1.2.727</string> <string>1.3.802</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>31</string> <string>32</string>
</dict> </dict>
</plist> </plist>

View File

@ -79,9 +79,9 @@
</dict> </dict>
</array> </array>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>1.2.727</string> <string>1.3.802</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>31</string> <string>32</string>
<key>CFBundleDevelopmentRegion</key> <key>CFBundleDevelopmentRegion</key>
<string>China</string> <string>China</string>
</dict> </dict>

View File

@ -90,7 +90,7 @@ namespace Pixiview.iOS.Renderers
if (Element is AdaptedPage page) if (Element is AdaptedPage page)
{ {
AppShell.Current?.SetStatusBarHeight( AppShell.Current?.SetStatusBarHeight(
NavigationController.NavigationBar.Frame.Height, NavigationController?.NavigationBar.Frame.Height ?? 0,
UIApplication.SharedApplication.StatusBarFrame.Height); UIApplication.SharedApplication.StatusBarFrame.Height);
var landscape = var landscape =
lastOrientation == UIDeviceOrientation.LandscapeLeft || lastOrientation == UIDeviceOrientation.LandscapeLeft ||

0
Pixiview/Illust/FavoritesPage.xaml.cs Executable file → Normal file
View File

11
Pixiview/Illust/IllustCollectionPage.cs Executable file → Normal file
View File

@ -630,7 +630,16 @@ namespace Pixiview.Illust
{ {
if (item.Image == null) if (item.Image == null)
{ {
var url = Configs.GetThumbnailUrl(item.ImageUrl); string url;
try
{
url = Configs.GetThumbnailUrl(item.ImageUrl);
}
catch (Exception ex)
{
App.DebugError("image.getthumbnail", $"{item.ImageUrl}, {ex}");
continue;
}
var image = Stores.LoadPreviewImage(url, false); var image = Stores.LoadPreviewImage(url, false);
if (image == null) if (image == null)
{ {

View File

@ -31,8 +31,8 @@
</u:FlowLayout> </u:FlowLayout>
</StackLayout> </StackLayout>
</ScrollView> </ScrollView>
<!--<u:BlurryPanel x:Name="panelBar" VerticalOptions="Start" <u:BlurryPanel x:Name="panelBar" VerticalOptions="Start"
HeightRequest="50"/>--> HeightRequest="60"/>
<SearchBar x:Name="searchBar" Placeholder="{r:Text Search}" <SearchBar x:Name="searchBar" Placeholder="{r:Text Search}"
HeightRequest="40" HeightRequest="40"
VerticalOptions="Start" VerticalOptions="Start"

View File

@ -43,8 +43,8 @@ namespace Pixiview.Illust
protected override void OnSizeAllocated(double width, double height) protected override void OnSizeAllocated(double width, double height)
{ {
base.OnSizeAllocated(width, height); base.OnSizeAllocated(width, height);
searchBar.Margin = PageTopMargin; searchBar.Margin = new Thickness(0, PageTopMargin.Top + 8, 0, 0);
//panelBar.Margin = PanelTopMargin; panelBar.Margin = PanelTopMargin;
} }
#if __IOS__ #if __IOS__
@ -52,8 +52,8 @@ namespace Pixiview.Illust
{ {
base.OnOrientationChanged(landscape); base.OnOrientationChanged(landscape);
AnimateToMargin(searchBar, PageTopMargin); AnimateToMargin(searchBar, new Thickness(0, PageTopMargin.Top + 8, 0, 0));
//AnimateToMargin(panelBar, PanelTopMargin); AnimateToMargin(panelBar, PanelTopMargin);
} }
#endif #endif
@ -99,7 +99,7 @@ namespace Pixiview.Illust
} }
} }
private const int searchBarHeight = 40; private const int searchBarHeight = 60;
private void ScrollView_Scrolled(object sender, ScrolledEventArgs e) private void ScrollView_Scrolled(object sender, ScrolledEventArgs e)
{ {
@ -115,9 +115,9 @@ namespace Pixiview.Illust
searchBar.Unfocus(); searchBar.Unfocus();
} }
ViewExtensions.CancelAnimations(searchBar); ViewExtensions.CancelAnimations(searchBar);
//ViewExtensions.CancelAnimations(panelBar); ViewExtensions.CancelAnimations(panelBar);
searchBar.TranslateTo(0, -searchBarHeight, easing: Easing.CubicIn); searchBar.TranslateTo(0, -searchBarHeight, easing: Easing.CubicIn);
//panelBar.TranslateTo(0, -searchBarHeight, easing: Easing.CubicIn); panelBar.TranslateTo(0, -searchBarHeight, easing: Easing.CubicIn);
} }
} }
else else
@ -127,9 +127,9 @@ namespace Pixiview.Illust
{ {
scrollDirection = ScrollDirection.Up; scrollDirection = ScrollDirection.Up;
ViewExtensions.CancelAnimations(searchBar); ViewExtensions.CancelAnimations(searchBar);
//ViewExtensions.CancelAnimations(panelBar); ViewExtensions.CancelAnimations(panelBar);
searchBar.TranslateTo(0, 0, easing: Easing.CubicOut); searchBar.TranslateTo(0, 0, easing: Easing.CubicOut);
//panelBar.TranslateTo(0, 0, easing: Easing.CubicOut); panelBar.TranslateTo(0, 0, easing: Easing.CubicOut);
} }
} }
lastScrollY = y; lastScrollY = y;

2
Pixiview/Illust/RelatedIllustsPage.xaml.cs Executable file → Normal file
View File

@ -46,7 +46,7 @@ namespace Pixiview.Illust
{ {
return null; return null;
} }
return data.body.illusts.Select(i => i.ConvertToItem()); return data.body.illusts.Where(i => i.url != null).Select(i => i.ConvertToItem());
} }
protected override IllustRecommendsData DoLoadIllustData(bool force) protected override IllustRecommendsData DoLoadIllustData(bool force)

26
Pixiview/Utils/HttpUtility.cs Executable file → Normal file
View File

@ -80,7 +80,7 @@ namespace Pixiview.Utils
} }
if (!response.IsSuccessStatusCode) if (!response.IsSuccessStatusCode)
{ {
App.DebugPrint($"http failed with code: {response.StatusCode}"); App.DebugPrint($"http failed with code: {(int)response.StatusCode} - {response.StatusCode}");
error = response.StatusCode.ToString(); error = response.StatusCode.ToString();
return default; return default;
} }
@ -188,7 +188,7 @@ namespace Pixiview.Utils
{ {
headers.Referrer = new Uri(Configs.Referer); headers.Referrer = new Uri(Configs.Referer);
headers.Add("User-Agent", Configs.UserAgent); headers.Add("User-Agent", Configs.UserAgent);
headers.Add("Accept", Configs.AcceptImage); headers.Add("Accept", Configs.AcceptPureImage);
}); });
if (response == null) if (response == null)
{ {
@ -345,19 +345,19 @@ namespace Pixiview.Utils
{ {
using (var request = new HttpRequestMessage(post == null ? HttpMethod.Get : HttpMethod.Post, uri.PathAndQuery) using (var request = new HttpRequestMessage(post == null ? HttpMethod.Get : HttpMethod.Post, uri.PathAndQuery)
{ {
Version = new Version(2, 0) Version = new Version(1, 1)
}) })
{ {
var headers = request.Headers; var headers = request.Headers;
headerAction(headers); headerAction(headers);
if (proxy == null) //if (proxy == null)
{ //{
var time = BitConverter.GetBytes(DateTime.UtcNow.Ticks); // var time = BitConverter.GetBytes(DateTime.UtcNow.Ticks);
headers.Add("X-Reverse-Ticks", Convert.ToBase64String(time)); // headers.Add("X-Reverse-Ticks", Convert.ToBase64String(time));
time = time.Concat(Encoding.UTF8.GetBytes("_reverse_for_pixiv_by_tsanie")).ToArray(); // time = time.Concat(Encoding.UTF8.GetBytes("_reverse_for_pixiv_by_tsanie")).ToArray();
var reverse = System.Security.Cryptography.SHA256.Create().ComputeHash(time); // var reverse = System.Security.Cryptography.SHA256.Create().ComputeHash(time);
headers.Add("X-Reverse", Convert.ToBase64String(reverse)); // headers.Add("X-Reverse", Convert.ToBase64String(reverse));
} //}
headers.Add("Accept-Language", Configs.AcceptLanguage); headers.Add("Accept-Language", Configs.AcceptLanguage);
//headers.Add("Accept-Encoding", Configs.AcceptEncoding); //headers.Add("Accept-Encoding", Configs.AcceptEncoding);
if (post != null) if (post != null)
@ -410,7 +410,7 @@ namespace Pixiview.Utils
{ {
using (var request = new HttpRequestMessage(HttpMethod.Head, uri.PathAndQuery) using (var request = new HttpRequestMessage(HttpMethod.Head, uri.PathAndQuery)
{ {
Version = new Version(2, 0) Version = new Version(1, 1)
}) })
{ {
var headers = request.Headers; var headers = request.Headers;
@ -434,7 +434,7 @@ namespace Pixiview.Utils
{ {
using (var request = new HttpRequestMessage(HttpMethod.Get, uri.PathAndQuery) using (var request = new HttpRequestMessage(HttpMethod.Get, uri.PathAndQuery)
{ {
Version = new Version(2, 0) Version = new Version(1, 1)
}) })
{ {
var headers = request.Headers; var headers = request.Headers;

11
Pixiview/Utils/IllustData.cs Executable file → Normal file
View File

@ -66,7 +66,7 @@ namespace Pixiview.Utils
{ {
Id = illustId ?? id, Id = illustId ?? id,
BookmarkId = bookmarkData?.id, BookmarkId = bookmarkData?.id,
Title = illustTitle, Title = illustTitle ?? title,
IllustType = (IllustType)illustType, IllustType = (IllustType)illustType,
Image = image, Image = image,
ImageUrl = urls?.x360 ?? url, ImageUrl = urls?.x360 ?? url,
@ -94,6 +94,13 @@ namespace Pixiview.Utils
public int partial; public int partial;
} }
public class IllustFavoriteData : IllustResponse<IllustFavoriteBody> { }
public class IllustFavoriteBody
{
public int total;
public Illust[] works;
}
public class IllustData : IllustResponse<IllustBody> { } public class IllustData : IllustResponse<IllustBody> { }
public class IllustBody public class IllustBody
{ {
@ -191,7 +198,7 @@ namespace Pixiview.Utils
public IllustItem CopyToItem(IllustItem item) public IllustItem CopyToItem(IllustItem item)
{ {
item.BookmarkId = bookmarkData?.id; item.BookmarkId = bookmarkData?.id;
item.Title = illustTitle; item.Title = illustTitle ?? title;
item.IllustType = (IllustType)illustType; item.IllustType = (IllustType)illustType;
item.ImageUrl = urls?.regular; item.ImageUrl = urls?.regular;
item.IsRestrict = xRestrict == 1; item.IsRestrict = xRestrict == 1;

110
Pixiview/Utils/Stores.cs Executable file → Normal file
View File

@ -498,89 +498,40 @@ namespace Pixiview.Utils
return result; return result;
} }
private static readonly Regex regexIllust = new Regex( //private static readonly Regex regexIllust = new Regex(
@"book_id\[\]"" value=""([0-9]+)"".*data-src=""([^""]+)"".*data-id=""([0-9]+)"".*" + // @"book_id\[\]"" value=""([0-9]+)"".*data-src=""([^""]+)"".*data-id=""([0-9]+)"".*" +
@"data-tags=""([^""]+)"".*data-user-id=""([0-9]+)"".*" + // @"data-tags=""([^""]+)"".*data-user-id=""([0-9]+)"".*" +
@"class=""title"" title=""([^""]+)"".*data-user_name=""([^""]+)"".*" + // @"class=""title"" title=""([^""]+)"".*data-user_name=""([^""]+)"".*" +
@"_bookmark-icon-inline""></i>([0-9]+)</a>", // @"_bookmark-icon-inline""></i>([0-9]+)</a>",
RegexOptions.Compiled); // RegexOptions.Compiled);
public static IllustItem[] LoadOnlineFavorites() public static IllustItem[] LoadOnlineFavorites()
{ {
var userId = Configs.UserId;
var list = new List<IllustItem>(); var list = new List<IllustItem>();
int p = 1; int offset = 0;
while (p > 0) while (offset >= 0)
{ {
var url = Configs.UrlFavoriteList; var result = HttpUtility.LoadObject<IllustFavoriteData>(
if (p > 1) null,
string.Format(Configs.UrlFavoriteList, userId, offset, 48),
string.Format(Configs.RefererFavorites, userId),
out _);
if (result == null || result.error)
{ {
url += $"&p={p}"; App.DebugPrint($"error when load favorites data: {result?.message}");
} }
var array = HttpUtility.LoadObject( else
null,
url,
null,
out _,
action: content =>
{
// page
p = -1;
var index = content.IndexOf("<span class=\"next\"><a href=\"?rest=show&amp;p=");
if (index > 0)
{
var page = content.Substring(index + 45, content.IndexOf('\"', index + 45) - index - 45);
if (int.TryParse(page, out var next))
{
p = next;
}
}
// list
index = content.IndexOf("<li class=\"image-item\">");
if (index < 0)
{
return null;
}
content = content.Substring(index + 23);
index = content.IndexOf("</li></ul><div class=\"clear\"></div>");
if (index < 0)
{
return null;
}
return content.Substring(0, index);
},
@return: content =>
{
if (content == null)
{
return null;
}
var lines = content.Split("</li><li class=\"image-item\">");
var illusts = new IllustItem[lines.Length];
for (var i = 0; i < illusts.Length; i++)
{
var line = lines[i];
var m = regexIllust.Match(line);
if (m.Success)
{
illusts[i] = new IllustItem
{
IsFavorite = true,
BookmarkId = m.Groups[1].Value,
ImageUrl = m.Groups[2].Value,
Id = m.Groups[3].Value,
Tags = m.Groups[4].Value.Split(' '),
UserId = m.Groups[5].Value,
Title = m.Groups[6].Value,
UserName = m.Groups[7].Value,
RatingCount = int.Parse(m.Groups[8].Value)
};
}
}
return illusts;
});
if (array != null && array.Length > 0)
{ {
list.AddRange(array); if (offset + 48 < result.body.total)
{
offset += 48;
}
else
{
offset = -1;
}
list.AddRange(result.body.works.Select(i => i.ConvertToItem()));
} }
} }
return list.Where(l => l != null).ToArray(); return list.Where(l => l != null).ToArray();
@ -763,6 +714,7 @@ namespace Pixiview.Utils
public const string RefererIllust = "https://www.pixiv.net/artworks/{0}"; public const string RefererIllust = "https://www.pixiv.net/artworks/{0}";
public const string RefererIllustRanking = "https://www.pixiv.net/ranking.php?{0}"; public const string RefererIllustRanking = "https://www.pixiv.net/ranking.php?{0}";
public const string RefererIllustUser = "https://www.pixiv.net/users/{0}/illustrations"; public const string RefererIllustUser = "https://www.pixiv.net/users/{0}/illustrations";
public const string RefererFavorites = "https://www.pixiv.net/users/{0}/bookmarks/artworks";
public static int DownloadIllustThreads; public static int DownloadIllustThreads;
public static bool IsOnR18; public static bool IsOnR18;
@ -856,20 +808,20 @@ namespace Pixiview.Utils
public static string UrlIllustUgoira => Prefix + "ajax/illust/{0}/ugoira_meta?lang=zh"; public static string UrlIllustUgoira => Prefix + "ajax/illust/{0}/ugoira_meta?lang=zh";
public static string UrlIllustRecommendsInit => Prefix + "ajax/illust/{0}/recommend/init?limit=18&lang=zh"; public static string UrlIllustRecommendsInit => Prefix + "ajax/illust/{0}/recommend/init?limit=18&lang=zh";
public static string UrlIllustRecommendsList => Prefix + "ajax/illust/recommend/illusts?{0}lang=zh"; public static string UrlIllustRecommendsList => Prefix + "ajax/illust/recommend/illusts?{0}lang=zh";
public static string UrlFavoriteList => Prefix + "bookmark.php?rest=show"; public static string UrlFavoriteList => Prefix + "ajax/user/{0}/illusts/bookmarks?tag=&offset={1}&limit={2}&rest=show&lang=zh";
public static string BookmarkAdd => Prefix + "ajax/illusts/bookmarks/add"; public static string BookmarkAdd => Prefix + "ajax/illusts/bookmarks/add";
public static string BookmarkRpc => Prefix + "rpc/index.php"; public static string BookmarkRpc => Prefix + "rpc/index.php";
public const string UserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36"; public const string UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36";
public const string AcceptImage = "image/png,image/svg+xml,image/*;q=0.8,video/*;q=0.8,*/*;q=0.5"; public const string AcceptImage = "image/png,image/svg+xml,image/*;q=0.8,video/*;q=0.8,*/*;q=0.5";
public const string AcceptPureImage = "image/*,*/*;q=0.8"; public const string AcceptPureImage = "image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8";
public const string AcceptJson = "application/json"; public const string AcceptJson = "application/json";
public const string AcceptUrlEncoded = "application/x-www-form-urlencoded"; public const string AcceptUrlEncoded = "application/x-www-form-urlencoded";
//public const string AcceptEncoding = "gzip, deflate"; //public const string AcceptEncoding = "gzip, deflate";
public const string AcceptLanguage = "zh-cn"; public const string AcceptLanguage = "zh-cn";
private const string URL_PREVIEW = "https://i.pximg.net/c/360x360_70"; private const string URL_PREVIEW = "https://i.pximg.net"; // /c/360x360_70
public static string GetThumbnailUrl(string url) public static string GetThumbnailUrl(string url)
{ {