shoko/Protocols/ResProtoHandler.cs

34 lines
687 B
C#

using System.Reflection;
using System.Web;
using HeyRed.Mime;
namespace Shoko;
[Protocol("res")]
class ResProtoHandler : ProtoHandler
{
public ResProtoHandler(Uri url)
{
URL = url;
}
public override void Load()
{
var path = HttpUtility.HtmlDecode(new UriBuilder(URL).Path);
Status = "OK";
Loaded = true;
try
{
Content = Assembly.GetExecutingAssembly().GetManifestResourceStream(path);
MediaType = MimeGuesser.GuessMimeType(Content);
}
catch
{
Status = "not found";
Loaded = false;
}
}
public override void Render()
{
}
}