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