Skip to content

Commit d6babf5

Browse files
committed
refactor(totletheyn): Cleanup
1 parent b7ac0dc commit d6babf5

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

src/Moss.NET.Sdk/Core/Base64.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,8 @@ public override string ToString()
8282
{
8383
return Convert.ToBase64String(strm.ToArray());
8484
}
85+
86+
public string Decode() {
87+
return new StreamReader(strm).ReadToEnd();
88+
}
8589
}

src/Plugins/Totletheyn/Core/Issue.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
namespace Totletheyn.Core;
1+
using System;
2+
3+
namespace Totletheyn.Core;
24

35
public record Issue(string Title, string PdfUrl);

src/Plugins/Totletheyn/Crawlers/FrauenhoferCrawler.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,17 @@ public class FrauenhoferCrawler : ICrawler
1212
public const string Name = "frauenhofer";
1313

1414
private readonly RestTemplate template = new();
15-
private HtmlDocument document = new();
15+
private readonly HtmlDocument document = new();
1616

1717

1818
public FrauenhoferCrawler()
1919
{
20-
Base64 content = template.Exchange("https://www.fraunhofer.de/de/mediathek/publikationen/fraunhofer-magazin.html").Body;
21-
document.LoadHtml(content.Decode());
20+
var content = template
21+
.Exchange("https://www.fraunhofer.de/de/mediathek/publikationen/fraunhofer-magazin.html")
22+
.Body
23+
.ReadString();
24+
25+
document.LoadHtml(content);
2226
}
2327

2428
public bool IsNewIssueAvailable()

src/Plugins/Totletheyn/Jobs/CrawlerJob.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public override void Init()
2525

2626
inboxId = MossConfig.Get<string>("inbox");
2727

28-
foreach (var crawler in Options.providers)
28+
foreach (var crawler in (string[])Options.providers)
2929
{
3030
_crawlers.Add(_activator.Create(crawler));
3131
}
@@ -49,9 +49,9 @@ public override void Run()
4949
Logger.Info($"CrawlerJob has {issues.Count} new issues");
5050
foreach (var issue in issues)
5151
{
52-
Logger.Info($"downloading {issue}");
52+
Logger.Info($"downloading {issue.Title}");
5353
Base64 content = template.Exchange(issue.PdfUrl).Body;
54-
Logger.Info($"uploading {issue}");
54+
Logger.Info($"uploading {issue.Title}");
5555

5656
var pdf = new PdfNotebook(issue.Title, content, inboxId);
5757
pdf.Upload();

0 commit comments

Comments
 (0)