Compare commits
3 Commits
3ca96cea78
...
d659a26987
Author | SHA1 | Date | |
---|---|---|---|
d659a26987 | |||
8c6c95d07d | |||
c4949936cd |
@ -105,7 +105,7 @@ public static class Tranga_Cli
|
|||||||
int tIndex = 0;
|
int tIndex = 0;
|
||||||
Console.WriteLine("Tasks:");
|
Console.WriteLine("Tasks:");
|
||||||
foreach(TrangaTask trangaTask in tasks)
|
foreach(TrangaTask trangaTask in tasks)
|
||||||
Console.WriteLine($"{tIndex++}: {trangaTask.task} - {trangaTask.reoccurrence} - {trangaTask.publication?.sortName} - {trangaTask.connectorName}");
|
Console.WriteLine($"{tIndex++}: {trangaTask.task} - {trangaTask.reoccurrence} - {trangaTask.publication?.sortName} - {trangaTask.connectorName} - {trangaTask.lastExecuted}");
|
||||||
return tasks.Length;
|
return tasks.Length;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,7 +114,7 @@ public static class Tranga_Cli
|
|||||||
int length = PrintTasks(taskManager);
|
int length = PrintTasks(taskManager);
|
||||||
|
|
||||||
TrangaTask[] tasks = taskManager.GetAllTasks();
|
TrangaTask[] tasks = taskManager.GetAllTasks();
|
||||||
Console.WriteLine($"Select Task (0-{length - 1}):");
|
Console.WriteLine($"Select Task (0-{length}):");
|
||||||
|
|
||||||
string? selectedTask = Console.ReadLine();
|
string? selectedTask = Console.ReadLine();
|
||||||
while(selectedTask is null || selectedTask.Length < 1)
|
while(selectedTask is null || selectedTask.Length < 1)
|
||||||
|
@ -20,6 +20,15 @@ public abstract class Connector
|
|||||||
|
|
||||||
protected void DownloadChapter(string[] imageUrls, string saveArchiveFilePath)
|
protected void DownloadChapter(string[] imageUrls, string saveArchiveFilePath)
|
||||||
{
|
{
|
||||||
|
string[] splitPath = saveArchiveFilePath.Split(Path.DirectorySeparatorChar);
|
||||||
|
string directoryPath = Path.Combine(splitPath.Take(splitPath.Length - 1).ToArray());
|
||||||
|
if (!Directory.Exists(directoryPath))
|
||||||
|
Directory.CreateDirectory(directoryPath);
|
||||||
|
|
||||||
|
string fullPath = $"{saveArchiveFilePath}.cbz";
|
||||||
|
if (File.Exists(fullPath))
|
||||||
|
return;
|
||||||
|
|
||||||
string tempFolder = Path.GetTempFileName();
|
string tempFolder = Path.GetTempFileName();
|
||||||
File.Delete(tempFolder);
|
File.Delete(tempFolder);
|
||||||
Directory.CreateDirectory(tempFolder);
|
Directory.CreateDirectory(tempFolder);
|
||||||
@ -32,13 +41,6 @@ public abstract class Connector
|
|||||||
DownloadImage(imageUrl, Path.Join(tempFolder, $"{chapter++}.{extension}"));
|
DownloadImage(imageUrl, Path.Join(tempFolder, $"{chapter++}.{extension}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
string[] splitPath = saveArchiveFilePath.Split(Path.DirectorySeparatorChar);
|
|
||||||
string directoryPath = Path.Combine(splitPath.Take(splitPath.Length - 1).ToArray());
|
|
||||||
if (!Directory.Exists(directoryPath))
|
|
||||||
Directory.CreateDirectory(directoryPath);
|
|
||||||
|
|
||||||
string fullPath = $"{saveArchiveFilePath}.cbz";
|
|
||||||
File.Delete(fullPath);
|
|
||||||
ZipFile.CreateFromDirectory(tempFolder, fullPath);
|
ZipFile.CreateFromDirectory(tempFolder, fullPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
using System.Net;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Text.Json.Nodes;
|
using System.Text.Json.Nodes;
|
||||||
|
|
||||||
@ -21,7 +22,11 @@ public class MangaDex : Connector
|
|||||||
HashSet<Publication> publications = new();
|
HashSet<Publication> publications = new();
|
||||||
while (offset < total)
|
while (offset < total)
|
||||||
{
|
{
|
||||||
DownloadClient.RequestResult requestResult = _downloadClient.MakeRequest($"https://api.mangadex.org/manga?limit={limit}&title={publicationTitle}&offset={offset}");
|
DownloadClient.RequestResult requestResult =
|
||||||
|
_downloadClient.MakeRequest(
|
||||||
|
$"https://api.mangadex.org/manga?limit={limit}&title={publicationTitle}&offset={offset}");
|
||||||
|
if (requestResult.statusCode != HttpStatusCode.OK)
|
||||||
|
break;
|
||||||
JsonObject? result = JsonSerializer.Deserialize<JsonObject>(requestResult.result);
|
JsonObject? result = JsonSerializer.Deserialize<JsonObject>(requestResult.result);
|
||||||
offset += limit;
|
offset += limit;
|
||||||
if (result is null)
|
if (result is null)
|
||||||
@ -121,7 +126,10 @@ public class MangaDex : Connector
|
|||||||
while (offset < total)
|
while (offset < total)
|
||||||
{
|
{
|
||||||
DownloadClient.RequestResult requestResult =
|
DownloadClient.RequestResult requestResult =
|
||||||
_downloadClient.MakeRequest($"https://api.mangadex.org/manga/{id}/feed?limit={limit}&offset={offset}&translatedLanguage%5B%5D={language}");
|
_downloadClient.MakeRequest(
|
||||||
|
$"https://api.mangadex.org/manga/{id}/feed?limit={limit}&offset={offset}&translatedLanguage%5B%5D={language}");
|
||||||
|
if (requestResult.statusCode != HttpStatusCode.OK)
|
||||||
|
break;
|
||||||
JsonObject? result = JsonSerializer.Deserialize<JsonObject>(requestResult.result);
|
JsonObject? result = JsonSerializer.Deserialize<JsonObject>(requestResult.result);
|
||||||
|
|
||||||
offset += limit;
|
offset += limit;
|
||||||
@ -163,6 +171,8 @@ public class MangaDex : Connector
|
|||||||
{
|
{
|
||||||
DownloadClient.RequestResult requestResult =
|
DownloadClient.RequestResult requestResult =
|
||||||
_downloadClient.MakeRequest($"https://api.mangadex.org/at-home/server/{chapter.url}?forcePort443=false'");
|
_downloadClient.MakeRequest($"https://api.mangadex.org/at-home/server/{chapter.url}?forcePort443=false'");
|
||||||
|
if (requestResult.statusCode != HttpStatusCode.OK)
|
||||||
|
return;
|
||||||
JsonObject? result = JsonSerializer.Deserialize<JsonObject>(requestResult.result);
|
JsonObject? result = JsonSerializer.Deserialize<JsonObject>(requestResult.result);
|
||||||
if (result is null)
|
if (result is null)
|
||||||
return;
|
return;
|
||||||
@ -188,12 +198,16 @@ public class MangaDex : Connector
|
|||||||
public override void DownloadCover(Publication publication)
|
public override void DownloadCover(Publication publication)
|
||||||
{
|
{
|
||||||
string publicationPath = Path.Join(downloadLocation, publication.folderName);
|
string publicationPath = Path.Join(downloadLocation, publication.folderName);
|
||||||
DirectoryInfo dirInfo = new DirectoryInfo(publicationPath);
|
Directory.CreateDirectory(publicationPath);
|
||||||
|
DirectoryInfo dirInfo = new (publicationPath);
|
||||||
foreach(FileInfo fileInfo in dirInfo.EnumerateFiles())
|
foreach(FileInfo fileInfo in dirInfo.EnumerateFiles())
|
||||||
if (fileInfo.Name.Contains("cover."))
|
if (fileInfo.Name.Contains("cover."))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
DownloadClient.RequestResult requestResult = _downloadClient.MakeRequest($"https://api.mangadex.org/cover/{publication.posterUrl}");
|
DownloadClient.RequestResult requestResult =
|
||||||
|
_downloadClient.MakeRequest($"https://api.mangadex.org/cover/{publication.posterUrl}");
|
||||||
|
if (requestResult.statusCode != HttpStatusCode.OK)
|
||||||
|
return;
|
||||||
JsonObject? result = JsonSerializer.Deserialize<JsonObject>(requestResult.result);
|
JsonObject? result = JsonSerializer.Deserialize<JsonObject>(requestResult.result);
|
||||||
if (result is null)
|
if (result is null)
|
||||||
return;
|
return;
|
||||||
|
@ -44,6 +44,8 @@ public class TaskManager
|
|||||||
if (!_allTasks.Any(trangaTask => trangaTask.task != task && trangaTask.connectorName != connector.name &&
|
if (!_allTasks.Any(trangaTask => trangaTask.task != task && trangaTask.connectorName != connector.name &&
|
||||||
trangaTask.publication?.downloadUrl != publication?.downloadUrl))
|
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(new TrangaTask(connector.name, task, publication, reoccurrence, language));
|
||||||
ExportTasks(Directory.GetCurrentDirectory());
|
ExportTasks(Directory.GetCurrentDirectory());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user