Skip to content

Commit 83b544c

Browse files
committed
Add Website Examples
1 parent 90804b1 commit 83b544c

File tree

5 files changed

+2402
-10
lines changed

5 files changed

+2402
-10
lines changed

UnitTest/DownloadTest.cs

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using DownloadAssistant.Request;
22
using Requests;
3+
using System.Diagnostics;
34
using WebsiteScraper.Downloadable.Books;
45
using WebsiteScraper.WebsiteUtilities;
56

@@ -8,7 +9,7 @@ namespace UnitTest
89
[TestClass]
910
public class DownloadTest
1011
{
11-
private const string _pathToWebsite = @"D:\Bibliothek\Visual Studio\Librarys\WebsiteScraper\mangaread.org.wsf";
12+
private string _pathToWebsite = @$"{Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.Parent.FullName}\Websites\mangaread.org.wsf";
1213

1314
private Website _mangaread = null!;
1415

@@ -21,12 +22,29 @@ public void Initialize()
2122
[TestMethod]
2223
public async Task SearchAsync()
2324
{
24-
_mangaread.ItemsPerSearch = 20;
25+
_mangaread.ItemsPerSearch = 10;
2526
await _mangaread.GetStatusTask();
26-
Comic[] searchComics = await _mangaread.SearchAsync<Comic>("isekai");
27-
Console.WriteLine("Comics found: " + searchComics.Length);
28-
for (int i = 0; i < searchComics.Length; i++)
29-
Console.WriteLine($"{i} | {searchComics[i].Title}");
27+
SearchInfo searchinfo = new("isekai", _mangaread);
28+
searchinfo.EnableAbleTags["action"].State = EnableAbleState.Enabled;
29+
searchinfo.EnableAbleTags["comedy"].State = EnableAbleState.Enabled;
30+
searchinfo.RadioTags["genres condition"].EnabledKey = "and";
31+
List<Comic> searchComics = new();
32+
searchComics.AddRange(await _mangaread.SearchAsync<Comic>(searchinfo));
33+
searchComics.AddRange(await _mangaread.SearchNextAsync<Comic>());
34+
Console.WriteLine("Comics found: " + searchComics.Count);
35+
for (int i = 0; i < searchComics.Count; i++)
36+
{
37+
Console.WriteLine($"{i} | Title {searchComics[i].Title}");
38+
Console.WriteLine($"{i} | Genres {string.Join("; ", searchComics[i].Genres)}");
39+
Console.WriteLine($"{i} | Alternative titles{string.Join("; ", searchComics[i].AlternativeTitles)}");
40+
Console.WriteLine($"{i} | Description: {searchComics[i].Description}");
41+
Console.WriteLine($"{i} | Status: {searchComics[i].Status}");
42+
Console.WriteLine($"{i} | Author: {searchComics[i].Author}");
43+
Console.WriteLine($"{i} | Cover url: {searchComics[i].CoverUrl}");
44+
Console.WriteLine($"{i} | Last updated: {searchComics[i].LastUpdated}");
45+
Console.WriteLine($"{i} | Url: {searchComics[i].Url}");
46+
Console.WriteLine("");
47+
}
3048
}
3149

3250
[TestMethod]
@@ -35,9 +53,25 @@ public async Task UpdateTestAsync()
3553
await _mangaread.GetStatusTask();
3654
Comic onePunch = new("https://www.mangaread.org/manga/one-punch-man-onepunchman/", "One Punch Man", _mangaread);
3755
await onePunch.UpdateAsync();
38-
Console.WriteLine(onePunch.Title);
39-
Console.WriteLine(onePunch.Chapter.Length + " Chapters");
40-
Console.WriteLine("Description: " + onePunch.Description);
56+
Console.WriteLine($"Title {onePunch.Title}");
57+
Console.WriteLine($"Alternative titles: {string.Join("; ", onePunch.AlternativeTitles)}");
58+
Console.WriteLine($"Description: {string.Join("; ", onePunch.Genres)}");
59+
Console.WriteLine($"Status: {onePunch.Status}");
60+
Console.WriteLine($"Author: {onePunch.Author}");
61+
Console.WriteLine($"Chapter lenght: {onePunch.Chapter.Length}");
62+
Console.WriteLine($"Last updated: {onePunch.LastUpdated}");
63+
Console.WriteLine($"Cover url: {onePunch.CoverUrl}");
64+
Console.WriteLine($"Url: {onePunch.Url}");
65+
}
66+
67+
[TestMethod]
68+
public async Task TestHomeAsync()
69+
{
70+
await _mangaread.GetStatusTask();
71+
Comic[] newComic = await _mangaread.LoadNewAsync<Comic>();
72+
Console.WriteLine($"Found {newComic.Length} new Comics");
73+
Comic[] rComic = await _mangaread.LoadExtraAsync<Comic>("Recommended");
74+
Console.WriteLine($"Found {rComic.Length} new Comics");
4175
}
4276

4377
[TestMethod]
@@ -46,7 +80,7 @@ public async Task DownloadTestAsync()
4680
await _mangaread.GetStatusTask();
4781
Comic onePunch = new("https://www.mangaread.org/manga/one-punch-man-onepunchman/", "One Punch Man", _mangaread);
4882
await onePunch.UpdateAsync();
49-
ProgressableContainer<LoadRequest> container = await onePunch.Chapter.First().DownloadAsync(@"D:\Bibliothek\Downloads\One Punch Man\1\");
83+
ProgressableContainer<LoadRequest> container = await onePunch.Chapter.First().DownloadAsync(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\One Punch Man\1\");
5084
container.StateChanged += (s, e) => Console.WriteLine("State: " + e);
5185
await container.Task;
5286
Console.WriteLine("Downloaded");

0 commit comments

Comments
 (0)