mirror of
https://github.com/C9Glax/tranga.git
synced 2025-06-14 15:27:53 +02:00
Compare commits
26 Commits
Author | SHA1 | Date | |
---|---|---|---|
3effc7aeb6 | |||
621468f498 | |||
2c8e647a04 | |||
9d583b284a | |||
08e0fe7c71 | |||
9d104b25f8 | |||
2550beb621 | |||
2b18dc9d4f | |||
247c06872e | |||
854bb71771 | |||
3f72e527fa | |||
3c1865de31 | |||
84542640dc | |||
a3520dfd77 | |||
68b40e087e | |||
1674d70995 | |||
ccbe8a95f8 | |||
78d8deb9de | |||
1d0883cbab | |||
7726259d19 | |||
dc97774587 | |||
26ef59ab42 | |||
1b59475254 | |||
28218b6dab | |||
5bfd6bc196 | |||
bc99735f76 |
@ -1,3 +1,5 @@
|
||||
Has a interactive CLI-Version as well as API-Version (no documentation yet).
|
||||
Has a interactive CLI-Version as well as API-Version (no documentation of API yet).
|
||||
|
||||
Only one Connector so far: MangaDex.org (Timeout between requests 750ms)
|
||||
|
||||
Can automatically download new Chapters every given time-period.
|
@ -55,8 +55,8 @@ public static class Tranga_Cli
|
||||
if(task != TrangaTask.Task.UpdatePublications)
|
||||
publication = SelectPublication(connector);
|
||||
TimeSpan reoccurrence = SelectReoccurrence();
|
||||
taskManager.AddTask(task, connector.name, publication, reoccurrence, "en");
|
||||
Console.WriteLine($"{task} - {connector.name} - {publication?.sortName}");
|
||||
TrangaTask newTask = taskManager.AddTask(task, connector.name, publication, reoccurrence, "en");
|
||||
Console.WriteLine(newTask);
|
||||
Console.WriteLine("Press any key.");
|
||||
Console.ReadKey();
|
||||
menu = 0;
|
||||
@ -68,7 +68,25 @@ public static class Tranga_Cli
|
||||
menu = 0;
|
||||
break;
|
||||
case 4:
|
||||
ExecuteTask(taskManager);
|
||||
ExecuteTaskNow(taskManager);
|
||||
Console.WriteLine("Press any key.");
|
||||
Console.ReadKey();
|
||||
menu = 0;
|
||||
break;
|
||||
case 5:
|
||||
Console.WriteLine("Search-Query (Name):");
|
||||
string? query = Console.ReadLine();
|
||||
while (query is null || query.Length < 1)
|
||||
query = Console.ReadLine();
|
||||
PrintTasks(taskManager.GetAllTasks().Where(qTask =>
|
||||
((Publication)qTask.publication!).sortName.ToLower()
|
||||
.Contains(query, StringComparison.OrdinalIgnoreCase)).ToArray());
|
||||
Console.WriteLine("Press any key.");
|
||||
Console.ReadKey();
|
||||
menu = 0;
|
||||
break;
|
||||
case 6:
|
||||
PrintTasks(taskManager.GetAllTasks().Where(eTask => eTask.isBeingExecuted).ToArray());
|
||||
Console.WriteLine("Press any key.");
|
||||
Console.ReadKey();
|
||||
menu = 0;
|
||||
@ -89,6 +107,15 @@ public static class Tranga_Cli
|
||||
case ConsoleKey.E:
|
||||
menu = 4;
|
||||
break;
|
||||
case ConsoleKey.U:
|
||||
menu = 0;
|
||||
break;
|
||||
case ConsoleKey.S:
|
||||
menu = 5;
|
||||
break;
|
||||
case ConsoleKey.R:
|
||||
menu = 6;
|
||||
break;
|
||||
default:
|
||||
menu = 0;
|
||||
break;
|
||||
@ -103,6 +130,7 @@ public static class Tranga_Cli
|
||||
selection = Console.ReadKey().Key;
|
||||
taskManager.Shutdown(selection == ConsoleKey.Y);
|
||||
}else
|
||||
// ReSharper disable once RedundantArgumentDefaultValue Better readability
|
||||
taskManager.Shutdown(false);
|
||||
}
|
||||
|
||||
@ -112,10 +140,13 @@ public static class Tranga_Cli
|
||||
int taskRunningCount = taskManager.GetAllTasks().Count(task => task.isBeingExecuted);
|
||||
Console.Clear();
|
||||
Console.WriteLine($"Download Folder: {folderPath} Tasks (Running/Total): {taskRunningCount}/{taskCount}");
|
||||
Console.WriteLine("U: Update this Screen");
|
||||
Console.WriteLine("L: List tasks");
|
||||
Console.WriteLine("C: Create Task");
|
||||
Console.WriteLine("D: Delete Task");
|
||||
Console.WriteLine("E: Execute Task now");
|
||||
Console.WriteLine("S: Search Task");
|
||||
Console.WriteLine("R: Running Tasks");
|
||||
Console.WriteLine("Q: Exit");
|
||||
ConsoleKey selection = Console.ReadKey().Key;
|
||||
Console.WriteLine();
|
||||
@ -130,10 +161,10 @@ public static class Tranga_Cli
|
||||
int tIndex = 0;
|
||||
Console.WriteLine($"Tasks (Running/Total): {taskRunningCount}/{taskCount}");
|
||||
foreach(TrangaTask trangaTask in tasks)
|
||||
Console.WriteLine($"{tIndex++}: {trangaTask.task} - {trangaTask.reoccurrence} - {trangaTask.publication?.sortName} - {trangaTask.connectorName} - {trangaTask.lastExecuted} - {(trangaTask.isBeingExecuted ? "Running" : "Waiting")}");
|
||||
Console.WriteLine($"{tIndex++:000}: {trangaTask}");
|
||||
}
|
||||
|
||||
private static void ExecuteTask(TaskManager taskManager)
|
||||
private static void ExecuteTaskNow(TaskManager taskManager)
|
||||
{
|
||||
TrangaTask[] tasks = taskManager.GetAllTasks();
|
||||
if (tasks.Length < 1)
|
||||
@ -144,7 +175,7 @@ public static class Tranga_Cli
|
||||
}
|
||||
PrintTasks(tasks);
|
||||
|
||||
Console.WriteLine($"Select Task (0-{tasks.Length}):");
|
||||
Console.WriteLine($"Select Task (0-{tasks.Length - 1}):");
|
||||
|
||||
string? selectedTask = Console.ReadLine();
|
||||
while(selectedTask is null || selectedTask.Length < 1)
|
||||
@ -165,7 +196,7 @@ public static class Tranga_Cli
|
||||
}
|
||||
PrintTasks(tasks);
|
||||
|
||||
Console.WriteLine($"Select Task (0-{tasks.Length}):");
|
||||
Console.WriteLine($"Select Task (0-{tasks.Length - 1}):");
|
||||
|
||||
string? selectedTask = Console.ReadLine();
|
||||
while(selectedTask is null || selectedTask.Length < 1)
|
||||
@ -184,7 +215,7 @@ public static class Tranga_Cli
|
||||
Console.WriteLine("Available Tasks:");
|
||||
foreach (string taskName in taskNames)
|
||||
Console.WriteLine($"{tIndex++}: {taskName}");
|
||||
Console.WriteLine($"Select Task (0-{taskNames.Length}):");
|
||||
Console.WriteLine($"Select Task (0-{taskNames.Length - 1}):");
|
||||
|
||||
string? selectedTask = Console.ReadLine();
|
||||
while(selectedTask is null || selectedTask.Length < 1)
|
||||
@ -285,7 +316,7 @@ public static class Tranga_Cli
|
||||
selected = Console.ReadLine();
|
||||
|
||||
int start = 0;
|
||||
int end = 0;
|
||||
int end;
|
||||
if (selected == "a")
|
||||
end = chapters.Length - 1;
|
||||
else if (selected.Contains('-'))
|
||||
|
@ -23,6 +23,6 @@ public struct Chapter
|
||||
string chapterName = string.Concat((name ?? "").Split(Path.GetInvalidFileNameChars()));
|
||||
double multiplied = Convert.ToDouble(chapterNumber, new NumberFormatInfo() { NumberDecimalSeparator = "." }) *
|
||||
Convert.ToInt32(volumeNumber);
|
||||
this.fileName = $"{chapterName} - V{volumeNumber}C{chapterNumber} - {multiplied}";
|
||||
this.fileName = $"{chapterName} - V{volumeNumber}C{chapterNumber} - {multiplied.ToString(new NumberFormatInfo() { NumberDecimalSeparator = "." })}";
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
using System.IO.Compression;
|
||||
using System.Net;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Tranga;
|
||||
|
||||
@ -57,9 +58,34 @@ public abstract class Connector
|
||||
/// <param name="publication">Publication to save series.json for</param>
|
||||
public void SaveSeriesInfo(Publication publication)
|
||||
{
|
||||
string seriesInfoPath = Path.Join(downloadLocation, publication.folderName, "series.json");
|
||||
//Check if Publication already has a Folder and a series.json
|
||||
string publicationFolder = Path.Join(downloadLocation, publication.folderName);
|
||||
if(!Directory.Exists(publicationFolder))
|
||||
Directory.CreateDirectory(publicationFolder);
|
||||
|
||||
string seriesInfoPath = Path.Join(publicationFolder, "series.json");
|
||||
if(!File.Exists(seriesInfoPath))
|
||||
File.WriteAllText(seriesInfoPath,publication.GetSeriesInfo());
|
||||
File.WriteAllText(seriesInfoPath,publication.GetSeriesInfoJson());
|
||||
}
|
||||
|
||||
protected static string CreateComicInfo(Publication publication, Chapter chapter)
|
||||
{
|
||||
XElement comicInfo = new XElement("ComicInfo",
|
||||
new XElement("Tags", string.Join(',',publication.tags)),
|
||||
new XElement("LanguageISO", publication.originalLanguage),
|
||||
new XElement("Title", chapter.name)
|
||||
);
|
||||
return comicInfo.ToString();
|
||||
}
|
||||
|
||||
public bool ChapterIsDownloaded(Publication publication, Chapter chapter)
|
||||
{
|
||||
return File.Exists(CreateFullFilepath(publication, chapter));
|
||||
}
|
||||
|
||||
protected string CreateFullFilepath(Publication publication, Chapter chapter)
|
||||
{
|
||||
return Path.Join(downloadLocation, publication.folderName, chapter.fileName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -82,7 +108,8 @@ public abstract class Connector
|
||||
/// <param name="imageUrls">List of URLs to download Images from</param>
|
||||
/// <param name="saveArchiveFilePath">Full path to save archive to (without file ending .cbz)</param>
|
||||
/// <param name="downloadClient">DownloadClient of the connector</param>
|
||||
protected static void DownloadChapterImages(string[] imageUrls, string saveArchiveFilePath, DownloadClient downloadClient)
|
||||
/// <param name="comicInfoPath">Path of the generate Chapter ComicInfo.xml, if it was generated</param>
|
||||
protected static void DownloadChapterImages(string[] imageUrls, string saveArchiveFilePath, DownloadClient downloadClient, string? comicInfoPath = null)
|
||||
{
|
||||
//Check if Publication Directory already exists
|
||||
string[] splitPath = saveArchiveFilePath.Split(Path.DirectorySeparatorChar);
|
||||
@ -95,22 +122,23 @@ public abstract class Connector
|
||||
return;
|
||||
|
||||
//Create a temporary folder to store images
|
||||
string tempFolder = Path.GetTempFileName();
|
||||
File.Delete(tempFolder);
|
||||
Directory.CreateDirectory(tempFolder);
|
||||
string tempFolder = Directory.CreateTempSubdirectory().FullName;
|
||||
|
||||
int chapter = 0;
|
||||
//Download all Images to temporary Folder
|
||||
foreach (string imageUrl in imageUrls)
|
||||
{
|
||||
string[] split = imageUrl.Split('.');
|
||||
string extension = split[split.Length - 1];
|
||||
string extension = split[^1];
|
||||
DownloadImage(imageUrl, Path.Join(tempFolder, $"{chapter++}.{extension}"), downloadClient);
|
||||
}
|
||||
|
||||
if(comicInfoPath is not null)
|
||||
File.Copy(comicInfoPath, Path.Join(tempFolder, "ComicInfo.xml"));
|
||||
|
||||
//ZIP-it and ship-it
|
||||
ZipFile.CreateFromDirectory(tempFolder, fullPath);
|
||||
Directory.Delete(tempFolder); //Cleanup
|
||||
Directory.Delete(tempFolder, true); //Cleanup
|
||||
}
|
||||
|
||||
protected class DownloadClient
|
||||
|
@ -49,7 +49,7 @@ public class MangaDex : Connector
|
||||
|
||||
string title = attributes["title"]!.AsObject().ContainsKey("en") && attributes["title"]!["en"] is not null
|
||||
? attributes["title"]!["en"]!.GetValue<string>()
|
||||
: "";
|
||||
: attributes["title"]![((IDictionary<string, JsonNode?>)attributes["title"]!.AsObject()).Keys.First()]!.GetValue<string>();
|
||||
|
||||
string? description = attributes["description"]!.AsObject().ContainsKey("en") && attributes["description"]!["en"] is not null
|
||||
? attributes["description"]!["en"]!.GetValue<string?>()
|
||||
@ -197,15 +197,19 @@ public class MangaDex : Connector
|
||||
foreach (JsonNode? image in imageFileNames)
|
||||
imageUrls.Add($"{baseUrl}/data/{hash}/{image!.GetValue<string>()}");
|
||||
|
||||
string comicInfoPath = Path.GetTempFileName();
|
||||
File.WriteAllText(comicInfoPath, CreateComicInfo(publication, chapter));
|
||||
|
||||
//Download Chapter-Images
|
||||
DownloadChapterImages(imageUrls.ToArray(), Path.Join(downloadLocation, publication.folderName, chapter.fileName), this.downloadClient);
|
||||
DownloadChapterImages(imageUrls.ToArray(), CreateFullFilepath(publication, chapter), downloadClient, comicInfoPath);
|
||||
}
|
||||
|
||||
public override void DownloadCover(Publication publication)
|
||||
{
|
||||
//Check if Publication already has a Folder and cover
|
||||
string publicationFolder = Path.Join(downloadLocation, publication.folderName);
|
||||
Directory.CreateDirectory(publicationFolder);
|
||||
if(!Directory.Exists(publicationFolder))
|
||||
Directory.CreateDirectory(publicationFolder);
|
||||
DirectoryInfo dirInfo = new (publicationFolder);
|
||||
foreach(FileInfo fileInfo in dirInfo.EnumerateFiles())
|
||||
if (fileInfo.Name.Contains("cover."))
|
||||
@ -220,13 +224,13 @@ public class MangaDex : Connector
|
||||
if (result is null)
|
||||
return;
|
||||
|
||||
string fileName = result!["data"]!["attributes"]!["fileName"]!.GetValue<string>();
|
||||
string fileName = result["data"]!["attributes"]!["fileName"]!.GetValue<string>();
|
||||
|
||||
string coverUrl = $"https://uploads.mangadex.org/covers/{publication.downloadUrl}/{fileName}";
|
||||
|
||||
//Get file-extension (jpg, png)
|
||||
string[] split = coverUrl.Split('.');
|
||||
string extension = split[split.Length - 1];
|
||||
string extension = split[^1];
|
||||
|
||||
string outFolderPath = Path.Join(downloadLocation, publication.folderName);
|
||||
Directory.CreateDirectory(outFolderPath);
|
||||
|
@ -5,10 +5,12 @@ namespace Tranga;
|
||||
/// <summary>
|
||||
/// Contains information on a Publication (Manga)
|
||||
/// </summary>
|
||||
public struct Publication
|
||||
public readonly struct Publication
|
||||
{
|
||||
public string sortName { get; }
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global we need it, trust
|
||||
[JsonIgnore]public string[,] altTitles { get; }
|
||||
// ReSharper disable trice MemberCanBePrivate.Global, trust
|
||||
public string? description { get; }
|
||||
public string[] tags { get; }
|
||||
public string? posterUrl { get; }
|
||||
@ -31,14 +33,14 @@ public struct Publication
|
||||
this.originalLanguage = originalLanguage;
|
||||
this.status = status;
|
||||
this.downloadUrl = downloadUrl;
|
||||
this.folderName = string.Concat(sortName.Split(Path.GetInvalidPathChars()));
|
||||
this.folderName = string.Concat(sortName.Split(Path.GetInvalidPathChars().Concat(Path.GetInvalidFileNameChars()).ToArray()));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns>Serialized JSON String for series.json</returns>
|
||||
public string GetSeriesInfo()
|
||||
public string GetSeriesInfoJson()
|
||||
{
|
||||
SeriesInfo si = new (new Metadata(this.sortName, this.year.ToString() ?? string.Empty, this.status, this.description ?? ""));
|
||||
return System.Text.Json.JsonSerializer.Serialize(si);
|
||||
@ -47,25 +49,49 @@ public struct Publication
|
||||
//Only for series.json
|
||||
private struct SeriesInfo
|
||||
{
|
||||
// ReSharper disable once UnusedAutoPropertyAccessor.Local we need it, trust
|
||||
[JsonRequired]public Metadata metadata { get; }
|
||||
public SeriesInfo(Metadata metadata) => this.metadata = metadata;
|
||||
}
|
||||
|
||||
//Only for series.json
|
||||
//Only for series.json what an abomination, why are all the fields not-null????
|
||||
private struct Metadata
|
||||
{
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Local we need it, trust
|
||||
[JsonRequired] public string type { get; }
|
||||
[JsonRequired] public string publisher { get; }
|
||||
// ReSharper disable twice IdentifierTypo
|
||||
[JsonRequired] public int comicid { get; }
|
||||
[JsonRequired] public string booktype { get; }
|
||||
// ReSharper disable InconsistentNaming
|
||||
[JsonRequired] public string ComicImage { get; }
|
||||
[JsonRequired] public int total_issues { get; }
|
||||
[JsonRequired] public string publication_run { get; }
|
||||
[JsonRequired]public string name { get; }
|
||||
[JsonRequired]public string year { get; }
|
||||
[JsonRequired]public string status { get; }
|
||||
// ReSharper disable twice InconsistentNaming
|
||||
[JsonRequired]public string description_text { get; }
|
||||
|
||||
public Metadata(string name, string year, string status, string description_text)
|
||||
{
|
||||
this.name = name;
|
||||
this.year = year;
|
||||
this.status = status;
|
||||
if(status == "ongoing" || status == "hiatus")
|
||||
this.status = "Continuing";
|
||||
else if (status == "completed" || status == "cancelled")
|
||||
this.status = "Ended";
|
||||
else
|
||||
this.status = status;
|
||||
this.description_text = description_text;
|
||||
|
||||
//kill it with fire
|
||||
type = "Manga";
|
||||
publisher = "";
|
||||
comicid = 0;
|
||||
booktype = "";
|
||||
ComicImage = "";
|
||||
total_issues = 0;
|
||||
publication_run = "";
|
||||
}
|
||||
}
|
||||
}
|
@ -67,10 +67,19 @@ public static class TaskExecutor
|
||||
private static void DownloadNewChapters(Connector connector, Publication publication, string language, Dictionary<Publication, List<Chapter>> chapterCollection)
|
||||
{
|
||||
List<Chapter> newChapters = UpdateChapters(connector, publication, language, chapterCollection);
|
||||
connector.DownloadCover(publication);
|
||||
|
||||
//Check if Publication already has a Folder and a series.json
|
||||
string publicationFolder = Path.Join(connector.downloadLocation, publication.folderName);
|
||||
if(!Directory.Exists(publicationFolder))
|
||||
Directory.CreateDirectory(publicationFolder);
|
||||
|
||||
string seriesInfoPath = Path.Join(publicationFolder, "series.json");
|
||||
if(!File.Exists(seriesInfoPath))
|
||||
File.WriteAllText(seriesInfoPath,publication.GetSeriesInfoJson());
|
||||
|
||||
foreach(Chapter newChapter in newChapters)
|
||||
connector.DownloadChapter(publication, newChapter);
|
||||
connector.DownloadCover(publication);
|
||||
connector.SaveSeriesInfo(publication);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -84,14 +93,11 @@ public static class TaskExecutor
|
||||
private static List<Chapter> UpdateChapters(Connector connector, Publication publication, string language, Dictionary<Publication, List<Chapter>> chapterCollection)
|
||||
{
|
||||
List<Chapter> newChaptersList = new();
|
||||
if (!chapterCollection.ContainsKey(publication))
|
||||
return newChaptersList;
|
||||
chapterCollection.TryAdd(publication, newChaptersList); //To ensure publication is actually in collection
|
||||
|
||||
List<Chapter> currentChapters = chapterCollection[publication];
|
||||
Chapter[] newChapters = connector.GetChapters(publication, language);
|
||||
newChaptersList = newChapters.Where(nChapter => !connector.ChapterIsDownloaded(publication, nChapter)).ToList();
|
||||
|
||||
newChaptersList = newChapters.ToList()
|
||||
.ExceptBy(currentChapters.Select(cChapter => cChapter.url), nChapter => nChapter.url).ToList();
|
||||
return newChaptersList;
|
||||
}
|
||||
}
|
@ -12,8 +12,7 @@ public class TaskManager
|
||||
private readonly Dictionary<Publication, List<Chapter>> _chapterCollection;
|
||||
private readonly HashSet<TrangaTask> _allTasks;
|
||||
private bool _continueRunning = true;
|
||||
private readonly Connector[] connectors;
|
||||
private readonly string folderPath;
|
||||
private readonly Connector[] _connectors;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@ -21,8 +20,7 @@ public class TaskManager
|
||||
/// <param name="folderPath">Local path to save data (Manga) to</param>
|
||||
public TaskManager(string folderPath)
|
||||
{
|
||||
this.folderPath = folderPath;
|
||||
this.connectors = new Connector[]{ new MangaDex(folderPath) };
|
||||
this._connectors = new Connector[]{ new MangaDex(folderPath) };
|
||||
_chapterCollection = new();
|
||||
_allTasks = ImportTasks(Directory.GetCurrentDirectory());
|
||||
Thread taskChecker = new(TaskCheckerThread);
|
||||
@ -36,7 +34,7 @@ public class TaskManager
|
||||
foreach (TrangaTask task in _allTasks)
|
||||
{
|
||||
if(task.ShouldExecute())
|
||||
TaskExecutor.Execute(this.connectors, task, this._chapterCollection);
|
||||
TaskExecutor.Execute(this._connectors, task, this._chapterCollection); //Might crash here, when adding new Task while another Task is running. Check later
|
||||
}
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
@ -53,7 +51,7 @@ public class TaskManager
|
||||
|
||||
Task t = new Task(() =>
|
||||
{
|
||||
TaskExecutor.Execute(this.connectors, task, this._chapterCollection);
|
||||
TaskExecutor.Execute(this._connectors, task, this._chapterCollection);
|
||||
});
|
||||
t.Start();
|
||||
}
|
||||
@ -67,23 +65,25 @@ public class TaskManager
|
||||
/// <param name="reoccurrence">Time-Interval between Executions</param>
|
||||
/// <param name="language">language, should Task require parameter. Can be empty</param>
|
||||
/// <exception cref="ArgumentException">Is thrown when connectorName is not a available Connector</exception>
|
||||
public void AddTask(TrangaTask.Task task, string connectorName, Publication? publication, TimeSpan reoccurrence,
|
||||
public TrangaTask AddTask(TrangaTask.Task task, string connectorName, Publication? publication, TimeSpan reoccurrence,
|
||||
string language = "")
|
||||
{
|
||||
//Get appropriate Connector from available Connectors for TrangaTask
|
||||
Connector? connector = connectors.FirstOrDefault(c => c.name == connectorName);
|
||||
Connector? connector = _connectors.FirstOrDefault(c => c.name == connectorName);
|
||||
if (connector is null)
|
||||
throw new ArgumentException($"Connector {connectorName} is not a known connector.");
|
||||
|
||||
TrangaTask newTask = new TrangaTask(connector.name, task, publication, reoccurrence, language);
|
||||
//Check if same task already exists
|
||||
if (!_allTasks.Any(trangaTask => trangaTask.task != task && trangaTask.connectorName != connector.name &&
|
||||
trangaTask.publication?.downloadUrl != publication?.downloadUrl))
|
||||
{
|
||||
if(task != TrangaTask.Task.UpdatePublications)
|
||||
_chapterCollection.Add((Publication)publication!, new List<Chapter>());
|
||||
_allTasks.Add(new TrangaTask(connector.name, task, publication, reoccurrence, language));
|
||||
_allTasks.Add(newTask);
|
||||
ExportTasks(Directory.GetCurrentDirectory());
|
||||
}
|
||||
return newTask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -106,7 +106,7 @@ public class TaskManager
|
||||
/// <returns>All available Connectors</returns>
|
||||
public Dictionary<string, Connector> GetAvailableConnectors()
|
||||
{
|
||||
return this.connectors.ToDictionary(connector => connector.name, connector => connector);
|
||||
return this._connectors.ToDictionary(connector => connector.name, connector => connector);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -7,6 +7,8 @@ namespace Tranga;
|
||||
/// </summary>
|
||||
public class TrangaTask
|
||||
{
|
||||
// ReSharper disable once CommentTypo ...tell me why!
|
||||
// ReSharper disable once MemberCanBePrivate.Global I want it thaaat way
|
||||
public TimeSpan reoccurrence { get; }
|
||||
public DateTime lastExecuted { get; set; }
|
||||
public string connectorName { get; }
|
||||
@ -42,4 +44,9 @@ public class TrangaTask
|
||||
UpdateChapters,
|
||||
DownloadNewChapters
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{task}\t{lastExecuted}\t{reoccurrence}\t{(isBeingExecuted ? "running" : "waiting")}\t{connectorName}\t{publication?.sortName}";
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user