Compare commits

..

No commits in common. "61024bcee9b55d216111a9b6e54130eff57deb8f" and "181942153bf6084a295fee813cedc7898df48db8" have entirely different histories.

19 changed files with 25 additions and 70 deletions

View File

@ -2,9 +2,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=altnames/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=altnames/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=authorsartists/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=authorsartists/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Gotify/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Gotify/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=jjob/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Komga/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Komga/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=lunasea/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=mangakatana/@EntryIndexedValue">True</s:Boolean> <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/=Manganato/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Mangasee/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Mangasee/@EntryIndexedValue">True</s:Boolean>

View File

@ -36,10 +36,6 @@ public readonly struct Chapter
this.fileName = $"{volStr}{chNumberStr}{chNameStr}"; this.fileName = $"{volStr}{chNumberStr}{chNameStr}";
} }
public override string ToString()
{
return $"Chapter {parentPublication.sortName} {parentPublication.internalId} {chapterNumber} {name}";
}
/// <summary> /// <summary>
/// Checks if a chapter-archive is already present /// Checks if a chapter-archive is already present

View File

@ -49,7 +49,6 @@ public abstract class GlobalBase
protected void AddNotificationConnector(NotificationConnector notificationConnector) protected void AddNotificationConnector(NotificationConnector notificationConnector)
{ {
Log($"Adding {notificationConnector}");
notificationConnectors.RemoveWhere(nc => nc.GetType() == notificationConnector.GetType()); notificationConnectors.RemoveWhere(nc => nc.GetType() == notificationConnector.GetType());
notificationConnectors.Add(notificationConnector); notificationConnectors.Add(notificationConnector);
@ -60,7 +59,6 @@ public abstract class GlobalBase
protected void DeleteNotificationConnector(NotificationConnector.NotificationManagerType notificationManagerType) protected void DeleteNotificationConnector(NotificationConnector.NotificationManagerType notificationManagerType)
{ {
Log($"Removing {notificationManagerType}");
notificationConnectors.RemoveWhere(nc => nc.notificationManagerType == notificationManagerType); notificationConnectors.RemoveWhere(nc => nc.notificationManagerType == notificationManagerType);
} }
@ -72,7 +70,6 @@ public abstract class GlobalBase
protected void AddLibraryConnector(LibraryConnector libraryConnector) protected void AddLibraryConnector(LibraryConnector libraryConnector)
{ {
Log($"Adding {libraryConnector}");
libraryConnectors.RemoveWhere(lc => lc.GetType() == libraryConnector.GetType()); libraryConnectors.RemoveWhere(lc => lc.GetType() == libraryConnector.GetType());
libraryConnectors.Add(libraryConnector); libraryConnectors.Add(libraryConnector);
@ -83,7 +80,6 @@ public abstract class GlobalBase
protected void DeleteLibraryConnector(LibraryConnector.LibraryType libraryType) protected void DeleteLibraryConnector(LibraryConnector.LibraryType libraryType)
{ {
Log($"Removing {libraryType}");
libraryConnectors.RemoveWhere(lc => lc.libraryType == libraryType); libraryConnectors.RemoveWhere(lc => lc.libraryType == libraryType);
} }

View File

@ -17,11 +17,6 @@ public class DownloadChapter : Job
return Convert.ToBase64String(Encoding.ASCII.GetBytes(string.Concat(this.GetType().ToString(), chapter.parentPublication.internalId, chapter.chapterNumber))); return Convert.ToBase64String(Encoding.ASCII.GetBytes(string.Concat(this.GetType().ToString(), chapter.parentPublication.internalId, chapter.chapterNumber)));
} }
public override string ToString()
{
return $"DownloadChapter {id} {chapter}";
}
protected override IEnumerable<Job> ExecuteReturnSubTasksInternal() protected override IEnumerable<Job> ExecuteReturnSubTasksInternal()
{ {
Task downloadTask = new(delegate Task downloadTask = new(delegate

View File

@ -17,11 +17,6 @@ public class DownloadNewChapters : Job
return Convert.ToBase64String(Encoding.ASCII.GetBytes(string.Concat(this.GetType().ToString(), publication.internalId))); return Convert.ToBase64String(Encoding.ASCII.GetBytes(string.Concat(this.GetType().ToString(), publication.internalId)));
} }
public override string ToString()
{
return $"DownloadChapter {id} {publication}";
}
protected override IEnumerable<Job> ExecuteReturnSubTasksInternal() protected override IEnumerable<Job> ExecuteReturnSubTasksInternal()
{ {
Chapter[] chapters = mangaConnector.GetNewChapters(publication); Chapter[] chapters = mangaConnector.GetNewChapters(publication);

View File

@ -15,22 +15,22 @@ public class JobBoss : GlobalBase
public void AddJob(Job job) public void AddJob(Job job)
{ {
Log($"Added {job}");
this.jobs.Add(job); this.jobs.Add(job);
} }
public void RemoveJob(Job job) public void RemoveJob(Job job)
{ {
Log($"Removing {job}");
job.Cancel(); job.Cancel();
this.jobs.Remove(job); this.jobs.Remove(job);
} }
public void RemoveJobs(IEnumerable<Job> jobsToRemove) public void RemoveJobs(IEnumerable<Job> jobs)
{ {
Log($"Removing {jobsToRemove.Count()} jobs."); foreach (Job job in jobs)
foreach (Job job in jobsToRemove) {
RemoveJob(job); job.Cancel();
this.jobs.Remove(job);
}
} }
public IEnumerable<Job> GetJobsLike(string? connectorName = null, string? internalId = null, string? chapterNumber = null) public IEnumerable<Job> GetJobsLike(string? connectorName = null, string? internalId = null, string? chapterNumber = null)

View File

@ -17,11 +17,6 @@ public class Kavita : LibraryConnector
{ {
} }
public override string ToString()
{
return $"Kavita {baseUrl}";
}
private static string GetToken(string baseUrl, string username, string password) private static string GetToken(string baseUrl, string username, string password)
{ {
HttpClient client = new() HttpClient client = new()
@ -42,7 +37,7 @@ public class Kavita : LibraryConnector
JsonObject? result = JsonSerializer.Deserialize<JsonObject>(response.Content.ReadAsStream()); JsonObject? result = JsonSerializer.Deserialize<JsonObject>(response.Content.ReadAsStream());
if (result is not null) if (result is not null)
return result["token"]!.GetValue<string>(); return result["token"]!.GetValue<string>();
else throw new Exception("Did not receive token."); else return "";
} }
public override void UpdateLibrary() public override void UpdateLibrary()

View File

@ -20,11 +20,6 @@ public class Komga : LibraryConnector
{ {
} }
public override string ToString()
{
return $"Komga {baseUrl}";
}
public override void UpdateLibrary() public override void UpdateLibrary()
{ {
Log("Updating libraries."); Log("Updating libraries.");

View File

@ -20,7 +20,7 @@ internal class DownloadClient : GlobalBase
private readonly Dictionary<byte, DateTime> _lastExecutedRateLimit; private readonly Dictionary<byte, DateTime> _lastExecutedRateLimit;
private readonly Dictionary<byte, TimeSpan> _rateLimit; private readonly Dictionary<byte, TimeSpan> _rateLimit;
public DownloadClient(GlobalBase clone, Dictionary<byte, int> rateLimitRequestsPerMinute) : base(clone) public DownloadClient(Dictionary<byte, int> rateLimitRequestsPerMinute, GlobalBase clone) : base(clone)
{ {
_lastExecutedRateLimit = new(); _lastExecutedRateLimit = new();
_rateLimit = new(); _rateLimit = new();
@ -60,7 +60,6 @@ internal class DownloadClient : GlobalBase
if(referrer is not null) if(referrer is not null)
requestMessage.Headers.Referrer = new Uri(referrer); requestMessage.Headers.Referrer = new Uri(referrer);
_lastExecutedRateLimit[requestType] = DateTime.Now; _lastExecutedRateLimit[requestType] = DateTime.Now;
Log($"Requesting {requestType} {url}");
response = Client.Send(requestMessage); response = Client.Send(requestMessage);
} }
catch (HttpRequestException e) catch (HttpRequestException e)

View File

@ -18,7 +18,8 @@ public abstract class MangaConnector : GlobalBase
protected MangaConnector(GlobalBase clone) : base(clone) protected MangaConnector(GlobalBase clone) : base(clone)
{ {
Directory.CreateDirectory(settings.coverImageCache); if (!Directory.Exists(settings.coverImageCache))
Directory.CreateDirectory(settings.coverImageCache);
} }
public abstract string name { get; } //Name of the Connector (e.g. Website) public abstract string name { get; } //Name of the Connector (e.g. Website)

View File

@ -21,14 +21,14 @@ public class MangaDex : MangaConnector
public MangaDex(GlobalBase clone) : base(clone) public MangaDex(GlobalBase clone) : base(clone)
{ {
name = "MangaDex"; name = "MangaDex";
this.downloadClient = new DownloadClient(clone, new Dictionary<byte, int>() this.downloadClient = new DownloadClient(new Dictionary<byte, int>()
{ {
{(byte)RequestType.Manga, 250}, {(byte)RequestType.Manga, 250},
{(byte)RequestType.Feed, 250}, {(byte)RequestType.Feed, 250},
{(byte)RequestType.AtHomeServer, 40}, {(byte)RequestType.AtHomeServer, 40},
{(byte)RequestType.CoverUrl, 250}, {(byte)RequestType.CoverUrl, 250},
{(byte)RequestType.Author, 250} {(byte)RequestType.Author, 250}
}); }, clone);
} }
public override Publication[] GetPublications(string publicationTitle = "") public override Publication[] GetPublications(string publicationTitle = "")

View File

@ -13,10 +13,10 @@ public class MangaKatana : MangaConnector
public MangaKatana(GlobalBase clone) : base(clone) public MangaKatana(GlobalBase clone) : base(clone)
{ {
this.name = "MangaKatana"; this.name = "MangaKatana";
this.downloadClient = new DownloadClient(clone, new Dictionary<byte, int>() this.downloadClient = new DownloadClient(new Dictionary<byte, int>()
{ {
{1, 60} {1, 60}
}); }, clone);
} }
public override Publication[] GetPublications(string publicationTitle = "") public override Publication[] GetPublications(string publicationTitle = "")

View File

@ -13,10 +13,10 @@ public class Manganato : MangaConnector
public Manganato(GlobalBase clone) : base(clone) public Manganato(GlobalBase clone) : base(clone)
{ {
this.name = "Manganato"; this.name = "Manganato";
this.downloadClient = new DownloadClient(clone, new Dictionary<byte, int>() this.downloadClient = new DownloadClient(new Dictionary<byte, int>()
{ {
{1, 60} {1, 60}
}); }, clone);
} }
public override Publication[] GetPublications(string publicationTitle = "") public override Publication[] GetPublications(string publicationTitle = "")

View File

@ -18,10 +18,10 @@ public class Mangasee : MangaConnector
public Mangasee(GlobalBase clone) : base(clone) public Mangasee(GlobalBase clone) : base(clone)
{ {
this.name = "Mangasee"; this.name = "Mangasee";
this.downloadClient = new DownloadClient(clone, new Dictionary<byte, int>() this.downloadClient = new DownloadClient(new Dictionary<byte, int>()
{ {
{ 1, 60 } { 1, 60 }
}); }, clone);
Task d = new Task(DownloadBrowser); Task d = new Task(DownloadBrowser);
d.Start(); d.Start();

View File

@ -17,11 +17,6 @@ public class Gotify : NotificationConnector
this.appToken = appToken; this.appToken = appToken;
} }
public override string ToString()
{
return $"Gotify {endpoint}";
}
public override void SendNotification(string title, string notificationText) public override void SendNotification(string title, string notificationText)
{ {
Log($"Sending notification: {title} - {notificationText}"); Log($"Sending notification: {title} - {notificationText}");
@ -33,7 +28,7 @@ public class Gotify : NotificationConnector
if (!response.IsSuccessStatusCode) if (!response.IsSuccessStatusCode)
{ {
StreamReader sr = new (response.Content.ReadAsStream()); StreamReader sr = new (response.Content.ReadAsStream());
Log($"{response.StatusCode}: {sr.ReadToEnd()}"); logger?.WriteLine(this.GetType().ToString(), $"{response.StatusCode}: {sr.ReadToEnd()}");
} }
} }

View File

@ -15,11 +15,6 @@ public class LunaSea : NotificationConnector
this.id = id; this.id = id;
} }
public override string ToString()
{
return $"LunaSea {id}";
}
public override void SendNotification(string title, string notificationText) public override void SendNotification(string title, string notificationText)
{ {
Log($"Sending notification: {title} - {notificationText}"); Log($"Sending notification: {title} - {notificationText}");

View File

@ -2,7 +2,7 @@
public abstract class NotificationConnector : GlobalBase public abstract class NotificationConnector : GlobalBase
{ {
public readonly NotificationManagerType notificationManagerType; public NotificationManagerType notificationManagerType;
protected NotificationConnector(GlobalBase clone, NotificationManagerType notificationManagerType) : base(clone) protected NotificationConnector(GlobalBase clone, NotificationManagerType notificationManagerType) : base(clone)
{ {

View File

@ -58,11 +58,6 @@ public struct Publication
this.ignoreChaptersBelow = ignoreChaptersBelow ?? 0f; this.ignoreChaptersBelow = ignoreChaptersBelow ?? 0f;
} }
public override string ToString()
{
return $"Publication {sortName} {internalId}";
}
public string CreatePublicationFolder(string downloadDirectory) public string CreatePublicationFolder(string downloadDirectory)
{ {
string publicationFolder = Path.Join(downloadDirectory, this.folderName); string publicationFolder = Path.Join(downloadDirectory, this.folderName);

View File

@ -397,9 +397,9 @@ public class Server : GlobalBase
: Array.Empty<byte>()); : Array.Empty<byte>());
response.OutputStream.Close(); response.OutputStream.Close();
} }
catch (HttpListenerException e) catch (HttpListenerException)
{ {
Log(e.ToString());
} }
} }
} }