2
0

Added API: customFolderName to Jobs/MonitorManga and Jobs/DownloadNewChapters

resolves #30
This commit is contained in:
glax 2023-09-05 19:50:56 +02:00
parent 384e4c4f43
commit ae1184320f
2 changed files with 19 additions and 2 deletions

View File

@ -28,7 +28,7 @@ public struct Manga
public string? originalLanguage { get; } public string? originalLanguage { get; }
// ReSharper disable once MemberCanBePrivate.Global // ReSharper disable once MemberCanBePrivate.Global
public string status { get; } public string status { get; }
public string folderName { get; } public string folderName { get; private set; }
public string publicationId { get; } public string publicationId { get; }
public string internalId { get; } public string internalId { get; }
public float ignoreChaptersBelow { get; set; } public float ignoreChaptersBelow { get; set; }
@ -73,6 +73,15 @@ public struct Manga
return publicationFolder; return publicationFolder;
} }
public void MovePublicationFolder(string downloadDirectory, string newFolderName)
{
string oldPath = Path.Join(downloadDirectory, this.folderName);
this.folderName = newFolderName;
string newPath = CreatePublicationFolder(downloadDirectory);
if(Directory.Exists(oldPath))
Directory.Move(oldPath, newPath);
}
public void SaveSeriesInfoJson(string downloadDirectory) public void SaveSeriesInfoJson(string downloadDirectory)
{ {
string publicationFolder = CreatePublicationFolder(downloadDirectory); string publicationFolder = CreatePublicationFolder(downloadDirectory);

View File

@ -222,7 +222,7 @@ public class Server : GlobalBase
private void HandlePost(HttpListenerRequest request, HttpListenerResponse response) private void HandlePost(HttpListenerRequest request, HttpListenerResponse response)
{ {
Dictionary<string, string> requestVariables = GetRequestVariables(request.Url!.Query); Dictionary<string, string> requestVariables = GetRequestVariables(request.Url!.Query);
string? connectorName, internalId, jobId, chapterNumStr; string? connectorName, internalId, jobId, chapterNumStr, customFolderName;
MangaConnector connector; MangaConnector connector;
Manga manga; Manga manga;
Job? job; Job? job;
@ -251,6 +251,10 @@ public class Server : GlobalBase
} }
manga.ignoreChaptersBelow = chapterNum; manga.ignoreChaptersBelow = chapterNum;
} }
if (requestVariables.TryGetValue("customFolderName", out customFolderName))
manga.MovePublicationFolder(settings.downloadLocation, customFolderName);
_parent.jobBoss.AddJob(new DownloadNewChapters(this, connector, manga, true, interval)); _parent.jobBoss.AddJob(new DownloadNewChapters(this, connector, manga, true, interval));
SendResponse(HttpStatusCode.Accepted, response); SendResponse(HttpStatusCode.Accepted, response);
break; break;
@ -274,6 +278,10 @@ public class Server : GlobalBase
} }
manga.ignoreChaptersBelow = chapterNum; manga.ignoreChaptersBelow = chapterNum;
} }
if (requestVariables.TryGetValue("customFolderName", out customFolderName))
manga.MovePublicationFolder(settings.downloadLocation, customFolderName);
_parent.jobBoss.AddJob(new DownloadNewChapters(this, connector, manga, false)); _parent.jobBoss.AddJob(new DownloadNewChapters(this, connector, manga, false));
SendResponse(HttpStatusCode.Accepted, response); SendResponse(HttpStatusCode.Accepted, response);
break; break;