2013-05-16 20:03:52 -07:00
|
|
|
using System.IO;
|
2013-08-19 23:23:36 -07:00
|
|
|
using NLog;
|
2013-05-16 20:03:52 -07:00
|
|
|
using NzbDrone.Common;
|
2013-06-27 17:04:52 -07:00
|
|
|
using NzbDrone.Common.EnvironmentInfo;
|
2013-05-16 20:03:52 -07:00
|
|
|
|
2013-08-19 19:31:26 -07:00
|
|
|
namespace NzbDrone.Api.Frontend.Mappers
|
2013-05-16 20:03:52 -07:00
|
|
|
{
|
2013-08-19 23:23:36 -07:00
|
|
|
public class MediaCoverMapper : StaticResourceMapperBase
|
2013-05-16 20:03:52 -07:00
|
|
|
{
|
2013-07-04 21:43:28 -07:00
|
|
|
private readonly IAppFolderInfo _appFolderInfo;
|
2013-05-16 20:03:52 -07:00
|
|
|
|
2013-08-19 23:23:36 -07:00
|
|
|
public MediaCoverMapper(IAppFolderInfo appFolderInfo, IDiskProvider diskProvider, Logger logger)
|
|
|
|
: base(diskProvider, logger)
|
2013-05-16 20:03:52 -07:00
|
|
|
{
|
2013-07-04 21:43:28 -07:00
|
|
|
_appFolderInfo = appFolderInfo;
|
2013-05-16 20:03:52 -07:00
|
|
|
}
|
|
|
|
|
2013-08-19 23:23:36 -07:00
|
|
|
protected override string Map(string resourceUrl)
|
2013-05-16 20:03:52 -07:00
|
|
|
{
|
|
|
|
var path = resourceUrl.Replace('/', Path.DirectorySeparatorChar);
|
2013-07-23 23:26:10 -07:00
|
|
|
path = path.Trim(Path.DirectorySeparatorChar);
|
2013-05-16 20:03:52 -07:00
|
|
|
|
2013-07-04 21:43:28 -07:00
|
|
|
return Path.Combine(_appFolderInfo.GetAppDataPath(), path);
|
2013-05-16 20:03:52 -07:00
|
|
|
}
|
|
|
|
|
2013-08-19 23:23:36 -07:00
|
|
|
public override bool CanHandle(string resourceUrl)
|
2013-05-17 18:18:02 -07:00
|
|
|
{
|
2013-07-23 23:26:10 -07:00
|
|
|
return resourceUrl.StartsWith("/MediaCover");
|
2013-05-17 18:18:02 -07:00
|
|
|
}
|
2013-05-16 20:03:52 -07:00
|
|
|
}
|
|
|
|
}
|