mirror of
https://github.com/EpinelPS/EpinelPS.git
synced 2025-12-15 16:34:40 +01:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
618619e36d |
@@ -169,7 +169,7 @@ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
|||||||
}
|
}
|
||||||
public static string GetCachePathForPath(string path)
|
public static string GetCachePathForPath(string path)
|
||||||
{
|
{
|
||||||
return AppDomain.CurrentDomain.BaseDirectory + "cache" + path;
|
return AppDomain.CurrentDomain.BaseDirectory + "cache/" + path;
|
||||||
}
|
}
|
||||||
private static async Task HandleAsset(IHttpContext ctx)
|
private static async Task HandleAsset(IHttpContext ctx)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -38,7 +38,19 @@ namespace nksrv.StaticInfo
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Fields
|
// Fields
|
||||||
public static StaticDataParser Instance;
|
private static StaticDataParser? _instance;
|
||||||
|
public static StaticDataParser Instance
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_instance == null)
|
||||||
|
{
|
||||||
|
_instance = BuildAsync().Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
return _instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
private ZipFile MainZip;
|
private ZipFile MainZip;
|
||||||
private MemoryStream ZipStream;
|
private MemoryStream ZipStream;
|
||||||
private JArray questDataRecords;
|
private JArray questDataRecords;
|
||||||
@@ -50,15 +62,16 @@ namespace nksrv.StaticInfo
|
|||||||
private JArray characterTable;
|
private JArray characterTable;
|
||||||
private JArray tutorialTable;
|
private JArray tutorialTable;
|
||||||
|
|
||||||
static StaticDataParser()
|
static async Task<StaticDataParser> BuildAsync()
|
||||||
{
|
{
|
||||||
Logger.Info("Loading static data");
|
Logger.Info("Loading static data");
|
||||||
Load().Wait();
|
await Load();
|
||||||
if (Instance == null) throw new Exception("static data load fail");
|
|
||||||
|
|
||||||
Logger.Info("Parsing static data");
|
Logger.Info("Parsing static data");
|
||||||
Instance.Parse().Wait();
|
await Instance.Parse();
|
||||||
|
return Instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public StaticDataParser(string filePath)
|
public StaticDataParser(string filePath)
|
||||||
{
|
{
|
||||||
if (!File.Exists(filePath)) throw new ArgumentException("Static data file must exist", nameof(filePath));
|
if (!File.Exists(filePath)) throw new ArgumentException("Static data file must exist", nameof(filePath));
|
||||||
@@ -198,7 +211,7 @@ namespace nksrv.StaticInfo
|
|||||||
var targetFile = await AssetDownloadUtil.DownloadOrGetFileAsync(StaticDataUrl, CancellationToken.None);
|
var targetFile = await AssetDownloadUtil.DownloadOrGetFileAsync(StaticDataUrl, CancellationToken.None);
|
||||||
if (targetFile == null) throw new Exception("static data download fail");
|
if (targetFile == null) throw new Exception("static data download fail");
|
||||||
|
|
||||||
Instance = new(targetFile);
|
_instance = new(targetFile);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ namespace nksrv.Utils
|
|||||||
public static readonly HttpClient AssetDownloader = new(new HttpClientHandler() { AutomaticDecompression = DecompressionMethods.All });
|
public static readonly HttpClient AssetDownloader = new(new HttpClientHandler() { AutomaticDecompression = DecompressionMethods.All });
|
||||||
public static async Task<string?> DownloadOrGetFileAsync(string url, CancellationToken cancellationToken)
|
public static async Task<string?> DownloadOrGetFileAsync(string url, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var rawUrl = url.Replace("https://cloud.nikke-kr.com", "");
|
var rawUrl = url.Replace("https://cloud.nikke-kr.com/", "");
|
||||||
string targetFile = Program.GetCachePathForPath(rawUrl);
|
string targetFile = Program.GetCachePathForPath(rawUrl);
|
||||||
var targetDir = Path.GetDirectoryName(targetFile);
|
var targetDir = Path.GetDirectoryName(targetFile);
|
||||||
if (targetDir == null)
|
if (targetDir == null)
|
||||||
@@ -27,12 +27,9 @@ namespace nksrv.Utils
|
|||||||
{
|
{
|
||||||
Logger.Info("Download " + targetFile);
|
Logger.Info("Download " + targetFile);
|
||||||
|
|
||||||
// TODO: Ip might change for cloud.nikke-kr.com
|
|
||||||
string @base = rawUrl.StartsWith("/prdenv") ? "prdenv" : "media";
|
|
||||||
if (rawUrl.StartsWith("/PC"))
|
|
||||||
@base = "PC";
|
|
||||||
|
|
||||||
var requestUri = new Uri("https://35.190.17.65/" + @base + rawUrl);
|
|
||||||
|
var requestUri = new Uri("https://35.190.17.65/" + rawUrl);
|
||||||
using var request = new HttpRequestMessage(HttpMethod.Get, requestUri);
|
using var request = new HttpRequestMessage(HttpMethod.Get, requestUri);
|
||||||
request.Headers.TryAddWithoutValidation("host", "cloud.nikke-kr.com");
|
request.Headers.TryAddWithoutValidation("host", "cloud.nikke-kr.com");
|
||||||
using var response = await AssetDownloader.SendAsync(request);
|
using var response = await AssetDownloader.SendAsync(request);
|
||||||
|
|||||||
Reference in New Issue
Block a user