Compare commits
No commits in common. "3c4867a276545519380477824c5fdc63792ee08b" and "e49db9a4cb57f5012cb7e6bc3b7d13a6fe36681b" have entirely different histories.
3c4867a276
...
e49db9a4cb
@ -27,14 +27,17 @@ public class UpdateMetadata : Job
|
||||
Manga? possibleUpdatedManga = mangaConnector.GetMangaFromId(manga.publicationId);
|
||||
if (possibleUpdatedManga is { } updatedManga)
|
||||
{
|
||||
if (updatedManga.Equals(this.manga)) //Check if anything changed
|
||||
{
|
||||
this.progressToken.Complete();
|
||||
if(updatedManga.Equals(this.manga))//Check if anything changed
|
||||
return Array.Empty<Job>();
|
||||
}
|
||||
|
||||
this.manga.UpdateMetadata(updatedManga);
|
||||
this.manga.SaveSeriesInfoJson(settings.downloadLocation, true);
|
||||
|
||||
/* //TODO remove if this fixes #90
|
||||
if (parentJobId is not null && jobBoss.GetJobById(this.parentJobId) is DownloadNewChapters dncJob)
|
||||
{
|
||||
dncJob.manga = updatedManga;
|
||||
}*/
|
||||
this.progressToken.Complete();
|
||||
}
|
||||
else
|
||||
|
@ -62,17 +62,8 @@ internal class ChromiumDownloadClient : DownloadClient
|
||||
{
|
||||
IPage page = this.browser.NewPageAsync().Result;
|
||||
page.DefaultTimeout = 10000;
|
||||
IResponse response;
|
||||
try
|
||||
{
|
||||
response = page.GoToAsync(url, WaitUntilNavigation.Networkidle0).Result;
|
||||
Log("Page loaded.");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log($"Could not load Page:\n{e.Message}");
|
||||
return new RequestResult(HttpStatusCode.InternalServerError, null, Stream.Null);
|
||||
}
|
||||
IResponse response = page.GoToAsync(url, WaitUntilNavigation.Networkidle0).Result;
|
||||
Log("Page loaded.");
|
||||
|
||||
Stream stream = Stream.Null;
|
||||
HtmlDocument? document = null;
|
||||
|
@ -15,14 +15,6 @@ internal abstract class DownloadClient : GlobalBase
|
||||
foreach (KeyValuePair<byte, int> limit in rateLimitRequestsPerMinute)
|
||||
_rateLimit.Add(limit.Key, TimeSpan.FromMinutes(1).Divide(limit.Value));
|
||||
}
|
||||
|
||||
internal void SetCustomRequestLimit(byte requestType, int limit)
|
||||
{
|
||||
if (_rateLimit.ContainsKey(requestType))
|
||||
_rateLimit[requestType] = TimeSpan.FromMinutes(1).Divide(limit);
|
||||
else
|
||||
_rateLimit.Add(requestType, TimeSpan.FromMinutes(1).Divide(limit));
|
||||
}
|
||||
|
||||
public RequestResult MakeRequest(string url, byte requestType, string? referrer = null, string? clickButton = null)
|
||||
{
|
||||
|
@ -8,16 +8,20 @@ internal class HttpDownloadClient : DownloadClient
|
||||
{
|
||||
private static readonly HttpClient Client = new()
|
||||
{
|
||||
Timeout = TimeSpan.FromSeconds(10)
|
||||
Timeout = TimeSpan.FromSeconds(60),
|
||||
DefaultRequestHeaders =
|
||||
{
|
||||
UserAgent =
|
||||
{
|
||||
new ProductInfoHeaderValue("Tranga", "0.1")
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
public HttpDownloadClient(GlobalBase clone, Dictionary<byte, int> rateLimitRequestsPerMinute) : base(clone, rateLimitRequestsPerMinute)
|
||||
{
|
||||
if (settings.customUserAgent is null || settings.customUserAgent.Length < 1)
|
||||
Client.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue("Tranga", "1.0"));
|
||||
else
|
||||
Client.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", settings.customUserAgent);
|
||||
|
||||
}
|
||||
|
||||
protected override RequestResult MakeRequestInternal(string url, string? referrer = null, string? clickButton = null)
|
||||
|
@ -178,7 +178,7 @@ public abstract class MangaConnector : GlobalBase
|
||||
string fileInCache = Path.Join(settings.coverImageCache, manga.coverFileNameInCache);
|
||||
if (!File.Exists(fileInCache))
|
||||
{
|
||||
Log($"Cloning cover failed: File missing {fileInCache}.");
|
||||
Log($"Cloníng cover failed: File missing {fileInCache}.");
|
||||
if (retries > 0 && manga.coverUrl is not null)
|
||||
{
|
||||
Log($"Trying {retries} more times");
|
||||
|
@ -384,29 +384,6 @@ public class Server : GlobalBase
|
||||
settings.UpdateWorkingDirectory(workingDirectory);
|
||||
SendResponse(HttpStatusCode.Accepted, response);
|
||||
break;*/
|
||||
case "Settings/customUserAgent":
|
||||
if(!requestVariables.TryGetValue("userAgent", out string? customUserAgent))
|
||||
{
|
||||
SendResponse(HttpStatusCode.BadRequest, response);
|
||||
break;
|
||||
}
|
||||
settings.customUserAgent = customUserAgent;
|
||||
SendResponse(HttpStatusCode.Accepted, response);
|
||||
break;
|
||||
case "Settings/customRequestLimit":
|
||||
if (!requestVariables.TryGetValue("requestType", out string? requestTypeStr) ||
|
||||
!requestVariables.TryGetValue("requestsPerMinute", out string? requestsPerMinuteStr) ||
|
||||
!requestVariables.TryGetValue("connector", out connectorName) ||
|
||||
!byte.TryParse(requestTypeStr, out byte requestType) ||
|
||||
!int.TryParse(requestsPerMinuteStr, out int requestsPerMinute) ||
|
||||
!_parent.TryGetConnector(connectorName, out connector))
|
||||
{
|
||||
SendResponse(HttpStatusCode.BadRequest, response);
|
||||
break;
|
||||
}
|
||||
connector!.downloadClient.SetCustomRequestLimit(requestType, requestsPerMinute);
|
||||
SendResponse(HttpStatusCode.Accepted, response);
|
||||
break;
|
||||
case "NotificationConnectors/Update":
|
||||
if (!requestVariables.TryGetValue("notificationConnector", out string? notificationConnectorStr) ||
|
||||
!Enum.TryParse(notificationConnectorStr, out NotificationConnector.NotificationConnectorType notificationConnectorType))
|
||||
|
@ -12,7 +12,6 @@ public class TrangaSettings
|
||||
public string workingDirectory { get; private set; }
|
||||
public int apiPortNumber { get; init; }
|
||||
public string styleSheet { get; private set; }
|
||||
public string? customUserAgent { get; set; } = null;
|
||||
[JsonIgnore] public string settingsFilePath => Path.Join(workingDirectory, "settings.json");
|
||||
[JsonIgnore] public string libraryConnectorsFilePath => Path.Join(workingDirectory, "libraryConnectors.json");
|
||||
[JsonIgnore] public string notificationConnectorsFilePath => Path.Join(workingDirectory, "notificationConnectors.json");
|
||||
|
Loading…
Reference in New Issue
Block a user