Compare commits

..

No commits in common. "b3bf523e1e3a673bf9a537ea93fdc0c8cd7be5a7" and "31a0c6ffb2355b80a8d86ff11674660715761ff2" have entirely different histories.

13 changed files with 43 additions and 36 deletions

View File

@ -8,6 +8,5 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=mangakatana/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Manganato/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Mangasee/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Mangaworld/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Taskmanager/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Tranga/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

View File

@ -101,7 +101,7 @@ public class JobBoss : GlobalBase
Chapter? chapter = null)
{
if (chapter is not null)
return GetJobsLike(mangaConnector?.name, chapter.Value.parentManga.internalId, chapter.Value.chapterNumber);
return GetJobsLike(mangaConnector?.name, chapter.Value.parentManga.internalId, chapter?.chapterNumber);
else
return GetJobsLike(mangaConnector?.name, publication?.internalId);
}

View File

@ -26,7 +26,7 @@ public class ProgressToken
private float GetProgress()
{
if(increments > 0 && incrementsCompleted > 0)
return incrementsCompleted / (float)increments;
return (float)incrementsCompleted / (float)increments;
return 0;
}

View File

@ -5,7 +5,7 @@ namespace Tranga.LibraryConnectors;
public class LibraryManagerJsonConverter : JsonConverter
{
private readonly GlobalBase _clone;
private GlobalBase _clone;
internal LibraryManagerJsonConverter(GlobalBase clone)
{

View File

@ -60,7 +60,7 @@ internal class ChromiumDownloadClient : DownloadClient
protected override RequestResult MakeRequestInternal(string url, string? referrer = null)
{
IPage page = this.browser.NewPageAsync().Result;
IPage page = this.browser!.NewPageAsync().Result;
page.DefaultTimeout = 10000;
IResponse response = page.GoToAsync(url, WaitUntilNavigation.DOMContentLoaded).Result;
Log("Page loaded.");

View File

@ -6,12 +6,12 @@ namespace Tranga.MangaConnectors;
public class MangaConnectorJsonConverter : JsonConverter
{
private GlobalBase _clone;
private readonly HashSet<MangaConnector> _connectors;
private HashSet<MangaConnector> connectors;
internal MangaConnectorJsonConverter(GlobalBase clone, HashSet<MangaConnector> connectors)
{
this._clone = clone;
this._connectors = connectors;
this.connectors = connectors;
}
public override bool CanConvert(Type objectType)
@ -25,15 +25,15 @@ public class MangaConnectorJsonConverter : JsonConverter
switch (jo.GetValue("name")!.Value<string>()!)
{
case "MangaDex":
return this._connectors.First(c => c is MangaDex);
return this.connectors.First(c => c is MangaDex);
case "Manganato":
return this._connectors.First(c => c is Manganato);
return this.connectors.First(c => c is Manganato);
case "MangaKatana":
return this._connectors.First(c => c is MangaKatana);
return this.connectors.First(c => c is MangaKatana);
case "Mangasee":
return this._connectors.First(c => c is Mangasee);
return this.connectors.First(c => c is Mangasee);
case "Mangaworld":
return this._connectors.First(c => c is Mangaworld);
return this.connectors.First(c => c is Mangaworld);
}
throw new Exception();

View File

@ -1,4 +1,5 @@
using System.Net;
using System.Globalization;
using System.Net;
using System.Text.Json.Nodes;
using System.Text.RegularExpressions;
using Tranga.Jobs;
@ -66,7 +67,7 @@ public class MangaDex : MangaConnector
if(MangaFromJsonObject((JsonObject) mangaNode) is { } manga)
retManga.Add(manga); //Add Publication (Manga) to result
}
}//else continue;
}else continue;
}
Log($"Retrieved {retManga.Count} publications. Term=\"{publicationTitle}\"");
return retManga.ToArray();
@ -246,7 +247,7 @@ public class MangaDex : MangaConnector
{
if (progressToken?.cancellationRequested ?? false)
{
progressToken.Cancel();
progressToken?.Cancel();
return HttpStatusCode.RequestTimeout;
}

View File

@ -1,4 +1,5 @@
using System.Net;
using System.Globalization;
using System.Net;
using System.Text.RegularExpressions;
using HtmlAgilityPack;
using Tranga.Jobs;
@ -186,7 +187,7 @@ public class MangaKatana : MangaConnector
{
if (progressToken?.cancellationRequested ?? false)
{
progressToken.Cancel();
progressToken?.Cancel();
return HttpStatusCode.RequestTimeout;
}

View File

@ -1,4 +1,5 @@
using System.Net;
using System.Globalization;
using System.Net;
using System.Text.RegularExpressions;
using HtmlAgilityPack;
using Tranga.Jobs;
@ -34,8 +35,8 @@ public class Manganato : MangaConnector
private Manga[] ParsePublicationsFromHtml(HtmlDocument document)
{
List<HtmlNode> searchResults = document.DocumentNode.Descendants("div").Where(n => n.HasClass("search-story-item")).ToList();
Log($"{searchResults.Count} items.");
IEnumerable<HtmlNode> searchResults = document.DocumentNode.Descendants("div").Where(n => n.HasClass("search-story-item"));
Log($"{searchResults.Count()} items.");
List<string> urls = new();
foreach (HtmlNode mangaResult in searchResults)
{
@ -178,7 +179,7 @@ public class Manganato : MangaConnector
{
if (progressToken?.cancellationRequested ?? false)
{
progressToken.Cancel();
progressToken?.Cancel();
return HttpStatusCode.RequestTimeout;
}

View File

@ -2,6 +2,7 @@
using System.Text.RegularExpressions;
using System.Xml.Linq;
using HtmlAgilityPack;
using Newtonsoft.Json;
using Tranga.Jobs;
namespace Tranga.MangaConnectors;
@ -122,10 +123,11 @@ public class Mangasee : MangaConnector
foreach (XElement chapter in chapterItems)
{
string volumeNumber = "1";
string url = chapter.Descendants("link").First().Value;
string chapterNumber = Regex.Match(url, @"-chapter-([0-9\.]+)").Groups[1].ToString();
string chapterName = chapter.Descendants("title").First().Value;
string chapterNumber = Regex.Matches(chapterName, "[0-9]+")[^1].ToString();
url = url.Replace(Regex.Match(url,"(-page-[0-9])").Value,"");
string url = chapter.Descendants("link").First().Value;
url = url.Replace(Regex.Matches(url,"(-page-[0-9])")[0].ToString(),"");
chapters.Add(new Chapter(manga, "", volumeNumber, chapterNumber, url));
}
@ -138,14 +140,14 @@ public class Mangasee : MangaConnector
{
if (progressToken?.cancellationRequested ?? false)
{
progressToken.Cancel();
progressToken?.Cancel();
return HttpStatusCode.RequestTimeout;
}
Manga chapterParentManga = chapter.parentManga;
if (progressToken?.cancellationRequested ?? false)
{
progressToken.Cancel();
progressToken?.Cancel();
return HttpStatusCode.RequestTimeout;
}

View File

@ -69,8 +69,11 @@ public class Mangaworld: MangaConnector
private Manga ParseSinglePublicationFromHtml(HtmlDocument document, string publicationId)
{
string status = "";
Dictionary<string, string> altTitles = new();
Dictionary<string, string>? links = null;
HashSet<string> tags = new();
string[] authors = Array.Empty<string>();
string originalLanguage = "";
HtmlNode infoNode = document.DocumentNode.Descendants("div").First(d => d.HasClass("info"));
@ -87,13 +90,13 @@ public class Mangaworld: MangaConnector
HtmlNode genresNode =
metadata.SelectSingleNode("//span[text()='Generi: ']/..");
HashSet<string> tags = genresNode.SelectNodes("a").Select(node => node.InnerText).ToHashSet();
tags = genresNode.SelectNodes("a").Select(node => node.InnerText).ToHashSet();
HtmlNode authorsNode =
metadata.SelectSingleNode("//span[text()='Autore: ']/..");
string[] authors = new[] { authorsNode.SelectNodes("a").First().InnerText };
authors = new[] { authorsNode.SelectNodes("a").First().InnerText };
string status = metadata.SelectSingleNode("//span[text()='Stato: ']/..").SelectNodes("a").First().InnerText;
status = metadata.SelectSingleNode("//span[text()='Stato: ']/..").SelectNodes("a").First().InnerText;
string posterUrl = document.DocumentNode.SelectSingleNode("//img[@class='rounded']").GetAttributeValue("src", "");
@ -166,7 +169,7 @@ public class Mangaworld: MangaConnector
{
if (progressToken?.cancellationRequested ?? false)
{
progressToken.Cancel();
progressToken?.Cancel();
return HttpStatusCode.RequestTimeout;
}

View File

@ -59,7 +59,7 @@ public partial class Tranga : GlobalBase
private static void PrintHelp()
{
Console.WriteLine("Tranga-Help:");
foreach (Argument argument in Arguments.Values)
foreach (Argument argument in arguments.Values)
{
foreach(string name in argument.names)
Console.Write("{0} ", name);
@ -82,14 +82,14 @@ public partial class Tranga : GlobalBase
{
List<string> argsList = args.ToList();
List<string> ret = new();
foreach (string name in Arguments[arg].names)
foreach (string name in arguments[arg].names)
{
int argIndex = argsList.IndexOf(name);
if (argIndex != -1)
{
if (Arguments[arg].parameterCount == 0)
if (arguments[arg].parameterCount == 0)
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
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;
}
private static readonly Dictionary<ArgEnum, Argument> Arguments = new()
private static Dictionary<ArgEnum, Argument> arguments = new()
{
{ 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") },

View File

@ -46,7 +46,7 @@ public class TrangaSettings
this.downloadLocation = downloadLocation!;
this.workingDirectory = workingDirectory!;
}
UpdateDownloadLocation(this.downloadLocation, false);
UpdateDownloadLocation(this.downloadLocation!, false);
}
public HashSet<LibraryConnector> LoadLibraryConnectors(GlobalBase clone)