Skip to content

Commit

Permalink
level scraper update
Browse files Browse the repository at this point in the history
  • Loading branch information
zblesk committed Apr 15, 2023
1 parent e28b011 commit 1594f9b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions Ghoplin/LevelService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public async Task<JNote> FetchIssue(int level)
var artikel = document.QuerySelector("#post-content-article")?.InnerText.Trim();
artikel = Regex.Replace(artikel, @"POZOR! POKUD SI.+ ZDARMA!\)", "")

Check warning on line 85 in Ghoplin/LevelService.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference argument for parameter 'input' in 'string Regex.Replace(string input, string pattern, string replacement)'.

Check warning on line 85 in Ghoplin/LevelService.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference argument for parameter 'input' in 'string Regex.Replace(string input, string pattern, string replacement)'.

Check warning on line 85 in Ghoplin/LevelService.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference argument for parameter 'input' in 'string Regex.Replace(string input, string pattern, string replacement)'.

Check warning on line 85 in Ghoplin/LevelService.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference argument for parameter 'input' in 'string Regex.Replace(string input, string pattern, string replacement)'.
.Replace(new string(new char[] { '\uFEFF' }), "");
artikel = Regex.Replace(artikel, @"Starší čísla .+send.cz", "");

var obrazok = document.QuerySelector(".attachment-post-thumb").OuterHtml;

Expand Down Expand Up @@ -115,14 +116,13 @@ public async Task<JNote> FetchIssue(int level)
var nadpis = info?[0];
var autor = info?[1];
noteText.Append($"<h2>{nadpis}</h2>");
noteText.AppendLine($"Autor: {autor}");
if (!string.IsNullOrWhiteSpace(autor))
noteText.AppendLine($"<i>Autor: {autor}</i>");
}
noteText.AppendLine();
}

var note = noteText.ToString().Trim();
note = note.Replace("\n", "<br />\n");
note.Dump();

var n = (new JNote
{
Expand All @@ -132,6 +132,11 @@ public async Task<JNote> FetchIssue(int level)
parent_id = _config.NotebookId
});
var joplinNote = await _joplin.Add(n);
joplinNote.body = Regex.Replace(joplinNote!.body!, @"## (.+)\n+\*Autor:", "## $1\n*Autor:",
RegexOptions.IgnoreCase
| RegexOptions.Multiline
| RegexOptions.CultureInvariant);
await _joplin.Update(joplinNote);
return joplinNote;
}
}

0 comments on commit 1594f9b

Please sign in to comment.