diff --git a/Pixiview.Android/Properties/AndroidManifest.xml b/Pixiview.Android/Properties/AndroidManifest.xml index 5a146a3..3847804 100644 --- a/Pixiview.Android/Properties/AndroidManifest.xml +++ b/Pixiview.Android/Properties/AndroidManifest.xml @@ -1,5 +1,5 @@  - + diff --git a/Pixiview.iOS.OpenExtension/Info.plist b/Pixiview.iOS.OpenExtension/Info.plist index 2f7adf2..0b533f1 100644 --- a/Pixiview.iOS.OpenExtension/Info.plist +++ b/Pixiview.iOS.OpenExtension/Info.plist @@ -31,6 +31,6 @@ CFBundleShortVersionString 1.0.525 CFBundleVersion - 18 + 20 diff --git a/Pixiview.iOS/Info.plist b/Pixiview.iOS/Info.plist index 42bfe5e..f9f33df 100644 --- a/Pixiview.iOS/Info.plist +++ b/Pixiview.iOS/Info.plist @@ -81,7 +81,7 @@ CFBundleShortVersionString 1.0.525 CFBundleVersion - 18 + 20 CFBundleDevelopmentRegion China diff --git a/Pixiview/App.cs b/Pixiview/App.cs index b2df18c..92cb409 100644 --- a/Pixiview/App.cs +++ b/Pixiview/App.cs @@ -36,6 +36,7 @@ namespace Pixiview Configs.SetCookie(Preferences.Get(Configs.CookieKey, null)); Configs.SetUserId(Preferences.Get(Configs.UserIdKey, null)); + Configs.DownloadIllustThreads = Preferences.Get(Configs.DownloadIllustThreadsKey, 1); Configs.IsOnR18 = Preferences.Get(Configs.IsOnR18Key, false); Configs.SyncFavType = (SyncType)Preferences.Get(Configs.SyncFavTypeKey, 0); var isProxied = Preferences.Get(Configs.IsProxiedKey, false); diff --git a/Pixiview/OptionPage.xaml b/Pixiview/OptionPage.xaml index 36c3c8b..972d1dd 100644 --- a/Pixiview/OptionPage.xaml +++ b/Pixiview/OptionPage.xaml @@ -20,6 +20,9 @@ IsToggled="{Binding IsOnR18, Mode=TwoWay}"/> + SetValue(VersionProperty, value); } + public static readonly BindableProperty DownloadIllustThreadsProperty = BindableProperty.Create( + nameof(DownloadIllustThreads), typeof(string), typeof(OptionPage)); public static readonly BindableProperty IsOnR18Property = BindableProperty.Create( nameof(IsOnR18), typeof(bool), typeof(OptionPage)); public static readonly BindableProperty SyncFavTypeProperty = BindableProperty.Create( @@ -32,6 +34,11 @@ namespace Pixiview public static readonly BindableProperty CookieProperty = BindableProperty.Create( nameof(Cookie), typeof(string), typeof(OptionPage)); + public string DownloadIllustThreads + { + get => (string)GetValue(DownloadIllustThreadsProperty); + set => SetValue(DownloadIllustThreadsProperty, value); + } public bool IsOnR18 { get => (bool)GetValue(IsOnR18Property); @@ -98,6 +105,7 @@ namespace Pixiview Version = $"{AppInfo.VersionString} ({AppInfo.BuildString})"; IsOnR18 = Configs.IsOnR18; SyncFavType = (int)Configs.SyncFavType; + DownloadIllustThreads = Configs.DownloadIllustThreads.ToString(); var proxy = Configs.Proxy; if (proxy != null) { @@ -141,6 +149,15 @@ namespace Pixiview #endif } + if (int.TryParse(DownloadIllustThreads, out int threads) && threads > 0 && threads <= 10 && threads != Configs.DownloadIllustThreads) + { + Preferences.Set(Configs.DownloadIllustThreadsKey, threads); + Configs.DownloadIllustThreads = threads; +#if LOG + App.DebugPrint($"will use {threads} threads to download illust"); +#endif + } + var proxy = Configs.Proxy; var h = Host?.Trim(); _ = int.TryParse(Port, out int pt); diff --git a/Pixiview/Resources/Languages/zh-CN.xml b/Pixiview/Resources/Languages/zh-CN.xml index 5b78952..25519b8 100644 --- a/Pixiview/Resources/Languages/zh-CN.xml +++ b/Pixiview/Resources/Languages/zh-CN.xml @@ -35,6 +35,7 @@ 不同步 提示同步 自动同步 + 下载线程数 已关注 推荐 按用户 diff --git a/Pixiview/Utils/HttpUtility.cs b/Pixiview/Utils/HttpUtility.cs index be5bf9d..88a118e 100644 --- a/Pixiview/Utils/HttpUtility.cs +++ b/Pixiview/Utils/HttpUtility.cs @@ -217,7 +217,7 @@ namespace Pixiview.Utils } var file = Path.Combine(directory, Path.GetFileName(url)); var proxy = Configs.Proxy; - var referer = new Uri(string.Format(Configs.UrlIllust, id)); + var referer = new Uri(string.Format(Configs.RefererIllust, id)); var handler = new HttpClientHandler { UseCookies = false @@ -251,7 +251,7 @@ namespace Pixiview.Utils } // segments - const int SIZE = 50000; + const int SIZE = 150000; var list = new List<(long from, long to)>(); for (var i = 0L; i < size; i += SIZE) { @@ -270,7 +270,7 @@ namespace Pixiview.Utils var data = new byte[size]; var task = new TaskCompletionSource(); - ParallelTask.Start($"download.async.{id}", 0, list.Count, 6, i => + ParallelTask.Start($"download.async.{id}", 0, list.Count, Configs.DownloadIllustThreads, i => { var (from, to) = list[i]; using (var request = new HttpRequestMessage(HttpMethod.Get, url)) @@ -279,9 +279,9 @@ namespace Pixiview.Utils headers.Add("Accept", Configs.AcceptPureImage); headers.Add("Accept-Language", Configs.AcceptLanguage); headers.Add("Accept-Encoding", "identity"); + headers.Referrer = referer; headers.IfRange = new RangeConditionHeaderValue(lastModified); headers.Range = new RangeHeaderValue(from, to); - headers.Referrer = referer; headers.Add("User-Agent", Configs.UserAgent); using (var response = client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead).Result) using (var ms = new MemoryStream(data, (int)from, (int)(to - from + 1))) diff --git a/Pixiview/Utils/Stores.cs b/Pixiview/Utils/Stores.cs index da6db8e..382166b 100644 --- a/Pixiview/Utils/Stores.cs +++ b/Pixiview/Utils/Stores.cs @@ -593,7 +593,7 @@ namespace Pixiview.Utils public static ImageSource LoadPreviewImage(string url, bool downloading, string id = null, bool force = false) { - if (downloading) + if (downloading && Configs.DownloadIllustThreads > 1) { return LoadImageAsync(url, id, PersonalFolder, previewFolder, force).Result; } @@ -746,6 +746,7 @@ namespace Pixiview.Utils public const string ProfileImageKey = "profile_img"; public const string CookieKey = "cookies"; public const string UserIdKey = "user_id"; + public const string DownloadIllustThreadsKey = "download_illust_threads"; public const string IsOnR18Key = "is_on_r18"; public const string SyncFavTypeKey = "sync_fav_type"; public const string IsProxiedKey = "is_proxied"; @@ -763,6 +764,7 @@ namespace Pixiview.Utils public const string RefererIllustRanking = "https://www.pixiv.net/ranking.php?{0}"; public const string RefererIllustUser = "https://www.pixiv.net/users/{0}/illustrations"; + public static int DownloadIllustThreads; public static bool IsOnR18; public static SyncType SyncFavType; public static WebProxy Proxy;