2013-05-17 05:03:52 +02:00
|
|
|
using System.IO;
|
|
|
|
using NzbDrone.Common;
|
2013-06-28 02:04:52 +02:00
|
|
|
using NzbDrone.Common.EnvironmentInfo;
|
2013-05-17 05:03:52 +02:00
|
|
|
|
|
|
|
namespace NzbDrone.Api.Frontend
|
|
|
|
{
|
|
|
|
public class MediaCoverMapper : IMapHttpRequestsToDisk
|
|
|
|
{
|
2013-07-05 06:43:28 +02:00
|
|
|
private readonly IAppFolderInfo _appFolderInfo;
|
2013-05-17 05:03:52 +02:00
|
|
|
|
2013-07-05 06:43:28 +02:00
|
|
|
public MediaCoverMapper(IAppFolderInfo appFolderInfo)
|
2013-05-17 05:03:52 +02:00
|
|
|
{
|
2013-07-05 06:43:28 +02:00
|
|
|
_appFolderInfo = appFolderInfo;
|
2013-05-17 05:03:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public string Map(string resourceUrl)
|
|
|
|
{
|
|
|
|
var path = resourceUrl.Replace('/', Path.DirectorySeparatorChar);
|
2013-07-24 08:26:10 +02:00
|
|
|
path = path.Trim(Path.DirectorySeparatorChar);
|
2013-05-17 05:03:52 +02:00
|
|
|
|
2013-07-05 06:43:28 +02:00
|
|
|
return Path.Combine(_appFolderInfo.GetAppDataPath(), path);
|
2013-05-17 05:03:52 +02:00
|
|
|
}
|
|
|
|
|
2013-05-18 03:18:02 +02:00
|
|
|
public bool CanHandle(string resourceUrl)
|
|
|
|
{
|
2013-07-24 08:26:10 +02:00
|
|
|
return resourceUrl.StartsWith("/MediaCover");
|
2013-05-18 03:18:02 +02:00
|
|
|
}
|
2013-05-17 05:03:52 +02:00
|
|
|
}
|
|
|
|
}
|