feature: view related illusts
This commit is contained in:
@@ -30,6 +30,7 @@ namespace Pixiview.Utils
|
||||
private const string preloadsFolder = "preloads";
|
||||
private const string thumbFolder = "img-thumb";
|
||||
private const string userFolder = "user-profile";
|
||||
private const string recommendsFolder = "recommends";
|
||||
|
||||
private static readonly object sync = new object();
|
||||
|
||||
@@ -212,7 +213,7 @@ namespace Pixiview.Utils
|
||||
|
||||
public static IllustRankingData LoadIllustRankingData(string mode, string date, int page, bool force = false)
|
||||
{
|
||||
var file = Path.Combine(CacheFolder, $"{mode}_{date}_{page}.json");
|
||||
var file = Path.Combine(CacheFolder, mode, $"{date}_{page}.json");
|
||||
string query = $"mode={mode}";
|
||||
if (mode != "male" && mode != "male_r18")
|
||||
{
|
||||
@@ -234,7 +235,7 @@ namespace Pixiview.Utils
|
||||
referer,
|
||||
namehandler: rst =>
|
||||
{
|
||||
return Path.Combine(CacheFolder, $"{mode}_{rst.date}_{page}.json");
|
||||
return Path.Combine(CacheFolder, mode, $"{rst.date}_{page}.json");
|
||||
},
|
||||
header: headers =>
|
||||
{
|
||||
@@ -248,6 +249,35 @@ namespace Pixiview.Utils
|
||||
return result;
|
||||
}
|
||||
|
||||
public static IllustRecommendsData LoadIllustRecommendsInitData(string id, bool force = false)
|
||||
{
|
||||
var file = Path.Combine(CacheFolder, recommendsFolder, $"{id}.json");
|
||||
var result = HttpUtility.LoadObject<IllustRecommendsData>(
|
||||
file,
|
||||
string.Format(Configs.UrlIllustRecommendsInit, id),
|
||||
string.Format(Configs.RefererIllust, id),
|
||||
force: force);
|
||||
if (result == null || result.error)
|
||||
{
|
||||
App.DebugPrint($"error when load recommends init data: {result?.message}, force({force})");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static IllustRecommendsData LoadIllustRecommendsListData(string id, string[] ids)
|
||||
{
|
||||
var ps = string.Concat(ids.Select(i => $"illust_ids%5B%5D={i}&"));
|
||||
var result = HttpUtility.LoadObject<IllustRecommendsData>(
|
||||
null,
|
||||
string.Format(Configs.UrlIllustRecommendsList, ps),
|
||||
string.Format(Configs.RefererIllust, id));
|
||||
if (result == null || result.error)
|
||||
{
|
||||
App.DebugPrint($"error when load recommends list data: {result?.message}");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static IllustPreloadBody LoadIllustPreloadData(string id, bool force = false)
|
||||
{
|
||||
var file = Path.Combine(CacheFolder, preloadsFolder, $"{id}.json");
|
||||
@@ -431,6 +461,8 @@ namespace Pixiview.Utils
|
||||
public static string UrlIllustUserArtworks => Prefix + "ajax/user/{0}/profile/illusts?{1}work_category=illustManga&is_first_page={2}&lang=zh";
|
||||
public static string UrlIllustPage => Prefix + "ajax/illust/{0}/pages?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 UrlIllustRecommendsList => Prefix + "ajax/illust/recommend/illusts?{0}lang=zh";
|
||||
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 AcceptImage = "image/png,image/svg+xml,image/*;q=0.8,video/*;q=0.8,*/*;q=0.5";
|
||||
public const string AcceptJson = "application/json";
|
||||
|
||||
Reference in New Issue
Block a user