diff options
| author | Jake Mannens <jake@asger.xyz> | 2023-09-26 00:26:07 +1000 |
|---|---|---|
| committer | Jake Mannens <jakem_5@hotmail.com> | 2026-01-14 21:19:38 +1100 |
| commit | ae8a4ba476664801f243bca1fc6cd89d99ae7da8 (patch) | |
| tree | e648bff54c7446089c52c89c0ae3b63b730153ca /Services/SourceService.cs | |
| parent | 09b54d55a54322633c940c63758f18712ebc65ae (diff) | |
Added filename source decoding
Diffstat (limited to 'Services/SourceService.cs')
| -rw-r--r-- | Services/SourceService.cs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Services/SourceService.cs b/Services/SourceService.cs new file mode 100644 index 0000000..d145346 --- /dev/null +++ b/Services/SourceService.cs @@ -0,0 +1,20 @@ +using System.Text.RegularExpressions; + +namespace HyperBooru.Services; + +public interface ISourceService { + public string? GetUrlFromFilename(string filename); +} + +public class SourceService : ISourceService { + private Regex PixivRegex = + new(@"^([0-9]+)_p[0-9]+(_master1200)?\.[^.]+$", RegexOptions.Compiled); + + public string? GetUrlFromFilename(string filename) { + var pixivMatch = PixivRegex.Match(filename); + if(pixivMatch.Success) + return $"https://pixiv.net/en/artworks/{pixivMatch.Groups[1].Value}"; + + return null; + } +} |
