resolved bookmark issue, related illusts issue.
This commit is contained in:
parent
23202abd98
commit
98676ce8b2
Pixiview.iOS.OpenExtension
Pixiview.iOS
Pixiview
@ -29,8 +29,8 @@
|
||||
<string>com.apple.share-services</string>
|
||||
</dict>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.2.727</string>
|
||||
<string>1.3.802</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>31</string>
|
||||
<string>32</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
@ -79,9 +79,9 @@
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.2.727</string>
|
||||
<string>1.3.802</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>31</string>
|
||||
<string>32</string>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>China</string>
|
||||
</dict>
|
||||
|
@ -90,7 +90,7 @@ namespace Pixiview.iOS.Renderers
|
||||
if (Element is AdaptedPage page)
|
||||
{
|
||||
AppShell.Current?.SetStatusBarHeight(
|
||||
NavigationController.NavigationBar.Frame.Height,
|
||||
NavigationController?.NavigationBar.Frame.Height ?? 0,
|
||||
UIApplication.SharedApplication.StatusBarFrame.Height);
|
||||
var landscape =
|
||||
lastOrientation == UIDeviceOrientation.LandscapeLeft ||
|
||||
|
0
Pixiview/Illust/FavoritesPage.xaml.cs
Executable file → Normal file
0
Pixiview/Illust/FavoritesPage.xaml.cs
Executable file → Normal file
11
Pixiview/Illust/IllustCollectionPage.cs
Executable file → Normal file
11
Pixiview/Illust/IllustCollectionPage.cs
Executable file → Normal file
@ -630,7 +630,16 @@ namespace Pixiview.Illust
|
||||
{
|
||||
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);
|
||||
if (image == null)
|
||||
{
|
||||
|
@ -31,8 +31,8 @@
|
||||
</u:FlowLayout>
|
||||
</StackLayout>
|
||||
</ScrollView>
|
||||
<!--<u:BlurryPanel x:Name="panelBar" VerticalOptions="Start"
|
||||
HeightRequest="50"/>-->
|
||||
<u:BlurryPanel x:Name="panelBar" VerticalOptions="Start"
|
||||
HeightRequest="60"/>
|
||||
<SearchBar x:Name="searchBar" Placeholder="{r:Text Search}"
|
||||
HeightRequest="40"
|
||||
VerticalOptions="Start"
|
||||
|
@ -43,8 +43,8 @@ namespace Pixiview.Illust
|
||||
protected override void OnSizeAllocated(double width, double height)
|
||||
{
|
||||
base.OnSizeAllocated(width, height);
|
||||
searchBar.Margin = PageTopMargin;
|
||||
//panelBar.Margin = PanelTopMargin;
|
||||
searchBar.Margin = new Thickness(0, PageTopMargin.Top + 8, 0, 0);
|
||||
panelBar.Margin = PanelTopMargin;
|
||||
}
|
||||
|
||||
#if __IOS__
|
||||
@ -52,8 +52,8 @@ namespace Pixiview.Illust
|
||||
{
|
||||
base.OnOrientationChanged(landscape);
|
||||
|
||||
AnimateToMargin(searchBar, PageTopMargin);
|
||||
//AnimateToMargin(panelBar, PanelTopMargin);
|
||||
AnimateToMargin(searchBar, new Thickness(0, PageTopMargin.Top + 8, 0, 0));
|
||||
AnimateToMargin(panelBar, PanelTopMargin);
|
||||
}
|
||||
#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)
|
||||
{
|
||||
@ -115,9 +115,9 @@ namespace Pixiview.Illust
|
||||
searchBar.Unfocus();
|
||||
}
|
||||
ViewExtensions.CancelAnimations(searchBar);
|
||||
//ViewExtensions.CancelAnimations(panelBar);
|
||||
ViewExtensions.CancelAnimations(panelBar);
|
||||
searchBar.TranslateTo(0, -searchBarHeight, easing: Easing.CubicIn);
|
||||
//panelBar.TranslateTo(0, -searchBarHeight, easing: Easing.CubicIn);
|
||||
panelBar.TranslateTo(0, -searchBarHeight, easing: Easing.CubicIn);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -127,9 +127,9 @@ namespace Pixiview.Illust
|
||||
{
|
||||
scrollDirection = ScrollDirection.Up;
|
||||
ViewExtensions.CancelAnimations(searchBar);
|
||||
//ViewExtensions.CancelAnimations(panelBar);
|
||||
ViewExtensions.CancelAnimations(panelBar);
|
||||
searchBar.TranslateTo(0, 0, easing: Easing.CubicOut);
|
||||
//panelBar.TranslateTo(0, 0, easing: Easing.CubicOut);
|
||||
panelBar.TranslateTo(0, 0, easing: Easing.CubicOut);
|
||||
}
|
||||
}
|
||||
lastScrollY = y;
|
||||
|
2
Pixiview/Illust/RelatedIllustsPage.xaml.cs
Executable file → Normal file
2
Pixiview/Illust/RelatedIllustsPage.xaml.cs
Executable file → Normal file
@ -46,7 +46,7 @@ namespace Pixiview.Illust
|
||||
{
|
||||
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)
|
||||
|
26
Pixiview/Utils/HttpUtility.cs
Executable file → Normal file
26
Pixiview/Utils/HttpUtility.cs
Executable file → Normal file
@ -80,7 +80,7 @@ namespace Pixiview.Utils
|
||||
}
|
||||
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();
|
||||
return default;
|
||||
}
|
||||
@ -188,7 +188,7 @@ namespace Pixiview.Utils
|
||||
{
|
||||
headers.Referrer = new Uri(Configs.Referer);
|
||||
headers.Add("User-Agent", Configs.UserAgent);
|
||||
headers.Add("Accept", Configs.AcceptImage);
|
||||
headers.Add("Accept", Configs.AcceptPureImage);
|
||||
});
|
||||
if (response == null)
|
||||
{
|
||||
@ -345,19 +345,19 @@ namespace Pixiview.Utils
|
||||
{
|
||||
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;
|
||||
headerAction(headers);
|
||||
if (proxy == null)
|
||||
{
|
||||
var time = BitConverter.GetBytes(DateTime.UtcNow.Ticks);
|
||||
headers.Add("X-Reverse-Ticks", Convert.ToBase64String(time));
|
||||
time = time.Concat(Encoding.UTF8.GetBytes("_reverse_for_pixiv_by_tsanie")).ToArray();
|
||||
var reverse = System.Security.Cryptography.SHA256.Create().ComputeHash(time);
|
||||
headers.Add("X-Reverse", Convert.ToBase64String(reverse));
|
||||
}
|
||||
//if (proxy == null)
|
||||
//{
|
||||
// var time = BitConverter.GetBytes(DateTime.UtcNow.Ticks);
|
||||
// headers.Add("X-Reverse-Ticks", Convert.ToBase64String(time));
|
||||
// time = time.Concat(Encoding.UTF8.GetBytes("_reverse_for_pixiv_by_tsanie")).ToArray();
|
||||
// var reverse = System.Security.Cryptography.SHA256.Create().ComputeHash(time);
|
||||
// headers.Add("X-Reverse", Convert.ToBase64String(reverse));
|
||||
//}
|
||||
headers.Add("Accept-Language", Configs.AcceptLanguage);
|
||||
//headers.Add("Accept-Encoding", Configs.AcceptEncoding);
|
||||
if (post != null)
|
||||
@ -410,7 +410,7 @@ namespace Pixiview.Utils
|
||||
{
|
||||
using (var request = new HttpRequestMessage(HttpMethod.Head, uri.PathAndQuery)
|
||||
{
|
||||
Version = new Version(2, 0)
|
||||
Version = new Version(1, 1)
|
||||
})
|
||||
{
|
||||
var headers = request.Headers;
|
||||
@ -434,7 +434,7 @@ namespace Pixiview.Utils
|
||||
{
|
||||
using (var request = new HttpRequestMessage(HttpMethod.Get, uri.PathAndQuery)
|
||||
{
|
||||
Version = new Version(2, 0)
|
||||
Version = new Version(1, 1)
|
||||
})
|
||||
{
|
||||
var headers = request.Headers;
|
||||
|
11
Pixiview/Utils/IllustData.cs
Executable file → Normal file
11
Pixiview/Utils/IllustData.cs
Executable file → Normal file
@ -66,7 +66,7 @@ namespace Pixiview.Utils
|
||||
{
|
||||
Id = illustId ?? id,
|
||||
BookmarkId = bookmarkData?.id,
|
||||
Title = illustTitle,
|
||||
Title = illustTitle ?? title,
|
||||
IllustType = (IllustType)illustType,
|
||||
Image = image,
|
||||
ImageUrl = urls?.x360 ?? url,
|
||||
@ -94,6 +94,13 @@ namespace Pixiview.Utils
|
||||
public int partial;
|
||||
}
|
||||
|
||||
public class IllustFavoriteData : IllustResponse<IllustFavoriteBody> { }
|
||||
public class IllustFavoriteBody
|
||||
{
|
||||
public int total;
|
||||
public Illust[] works;
|
||||
}
|
||||
|
||||
public class IllustData : IllustResponse<IllustBody> { }
|
||||
public class IllustBody
|
||||
{
|
||||
@ -191,7 +198,7 @@ namespace Pixiview.Utils
|
||||
public IllustItem CopyToItem(IllustItem item)
|
||||
{
|
||||
item.BookmarkId = bookmarkData?.id;
|
||||
item.Title = illustTitle;
|
||||
item.Title = illustTitle ?? title;
|
||||
item.IllustType = (IllustType)illustType;
|
||||
item.ImageUrl = urls?.regular;
|
||||
item.IsRestrict = xRestrict == 1;
|
||||
|
110
Pixiview/Utils/Stores.cs
Executable file → Normal file
110
Pixiview/Utils/Stores.cs
Executable file → Normal file
@ -498,89 +498,40 @@ namespace Pixiview.Utils
|
||||
return result;
|
||||
}
|
||||
|
||||
private static readonly Regex regexIllust = new Regex(
|
||||
@"book_id\[\]"" value=""([0-9]+)"".*data-src=""([^""]+)"".*data-id=""([0-9]+)"".*" +
|
||||
@"data-tags=""([^""]+)"".*data-user-id=""([0-9]+)"".*" +
|
||||
@"class=""title"" title=""([^""]+)"".*data-user_name=""([^""]+)"".*" +
|
||||
@"_bookmark-icon-inline""></i>([0-9]+)</a>",
|
||||
RegexOptions.Compiled);
|
||||
//private static readonly Regex regexIllust = new Regex(
|
||||
// @"book_id\[\]"" value=""([0-9]+)"".*data-src=""([^""]+)"".*data-id=""([0-9]+)"".*" +
|
||||
// @"data-tags=""([^""]+)"".*data-user-id=""([0-9]+)"".*" +
|
||||
// @"class=""title"" title=""([^""]+)"".*data-user_name=""([^""]+)"".*" +
|
||||
// @"_bookmark-icon-inline""></i>([0-9]+)</a>",
|
||||
// RegexOptions.Compiled);
|
||||
|
||||
public static IllustItem[] LoadOnlineFavorites()
|
||||
{
|
||||
var userId = Configs.UserId;
|
||||
var list = new List<IllustItem>();
|
||||
int p = 1;
|
||||
while (p > 0)
|
||||
int offset = 0;
|
||||
while (offset >= 0)
|
||||
{
|
||||
var url = Configs.UrlFavoriteList;
|
||||
if (p > 1)
|
||||
var result = HttpUtility.LoadObject<IllustFavoriteData>(
|
||||
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(
|
||||
null,
|
||||
url,
|
||||
null,
|
||||
out _,
|
||||
action: content =>
|
||||
{
|
||||
// page
|
||||
p = -1;
|
||||
var index = content.IndexOf("<span class=\"next\"><a href=\"?rest=show&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)
|
||||
else
|
||||
{
|
||||
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();
|
||||
@ -763,6 +714,7 @@ namespace Pixiview.Utils
|
||||
public const string RefererIllust = "https://www.pixiv.net/artworks/{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 RefererFavorites = "https://www.pixiv.net/users/{0}/bookmarks/artworks";
|
||||
|
||||
public static int DownloadIllustThreads;
|
||||
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 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 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 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 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 AcceptUrlEncoded = "application/x-www-form-urlencoded";
|
||||
//public const string AcceptEncoding = "gzip, deflate";
|
||||
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)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user