blob: d1453465704b924abb67884b4f3f3a62d0c8e675 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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;
}
}
|