Compare commits
No commits in common. "9ccba6fba683bb40e438e493714f63c3b725dc28" and "0a51e7ad3d1e5320b6da67da9a814b9f8c53efb8" have entirely different histories.
9ccba6fba6
...
0a51e7ad3d
@ -80,16 +80,12 @@ public class RequestHandler
|
|||||||
private Dictionary<string, string> GetRequestVariables(string query)
|
private Dictionary<string, string> GetRequestVariables(string query)
|
||||||
{
|
{
|
||||||
Dictionary<string, string> ret = new();
|
Dictionary<string, string> ret = new();
|
||||||
Regex queryRex = new (@"\?{1}&?([A-z0-9-=]+=[A-z0-9-=]+)+(&[A-z0-9-=]+=[A-z0-9-=]+)*");
|
Regex queryRex = new (@"\?{1}&?([A-z]+=[A-z]+)+(&[A-z]+=[A-z]+)*");
|
||||||
if (!queryRex.IsMatch(query))
|
if (!queryRex.IsMatch(query))
|
||||||
return ret;
|
return ret;
|
||||||
query = query.Substring(1);
|
query = query.Substring(1);
|
||||||
foreach(string kvpair in query.Split('&').Where(str => str.Length>=3 ))
|
foreach(string kvpair in query.Split('&').Where(str => str.Length>=3 ))
|
||||||
{
|
ret.Add(kvpair.Split('=')[0], kvpair.Split('=')[1]);
|
||||||
string var = kvpair.Split('=')[0];
|
|
||||||
string val = kvpair.Substring(var.Length + 1);
|
|
||||||
ret.Add(var, val);
|
|
||||||
}
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,7 +152,7 @@ public class RequestHandler
|
|||||||
_taskManager.GetAvailableConnectors().FirstOrDefault(con => con.Key == connectorName1).Value;
|
_taskManager.GetAvailableConnectors().FirstOrDefault(con => con.Key == connectorName1).Value;
|
||||||
if (connector1 is null)
|
if (connector1 is null)
|
||||||
return;
|
return;
|
||||||
Publication? publication1 = _taskManager.GetAllPublications().FirstOrDefault(pub => pub.internalId == internalId1);
|
Publication? publication1 = _taskManager.GetAllPublications().FirstOrDefault(pub => string.Concat(TrangaSettings.CleanIdRex.Matches(pub.internalId)) == string.Concat(TrangaSettings.CleanIdRex.Matches(internalId1)));
|
||||||
if (publication1 is null)
|
if (publication1 is null)
|
||||||
return;
|
return;
|
||||||
_taskManager.AddTask(new MonitorPublicationTask(connectorName1, (Publication)publication1, TimeSpan.Parse(reoccurrenceTime1), language1 ?? "en"));
|
_taskManager.AddTask(new MonitorPublicationTask(connectorName1, (Publication)publication1, TimeSpan.Parse(reoccurrenceTime1), language1 ?? "en"));
|
||||||
@ -178,7 +174,7 @@ public class RequestHandler
|
|||||||
_taskManager.GetAvailableConnectors().FirstOrDefault(con => con.Key == connectorName2).Value;
|
_taskManager.GetAvailableConnectors().FirstOrDefault(con => con.Key == connectorName2).Value;
|
||||||
if (connector2 is null)
|
if (connector2 is null)
|
||||||
return;
|
return;
|
||||||
Publication? publication2 = _taskManager.GetAllPublications().FirstOrDefault(pub => pub.internalId == internalId2);
|
Publication? publication2 = _taskManager.GetAllPublications().FirstOrDefault(pub => string.Concat(TrangaSettings.CleanIdRex.Matches(pub.internalId)) == string.Concat(TrangaSettings.CleanIdRex.Matches(internalId2)));
|
||||||
if (publication2 is null)
|
if (publication2 is null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -265,7 +261,7 @@ public class RequestHandler
|
|||||||
variables.TryGetValue("internalId", out string? internalId1);
|
variables.TryGetValue("internalId", out string? internalId1);
|
||||||
if(internalId1 is null)
|
if(internalId1 is null)
|
||||||
return _taskManager.GetAllPublications();
|
return _taskManager.GetAllPublications();
|
||||||
return new [] { _taskManager.GetAllPublications().FirstOrDefault(pub => pub.internalId == internalId1) };
|
return new [] { _taskManager.GetAllPublications().FirstOrDefault(pub => string.Concat(TrangaSettings.CleanIdRex.Matches(pub.internalId)) == string.Concat(TrangaSettings.CleanIdRex.Matches(internalId1))) };
|
||||||
case "/Publications/FromConnector":
|
case "/Publications/FromConnector":
|
||||||
variables.TryGetValue("connectorName", out string? connectorName1);
|
variables.TryGetValue("connectorName", out string? connectorName1);
|
||||||
variables.TryGetValue("title", out string? title);
|
variables.TryGetValue("title", out string? title);
|
||||||
@ -292,7 +288,7 @@ public class RequestHandler
|
|||||||
Connector? connector2 = _taskManager.GetAvailableConnectors().FirstOrDefault(con => con.Key == connectorName2).Value;
|
Connector? connector2 = _taskManager.GetAvailableConnectors().FirstOrDefault(con => con.Key == connectorName2).Value;
|
||||||
if (connector2 is null)
|
if (connector2 is null)
|
||||||
return null;
|
return null;
|
||||||
Publication? publication = _taskManager.GetAllPublications().FirstOrDefault(pub => pub.internalId == internalId2);
|
Publication? publication = _taskManager.GetAllPublications().FirstOrDefault(pub => string.Concat(TrangaSettings.CleanIdRex.Matches(pub.internalId)) == string.Concat(TrangaSettings.CleanIdRex.Matches(internalId2)));
|
||||||
if (publication is null)
|
if (publication is null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
@ -187,9 +187,7 @@ public abstract class Connector
|
|||||||
public bool CheckChapterIsDownloaded(Publication publication, Chapter chapter)
|
public bool CheckChapterIsDownloaded(Publication publication, Chapter chapter)
|
||||||
{
|
{
|
||||||
string newFilePath = GetArchiveFilePath(publication, chapter);
|
string newFilePath = GetArchiveFilePath(publication, chapter);
|
||||||
if (!Directory.Exists(Path.Join(downloadLocation, publication.folderName)))
|
FileInfo[] archives = new DirectoryInfo(Path.Join(downloadLocation, publication.folderName)).GetFiles("*.cbz");
|
||||||
return false;
|
|
||||||
FileInfo[] archives = new DirectoryInfo(Path.Join(downloadLocation, publication.folderName)).GetFiles();
|
|
||||||
Regex chapterRex = new(@"(Vol.[0-9]*)*Ch.[0-9]+");
|
Regex chapterRex = new(@"(Vol.[0-9]*)*Ch.[0-9]+");
|
||||||
|
|
||||||
if (File.Exists(newFilePath))
|
if (File.Exists(newFilePath))
|
||||||
|
@ -180,7 +180,7 @@ public class TaskManager
|
|||||||
{
|
{
|
||||||
return _allTasks.Where(mTask =>
|
return _allTasks.Where(mTask =>
|
||||||
mTask is MonitorPublicationTask mpt && mpt.connectorName == connectorName &&
|
mTask is MonitorPublicationTask mpt && mpt.connectorName == connectorName &&
|
||||||
mpt.publication.internalId == internalId);
|
string.Concat(TrangaSettings.CleanIdRex.Matches(mpt.publication.internalId)) == string.Concat(TrangaSettings.CleanIdRex.Matches(internalId)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return _allTasks.Where(tTask =>
|
return _allTasks.Where(tTask =>
|
||||||
@ -200,7 +200,7 @@ public class TaskManager
|
|||||||
{
|
{
|
||||||
return _allTasks.Where(mTask =>
|
return _allTasks.Where(mTask =>
|
||||||
mTask is DownloadChapterTask dct && dct.connectorName == connectorName &&
|
mTask is DownloadChapterTask dct && dct.connectorName == connectorName &&
|
||||||
dct.publication.internalId == internalId &&
|
string.Concat(TrangaSettings.CleanIdRex.Matches(dct.publication.internalId)) == string.Concat(TrangaSettings.CleanIdRex.Matches(internalId)) &&
|
||||||
dct.chapter.sortNumber == chapterSortNumber);
|
dct.chapter.sortNumber == chapterSortNumber);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -16,6 +16,7 @@ public class TrangaSettings
|
|||||||
[JsonIgnore] public string coverImageCache => Path.Join(workingDirectory, "imageCache");
|
[JsonIgnore] public string coverImageCache => Path.Join(workingDirectory, "imageCache");
|
||||||
public HashSet<LibraryManager> libraryManagers { get; }
|
public HashSet<LibraryManager> libraryManagers { get; }
|
||||||
public HashSet<NotificationManager> notificationManagers { get; }
|
public HashSet<NotificationManager> notificationManagers { get; }
|
||||||
|
[JsonIgnore] public static Regex CleanIdRex = new (@"([a-zA-Z0-9]*-*_*)*");
|
||||||
|
|
||||||
public TrangaSettings(string downloadLocation, string workingDirectory, HashSet<LibraryManager>? libraryManagers,
|
public TrangaSettings(string downloadLocation, string workingDirectory, HashSet<LibraryManager>? libraryManagers,
|
||||||
HashSet<NotificationManager>? notificationManagers)
|
HashSet<NotificationManager>? notificationManagers)
|
||||||
|
Loading…
Reference in New Issue
Block a user