housekeeping
This commit is contained in:
parent
d89af7cc5b
commit
7972f07801
@ -101,7 +101,7 @@ public class JobBoss : GlobalBase
|
|||||||
Chapter? chapter = null)
|
Chapter? chapter = null)
|
||||||
{
|
{
|
||||||
if (chapter is not null)
|
if (chapter is not null)
|
||||||
return GetJobsLike(mangaConnector?.name, chapter.Value.parentManga.internalId, chapter?.chapterNumber);
|
return GetJobsLike(mangaConnector?.name, chapter.Value.parentManga.internalId, chapter.Value.chapterNumber);
|
||||||
else
|
else
|
||||||
return GetJobsLike(mangaConnector?.name, publication?.internalId);
|
return GetJobsLike(mangaConnector?.name, publication?.internalId);
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ public class ProgressToken
|
|||||||
private float GetProgress()
|
private float GetProgress()
|
||||||
{
|
{
|
||||||
if(increments > 0 && incrementsCompleted > 0)
|
if(increments > 0 && incrementsCompleted > 0)
|
||||||
return (float)incrementsCompleted / (float)increments;
|
return incrementsCompleted / (float)increments;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ namespace Tranga.LibraryConnectors;
|
|||||||
|
|
||||||
public class LibraryManagerJsonConverter : JsonConverter
|
public class LibraryManagerJsonConverter : JsonConverter
|
||||||
{
|
{
|
||||||
private GlobalBase _clone;
|
private readonly GlobalBase _clone;
|
||||||
|
|
||||||
internal LibraryManagerJsonConverter(GlobalBase clone)
|
internal LibraryManagerJsonConverter(GlobalBase clone)
|
||||||
{
|
{
|
||||||
|
@ -60,7 +60,7 @@ internal class ChromiumDownloadClient : DownloadClient
|
|||||||
|
|
||||||
protected override RequestResult MakeRequestInternal(string url, string? referrer = null)
|
protected override RequestResult MakeRequestInternal(string url, string? referrer = null)
|
||||||
{
|
{
|
||||||
IPage page = this.browser!.NewPageAsync().Result;
|
IPage page = this.browser.NewPageAsync().Result;
|
||||||
page.DefaultTimeout = 10000;
|
page.DefaultTimeout = 10000;
|
||||||
IResponse response = page.GoToAsync(url, WaitUntilNavigation.DOMContentLoaded).Result;
|
IResponse response = page.GoToAsync(url, WaitUntilNavigation.DOMContentLoaded).Result;
|
||||||
Log("Page loaded.");
|
Log("Page loaded.");
|
||||||
|
@ -6,12 +6,12 @@ namespace Tranga.MangaConnectors;
|
|||||||
public class MangaConnectorJsonConverter : JsonConverter
|
public class MangaConnectorJsonConverter : JsonConverter
|
||||||
{
|
{
|
||||||
private GlobalBase _clone;
|
private GlobalBase _clone;
|
||||||
private HashSet<MangaConnector> connectors;
|
private readonly HashSet<MangaConnector> _connectors;
|
||||||
|
|
||||||
internal MangaConnectorJsonConverter(GlobalBase clone, HashSet<MangaConnector> connectors)
|
internal MangaConnectorJsonConverter(GlobalBase clone, HashSet<MangaConnector> connectors)
|
||||||
{
|
{
|
||||||
this._clone = clone;
|
this._clone = clone;
|
||||||
this.connectors = connectors;
|
this._connectors = connectors;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool CanConvert(Type objectType)
|
public override bool CanConvert(Type objectType)
|
||||||
@ -25,15 +25,15 @@ public class MangaConnectorJsonConverter : JsonConverter
|
|||||||
switch (jo.GetValue("name")!.Value<string>()!)
|
switch (jo.GetValue("name")!.Value<string>()!)
|
||||||
{
|
{
|
||||||
case "MangaDex":
|
case "MangaDex":
|
||||||
return this.connectors.First(c => c is MangaDex);
|
return this._connectors.First(c => c is MangaDex);
|
||||||
case "Manganato":
|
case "Manganato":
|
||||||
return this.connectors.First(c => c is Manganato);
|
return this._connectors.First(c => c is Manganato);
|
||||||
case "MangaKatana":
|
case "MangaKatana":
|
||||||
return this.connectors.First(c => c is MangaKatana);
|
return this._connectors.First(c => c is MangaKatana);
|
||||||
case "Mangasee":
|
case "Mangasee":
|
||||||
return this.connectors.First(c => c is Mangasee);
|
return this._connectors.First(c => c is Mangasee);
|
||||||
case "Mangaworld":
|
case "Mangaworld":
|
||||||
return this.connectors.First(c => c is Mangaworld);
|
return this._connectors.First(c => c is Mangaworld);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Exception();
|
throw new Exception();
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System.Globalization;
|
using System.Net;
|
||||||
using System.Net;
|
|
||||||
using System.Text.Json.Nodes;
|
using System.Text.Json.Nodes;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using Tranga.Jobs;
|
using Tranga.Jobs;
|
||||||
@ -67,7 +66,7 @@ public class MangaDex : MangaConnector
|
|||||||
if(MangaFromJsonObject((JsonObject) mangaNode) is { } manga)
|
if(MangaFromJsonObject((JsonObject) mangaNode) is { } manga)
|
||||||
retManga.Add(manga); //Add Publication (Manga) to result
|
retManga.Add(manga); //Add Publication (Manga) to result
|
||||||
}
|
}
|
||||||
}else continue;
|
}//else continue;
|
||||||
}
|
}
|
||||||
Log($"Retrieved {retManga.Count} publications. Term=\"{publicationTitle}\"");
|
Log($"Retrieved {retManga.Count} publications. Term=\"{publicationTitle}\"");
|
||||||
return retManga.ToArray();
|
return retManga.ToArray();
|
||||||
@ -247,7 +246,7 @@ public class MangaDex : MangaConnector
|
|||||||
{
|
{
|
||||||
if (progressToken?.cancellationRequested ?? false)
|
if (progressToken?.cancellationRequested ?? false)
|
||||||
{
|
{
|
||||||
progressToken?.Cancel();
|
progressToken.Cancel();
|
||||||
return HttpStatusCode.RequestTimeout;
|
return HttpStatusCode.RequestTimeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System.Globalization;
|
using System.Net;
|
||||||
using System.Net;
|
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using HtmlAgilityPack;
|
using HtmlAgilityPack;
|
||||||
using Tranga.Jobs;
|
using Tranga.Jobs;
|
||||||
@ -187,7 +186,7 @@ public class MangaKatana : MangaConnector
|
|||||||
{
|
{
|
||||||
if (progressToken?.cancellationRequested ?? false)
|
if (progressToken?.cancellationRequested ?? false)
|
||||||
{
|
{
|
||||||
progressToken?.Cancel();
|
progressToken.Cancel();
|
||||||
return HttpStatusCode.RequestTimeout;
|
return HttpStatusCode.RequestTimeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System.Globalization;
|
using System.Net;
|
||||||
using System.Net;
|
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using HtmlAgilityPack;
|
using HtmlAgilityPack;
|
||||||
using Tranga.Jobs;
|
using Tranga.Jobs;
|
||||||
@ -179,7 +178,7 @@ public class Manganato : MangaConnector
|
|||||||
{
|
{
|
||||||
if (progressToken?.cancellationRequested ?? false)
|
if (progressToken?.cancellationRequested ?? false)
|
||||||
{
|
{
|
||||||
progressToken?.Cancel();
|
progressToken.Cancel();
|
||||||
return HttpStatusCode.RequestTimeout;
|
return HttpStatusCode.RequestTimeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
using HtmlAgilityPack;
|
using HtmlAgilityPack;
|
||||||
using Newtonsoft.Json;
|
|
||||||
using Tranga.Jobs;
|
using Tranga.Jobs;
|
||||||
|
|
||||||
namespace Tranga.MangaConnectors;
|
namespace Tranga.MangaConnectors;
|
||||||
@ -140,14 +139,14 @@ public class Mangasee : MangaConnector
|
|||||||
{
|
{
|
||||||
if (progressToken?.cancellationRequested ?? false)
|
if (progressToken?.cancellationRequested ?? false)
|
||||||
{
|
{
|
||||||
progressToken?.Cancel();
|
progressToken.Cancel();
|
||||||
return HttpStatusCode.RequestTimeout;
|
return HttpStatusCode.RequestTimeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
Manga chapterParentManga = chapter.parentManga;
|
Manga chapterParentManga = chapter.parentManga;
|
||||||
if (progressToken?.cancellationRequested ?? false)
|
if (progressToken?.cancellationRequested ?? false)
|
||||||
{
|
{
|
||||||
progressToken?.Cancel();
|
progressToken.Cancel();
|
||||||
return HttpStatusCode.RequestTimeout;
|
return HttpStatusCode.RequestTimeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,11 +69,8 @@ public class Mangaworld: MangaConnector
|
|||||||
|
|
||||||
private Manga ParseSinglePublicationFromHtml(HtmlDocument document, string publicationId)
|
private Manga ParseSinglePublicationFromHtml(HtmlDocument document, string publicationId)
|
||||||
{
|
{
|
||||||
string status = "";
|
|
||||||
Dictionary<string, string> altTitles = new();
|
Dictionary<string, string> altTitles = new();
|
||||||
Dictionary<string, string>? links = null;
|
Dictionary<string, string>? links = null;
|
||||||
HashSet<string> tags = new();
|
|
||||||
string[] authors = Array.Empty<string>();
|
|
||||||
string originalLanguage = "";
|
string originalLanguage = "";
|
||||||
|
|
||||||
HtmlNode infoNode = document.DocumentNode.Descendants("div").First(d => d.HasClass("info"));
|
HtmlNode infoNode = document.DocumentNode.Descendants("div").First(d => d.HasClass("info"));
|
||||||
@ -90,13 +87,13 @@ public class Mangaworld: MangaConnector
|
|||||||
|
|
||||||
HtmlNode genresNode =
|
HtmlNode genresNode =
|
||||||
metadata.SelectSingleNode("//span[text()='Generi: ']/..");
|
metadata.SelectSingleNode("//span[text()='Generi: ']/..");
|
||||||
tags = genresNode.SelectNodes("a").Select(node => node.InnerText).ToHashSet();
|
HashSet<string> tags = genresNode.SelectNodes("a").Select(node => node.InnerText).ToHashSet();
|
||||||
|
|
||||||
HtmlNode authorsNode =
|
HtmlNode authorsNode =
|
||||||
metadata.SelectSingleNode("//span[text()='Autore: ']/..");
|
metadata.SelectSingleNode("//span[text()='Autore: ']/..");
|
||||||
authors = new[] { authorsNode.SelectNodes("a").First().InnerText };
|
string[] authors = new[] { authorsNode.SelectNodes("a").First().InnerText };
|
||||||
|
|
||||||
status = metadata.SelectSingleNode("//span[text()='Stato: ']/..").SelectNodes("a").First().InnerText;
|
string status = metadata.SelectSingleNode("//span[text()='Stato: ']/..").SelectNodes("a").First().InnerText;
|
||||||
|
|
||||||
string posterUrl = document.DocumentNode.SelectSingleNode("//img[@class='rounded']").GetAttributeValue("src", "");
|
string posterUrl = document.DocumentNode.SelectSingleNode("//img[@class='rounded']").GetAttributeValue("src", "");
|
||||||
|
|
||||||
@ -169,7 +166,7 @@ public class Mangaworld: MangaConnector
|
|||||||
{
|
{
|
||||||
if (progressToken?.cancellationRequested ?? false)
|
if (progressToken?.cancellationRequested ?? false)
|
||||||
{
|
{
|
||||||
progressToken?.Cancel();
|
progressToken.Cancel();
|
||||||
return HttpStatusCode.RequestTimeout;
|
return HttpStatusCode.RequestTimeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ public partial class Tranga : GlobalBase
|
|||||||
private static void PrintHelp()
|
private static void PrintHelp()
|
||||||
{
|
{
|
||||||
Console.WriteLine("Tranga-Help:");
|
Console.WriteLine("Tranga-Help:");
|
||||||
foreach (Argument argument in arguments.Values)
|
foreach (Argument argument in Arguments.Values)
|
||||||
{
|
{
|
||||||
foreach(string name in argument.names)
|
foreach(string name in argument.names)
|
||||||
Console.Write("{0} ", name);
|
Console.Write("{0} ", name);
|
||||||
@ -82,14 +82,14 @@ public partial class Tranga : GlobalBase
|
|||||||
{
|
{
|
||||||
List<string> argsList = args.ToList();
|
List<string> argsList = args.ToList();
|
||||||
List<string> ret = new();
|
List<string> ret = new();
|
||||||
foreach (string name in arguments[arg].names)
|
foreach (string name in Arguments[arg].names)
|
||||||
{
|
{
|
||||||
int argIndex = argsList.IndexOf(name);
|
int argIndex = argsList.IndexOf(name);
|
||||||
if (argIndex != -1)
|
if (argIndex != -1)
|
||||||
{
|
{
|
||||||
if (arguments[arg].parameterCount == 0)
|
if (Arguments[arg].parameterCount == 0)
|
||||||
return ret.ToArray();
|
return ret.ToArray();
|
||||||
for (int parameterIndex = 1; parameterIndex <= arguments[arg].parameterCount; parameterIndex++)
|
for (int parameterIndex = 1; parameterIndex <= Arguments[arg].parameterCount; parameterIndex++)
|
||||||
{
|
{
|
||||||
if(argIndex + parameterIndex >= argsList.Count || args[argIndex + parameterIndex].Contains('-'))//End of arguments, or no parameter provided, when one is required
|
if(argIndex + parameterIndex >= argsList.Count || args[argIndex + parameterIndex].Contains('-'))//End of arguments, or no parameter provided, when one is required
|
||||||
Console.WriteLine($"No parameter provided for argument {name}. -h for help.");
|
Console.WriteLine($"No parameter provided for argument {name}. -h for help.");
|
||||||
@ -100,7 +100,7 @@ public partial class Tranga : GlobalBase
|
|||||||
return ret.Any() ? ret.ToArray() : null;
|
return ret.Any() ? ret.ToArray() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Dictionary<ArgEnum, Argument> arguments = new()
|
private static readonly Dictionary<ArgEnum, Argument> Arguments = new()
|
||||||
{
|
{
|
||||||
{ ArgEnum.DownloadLocation, new(new []{"-d", "--downloadLocation"}, 1, "Directory to which downloaded Manga are saved") },
|
{ ArgEnum.DownloadLocation, new(new []{"-d", "--downloadLocation"}, 1, "Directory to which downloaded Manga are saved") },
|
||||||
{ ArgEnum.WorkingDirectory, new(new []{"-w", "--workingDirectory"}, 1, "Directory in which application-data is saved") },
|
{ ArgEnum.WorkingDirectory, new(new []{"-w", "--workingDirectory"}, 1, "Directory in which application-data is saved") },
|
||||||
|
@ -46,7 +46,7 @@ public class TrangaSettings
|
|||||||
this.downloadLocation = downloadLocation!;
|
this.downloadLocation = downloadLocation!;
|
||||||
this.workingDirectory = workingDirectory!;
|
this.workingDirectory = workingDirectory!;
|
||||||
}
|
}
|
||||||
UpdateDownloadLocation(this.downloadLocation!, false);
|
UpdateDownloadLocation(this.downloadLocation, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashSet<LibraryConnector> LoadLibraryConnectors(GlobalBase clone)
|
public HashSet<LibraryConnector> LoadLibraryConnectors(GlobalBase clone)
|
||||||
|
Loading…
Reference in New Issue
Block a user