2013-05-17 03:03:52 +00:00
|
|
|
using System.IO;
|
|
|
|
using NzbDrone.Common;
|
2013-06-28 00:04:52 +00:00
|
|
|
using NzbDrone.Common.EnvironmentInfo;
|
2013-05-17 03:03:52 +00:00
|
|
|
|
|
|
|
namespace NzbDrone.Api.Frontend
|
|
|
|
{
|
|
|
|
public class MediaCoverMapper : IMapHttpRequestsToDisk
|
|
|
|
{
|
2013-06-28 00:04:52 +00:00
|
|
|
private readonly IAppDirectoryInfo _appDirectoryInfo;
|
2013-05-17 03:03:52 +00:00
|
|
|
|
2013-06-28 00:04:52 +00:00
|
|
|
public MediaCoverMapper(IAppDirectoryInfo appDirectoryInfo)
|
2013-05-17 03:03:52 +00:00
|
|
|
{
|
2013-06-28 00:04:52 +00:00
|
|
|
_appDirectoryInfo = appDirectoryInfo;
|
2013-05-17 03:03:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public string Map(string resourceUrl)
|
|
|
|
{
|
|
|
|
var path = resourceUrl.Replace('/', Path.DirectorySeparatorChar);
|
|
|
|
path = path.Trim(Path.DirectorySeparatorChar).ToLower();
|
|
|
|
|
2013-06-28 00:04:52 +00:00
|
|
|
return Path.Combine(_appDirectoryInfo.GetAppDataPath(), path);
|
2013-05-17 03:03:52 +00:00
|
|
|
}
|
|
|
|
|
2013-05-18 01:18:02 +00:00
|
|
|
public bool CanHandle(string resourceUrl)
|
|
|
|
{
|
|
|
|
return resourceUrl.StartsWith("/mediacover");
|
|
|
|
}
|
2013-05-17 03:03:52 +00:00
|
|
|
}
|
|
|
|
}
|