Rename Connector.SearchChapters -> SelectChapters
Added "a(ll)"-option to SelectChapters
This commit is contained in:
parent
2833b7f22a
commit
b3e1d39d0f
@ -182,7 +182,7 @@ public class RequestHandler
|
|||||||
if (publication2 is null)
|
if (publication2 is null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
IEnumerable<Chapter> toDownload = connector2.SearchChapters((Publication)publication2, chapters, language2 ?? "en");
|
IEnumerable<Chapter> toDownload = connector2.SelectChapters((Publication)publication2, chapters, language2 ?? "en");
|
||||||
foreach(Chapter chapter in toDownload)
|
foreach(Chapter chapter in toDownload)
|
||||||
_taskManager.AddTask(new DownloadChapterTask(connectorName2, (Publication)publication2, chapter, "en"));
|
_taskManager.AddTask(new DownloadChapterTask(connectorName2, (Publication)publication2, chapter, "en"));
|
||||||
break;
|
break;
|
||||||
|
@ -514,7 +514,7 @@ public static class Tranga_Cli
|
|||||||
while(selectedChapters is null || selectedChapters.Length < 1)
|
while(selectedChapters is null || selectedChapters.Length < 1)
|
||||||
selectedChapters = Console.ReadLine();
|
selectedChapters = Console.ReadLine();
|
||||||
|
|
||||||
return connector.SearchChapters(publication, selectedChapters);
|
return connector.SelectChapters(publication, selectedChapters);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Connector? SelectConnector(Connector[] connectors, Logger logger)
|
private static Connector? SelectConnector(Connector[] connectors, Logger logger)
|
||||||
|
@ -48,13 +48,14 @@ public abstract class Connector
|
|||||||
/// <returns>Array of Chapters matching Publication and Language</returns>
|
/// <returns>Array of Chapters matching Publication and Language</returns>
|
||||||
public abstract Chapter[] GetChapters(Publication publication, string language = "");
|
public abstract Chapter[] GetChapters(Publication publication, string language = "");
|
||||||
|
|
||||||
public Chapter[] SearchChapters(Publication publication, string searchTerm, string? language = null)
|
public Chapter[] SelectChapters(Publication publication, string searchTerm, string? language = null)
|
||||||
{
|
{
|
||||||
Chapter[] availableChapters = this.GetChapters(publication, language??"en");
|
Chapter[] availableChapters = this.GetChapters(publication, language??"en");
|
||||||
Regex volumeRegex = new ("((v(ol)*(olume)*)+ *([0-9]+(-[0-9]+)?){1})", RegexOptions.IgnoreCase);
|
Regex volumeRegex = new ("((v(ol)*(olume)*)+ *([0-9]+(-[0-9]+)?){1})", RegexOptions.IgnoreCase);
|
||||||
Regex chapterRegex = new ("((c(h)*(hapter)*)+ *([0-9]+(-[0-9]+)?){1})", RegexOptions.IgnoreCase);
|
Regex chapterRegex = new ("((c(h)*(hapter)*)+ *([0-9]+(-[0-9]+)?){1})", RegexOptions.IgnoreCase);
|
||||||
Regex singleResultRegex = new("([0-9]+)", RegexOptions.IgnoreCase);
|
Regex singleResultRegex = new("([0-9]+)", RegexOptions.IgnoreCase);
|
||||||
Regex rangeResultRegex = new("([0-9]+(-[0-9]+))", RegexOptions.IgnoreCase);
|
Regex rangeResultRegex = new("([0-9]+(-[0-9]+))", RegexOptions.IgnoreCase);
|
||||||
|
Regex allRegex = new("a(ll)?", RegexOptions.IgnoreCase);
|
||||||
if (volumeRegex.IsMatch(searchTerm) && chapterRegex.IsMatch(searchTerm))
|
if (volumeRegex.IsMatch(searchTerm) && chapterRegex.IsMatch(searchTerm))
|
||||||
{
|
{
|
||||||
string volume = singleResultRegex.Match(volumeRegex.Match(searchTerm).Value).Value;
|
string volume = singleResultRegex.Match(volumeRegex.Match(searchTerm).Value).Value;
|
||||||
@ -115,6 +116,8 @@ public abstract class Connector
|
|||||||
}
|
}
|
||||||
else if(singleResultRegex.IsMatch(searchTerm))
|
else if(singleResultRegex.IsMatch(searchTerm))
|
||||||
return new [] { availableChapters[Convert.ToInt32(searchTerm)] };
|
return new [] { availableChapters[Convert.ToInt32(searchTerm)] };
|
||||||
|
else if (allRegex.IsMatch(searchTerm))
|
||||||
|
return availableChapters;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Array.Empty<Chapter>();
|
return Array.Empty<Chapter>();
|
||||||
|
Loading…
Reference in New Issue
Block a user