diff --git a/src/Lidarr.sln b/src/Lidarr.sln
index ba01b4c9c..fa172505c 100644
--- a/src/Lidarr.sln
+++ b/src/Lidarr.sln
@@ -47,8 +47,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{1E6B3C
.nuget\NuGet.exe = .nuget\NuGet.exe
EndProjectSection
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NzbDrone.Api", "NzbDrone.Api\NzbDrone.Api.csproj", "{FD286DF8-2D3A-4394-8AD5-443FADE55FB2}"
-EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Host", "Host", "{486ADF86-DD89-4E19-B805-9D94F19800D9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NzbDrone.Console", "NzbDrone.Console\NzbDrone.Console.csproj", "{3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}"
@@ -185,12 +183,6 @@ Global
{F2BE0FDF-6E47-4827-A420-DD4EF82407F8}.Mono|x86.Build.0 = Release|x86
{F2BE0FDF-6E47-4827-A420-DD4EF82407F8}.Release|x86.ActiveCfg = Release|x86
{F2BE0FDF-6E47-4827-A420-DD4EF82407F8}.Release|x86.Build.0 = Release|x86
- {FD286DF8-2D3A-4394-8AD5-443FADE55FB2}.Debug|x86.ActiveCfg = Debug|x86
- {FD286DF8-2D3A-4394-8AD5-443FADE55FB2}.Debug|x86.Build.0 = Debug|x86
- {FD286DF8-2D3A-4394-8AD5-443FADE55FB2}.Mono|x86.ActiveCfg = Release|x86
- {FD286DF8-2D3A-4394-8AD5-443FADE55FB2}.Mono|x86.Build.0 = Release|x86
- {FD286DF8-2D3A-4394-8AD5-443FADE55FB2}.Release|x86.ActiveCfg = Release|x86
- {FD286DF8-2D3A-4394-8AD5-443FADE55FB2}.Release|x86.Build.0 = Release|x86
{3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Debug|x86.ActiveCfg = Debug|x86
{3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Debug|x86.Build.0 = Debug|x86
{3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Mono|x86.ActiveCfg = Debug|x86
diff --git a/src/NzbDrone.Api.Test/NzbDrone.Api.Test.csproj b/src/NzbDrone.Api.Test/NzbDrone.Api.Test.csproj
index 942e602f3..32ed3c462 100644
--- a/src/NzbDrone.Api.Test/NzbDrone.Api.Test.csproj
+++ b/src/NzbDrone.Api.Test/NzbDrone.Api.Test.csproj
@@ -70,14 +70,14 @@
+
+ {7140ff1f-79be-492f-9188-b21a050bf708}
+ Lidarr.Api.V3
+
{F6FC6BE7-0847-4817-A1ED-223DC647C3D7}
Marr.Data
-
- {FD286DF8-2D3A-4394-8AD5-443FADE55FB2}
- NzbDrone.Api
-
{F2BE0FDF-6E47-4827-A420-DD4EF82407F8}
NzbDrone.Common
diff --git a/src/NzbDrone.Api/AlbumStudio/AlbumStudioModule.cs b/src/NzbDrone.Api/AlbumStudio/AlbumStudioModule.cs
deleted file mode 100644
index 2409d932a..000000000
--- a/src/NzbDrone.Api/AlbumStudio/AlbumStudioModule.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-using Nancy;
-using Lidarr.Http.Extensions;
-using NzbDrone.Core.Music;
-
-namespace NzbDrone.Api.AlbumPass
-{
- public class AlbumStudioModule : NzbDroneApiModule
- {
- private readonly IAlbumMonitoredService _albumMonitoredService;
-
- public AlbumStudioModule(IAlbumMonitoredService albumMonitoredService)
- : base("/albumstudio")
- {
- _albumMonitoredService = albumMonitoredService;
- Post["/"] = artist => UpdateAll();
- }
-
- private Response UpdateAll()
- {
- //Read from request
- var request = Request.Body.FromJson();
-
- foreach (var s in request.Artist)
- {
- _albumMonitoredService.SetAlbumMonitoredStatus(s, request.MonitoringOptions);
- }
-
- return "ok".AsResponse(HttpStatusCode.Accepted);
- }
- }
-}
diff --git a/src/NzbDrone.Api/AlbumStudio/AlbumStudioResource.cs b/src/NzbDrone.Api/AlbumStudio/AlbumStudioResource.cs
deleted file mode 100644
index 1b0779af9..000000000
--- a/src/NzbDrone.Api/AlbumStudio/AlbumStudioResource.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using System.Collections.Generic;
-using NzbDrone.Core.Music;
-
-namespace NzbDrone.Api.AlbumPass
-{
- public class AlbumStudioResource
- {
- public List Artist { get; set; }
- public MonitoringOptions MonitoringOptions { get; set; }
- }
-}
diff --git a/src/NzbDrone.Api/Albums/AlbumModule.cs b/src/NzbDrone.Api/Albums/AlbumModule.cs
deleted file mode 100644
index bf36929a6..000000000
--- a/src/NzbDrone.Api/Albums/AlbumModule.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-using System.Collections.Generic;
-using Lidarr.Http.REST;
-using NzbDrone.Core.Music;
-using NzbDrone.Core.ArtistStats;
-using NzbDrone.Core.DecisionEngine;
-using NzbDrone.SignalR;
-
-namespace NzbDrone.Api.Albums
-{
- public class AlbumModule : AlbumModuleWithSignalR
- {
- public AlbumModule(IArtistService artistService,
- IArtistStatisticsService artistStatisticsService,
- IAlbumService albumService,
- IUpgradableSpecification qualityUpgradableSpecification,
- IBroadcastSignalRMessage signalRBroadcaster)
- : base(albumService, artistStatisticsService, artistService, qualityUpgradableSpecification, signalRBroadcaster)
- {
- GetResourceAll = GetAlbums;
- UpdateResource = SetMonitored;
- }
-
- private List GetAlbums()
- {
- if (!Request.Query.ArtistId.HasValue)
- {
- throw new BadRequestException("artistId is missing");
- }
-
- var artistId = (int)Request.Query.ArtistId;
-
- var resources = MapToResource(_albumService.GetAlbumsByArtist(artistId), false);
-
- return resources;
- }
-
- private void SetMonitored(AlbumResource albumResource)
- {
- _albumService.SetAlbumMonitored(albumResource.Id, albumResource.Monitored);
- }
- }
-}
diff --git a/src/NzbDrone.Api/Albums/AlbumModuleWithSignalR.cs b/src/NzbDrone.Api/Albums/AlbumModuleWithSignalR.cs
deleted file mode 100644
index f799c02ac..000000000
--- a/src/NzbDrone.Api/Albums/AlbumModuleWithSignalR.cs
+++ /dev/null
@@ -1,153 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using FluentValidation;
-using NzbDrone.Common.Extensions;
-using NzbDrone.Api.TrackFiles;
-using NzbDrone.Api.Music;
-using NzbDrone.Core.Datastore.Events;
-using NzbDrone.Core.DecisionEngine;
-using NzbDrone.Core.Download;
-using NzbDrone.Core.MediaFiles.Events;
-using NzbDrone.Core.Messaging.Events;
-using NzbDrone.Core.Music;
-using NzbDrone.Core.ArtistStats;
-using NzbDrone.SignalR;
-using Lidarr.Http;
-
-namespace NzbDrone.Api.Albums
-{
- public abstract class AlbumModuleWithSignalR : LidarrRestModuleWithSignalR
- {
- protected readonly IAlbumService _albumService;
- protected readonly IArtistStatisticsService _artistStatisticsService;
- protected readonly IArtistService _artistService;
- protected readonly IUpgradableSpecification _qualityUpgradableSpecification;
-
- protected AlbumModuleWithSignalR(IAlbumService albumService,
- IArtistStatisticsService artistStatisticsService,
- IArtistService artistService,
- IUpgradableSpecification qualityUpgradableSpecification,
- IBroadcastSignalRMessage signalRBroadcaster)
- : base(signalRBroadcaster)
- {
- _albumService = albumService;
- _artistStatisticsService = artistStatisticsService;
- _artistService = artistService;
- _qualityUpgradableSpecification = qualityUpgradableSpecification;
-
- GetResourceById = GetAlbum;
- }
-
- protected AlbumModuleWithSignalR(IAlbumService albumService,
- IArtistStatisticsService artistStatisticsService,
- IArtistService artistService,
- IUpgradableSpecification qualityUpgradableSpecification,
- IBroadcastSignalRMessage signalRBroadcaster,
- string resource)
- : base(signalRBroadcaster, resource)
- {
- _albumService = albumService;
- _artistStatisticsService = artistStatisticsService;
- _artistService = artistService;
- _qualityUpgradableSpecification = qualityUpgradableSpecification;
-
- GetResourceById = GetAlbum;
- }
-
- protected AlbumResource GetAlbum(int id)
- {
- var album = _albumService.GetAlbum(id);
- var resource = MapToResource(album, true);
- return resource;
- }
-
- protected AlbumResource MapToResource(Album album, bool includeArtist)
- {
- var resource = album.ToResource();
-
- if (includeArtist)
- {
- var artist = album.Artist ?? _artistService.GetArtist(album.ArtistId);
-
- if (includeArtist)
- {
- resource.Artist = artist.ToResource();
- }
- }
-
- FetchAndLinkAlbumStatistics(resource);
-
- return resource;
- }
-
- protected List MapToResource(List albums, bool includeArtist)
- {
- var result = albums.ToResource();
-
- if (includeArtist)
- {
- var artistDict = new Dictionary();
- for (var i = 0; i < albums.Count; i++)
- {
- var album = albums[i];
- var resource = result[i];
-
- var artist = album.Artist ?? artistDict.GetValueOrDefault(albums[i].ArtistId) ?? _artistService.GetArtist(albums[i].ArtistId);
- artistDict[artist.Id] = artist;
-
- if (includeArtist)
- {
- resource.Artist = artist.ToResource();
- }
- }
- }
-
- for (var i = 0; i < albums.Count; i++)
- {
- var resource = result[i];
- FetchAndLinkAlbumStatistics(resource);
- }
-
-
- return result;
- }
-
- private void FetchAndLinkAlbumStatistics(AlbumResource resource)
- {
- LinkArtistStatistics(resource, _artistStatisticsService.ArtistStatistics(resource.ArtistId));
- }
-
- private void LinkArtistStatistics(AlbumResource resource, ArtistStatistics artistStatistics)
- {
- if (artistStatistics.AlbumStatistics != null)
- {
- var dictAlbumStats = artistStatistics.AlbumStatistics.ToDictionary(v => v.AlbumId);
-
- resource.Statistics = dictAlbumStats.GetValueOrDefault(resource.Id).ToResource();
-
- }
- }
-
- //TODO: Implement Track or Album Grabbed/Dowloaded Events
-
- //public void Handle(TrackGrabbedEvent message)
- //{
- // foreach (var track in message.Track.Tracks)
- // {
- // var resource = track.ToResource();
- // resource.Grabbed = true;
-
- // BroadcastResourceChange(ModelAction.Updated, resource);
- // }
- //}
-
- //public void Handle(TrackDownloadedEvent message)
- //{
- // foreach (var album in message.Album.Albums)
- // {
- // BroadcastResourceChange(ModelAction.Updated, album.Id);
- // }
- //}
- }
-}
diff --git a/src/NzbDrone.Api/Albums/AlbumResource.cs b/src/NzbDrone.Api/Albums/AlbumResource.cs
deleted file mode 100644
index 1f500268d..000000000
--- a/src/NzbDrone.Api/Albums/AlbumResource.cs
+++ /dev/null
@@ -1,87 +0,0 @@
-using NzbDrone.Core.Music;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Lidarr.Http.REST;
-using NzbDrone.Api.Music;
-using NzbDrone.Core.MediaCover;
-
-namespace NzbDrone.Api.Albums
-{
- public class AlbumResource : RestResource
- {
-
- public string Title { get; set; }
- public int ArtistId { get; set; }
- public List Label { get; set; }
- public bool Monitored { get; set; }
- public string Path { get; set; }
- public int ProfileId { get; set; }
- public int Duration { get; set; }
- public string AlbumType { get; set; }
- public Ratings Ratings { get; set; }
- public DateTime? ReleaseDate { get; set; }
- public List Genres { get; set; }
- public ArtistResource Artist { get; set; }
- public List Images { get; set; }
- public AlbumStatisticsResource Statistics { get; set; }
-
- }
-
- public static class AlbumResourceMapper
- {
- public static AlbumResource ToResource(this Core.Music.Album model)
- {
- if (model == null) return null;
-
- return new AlbumResource
- {
- Id = model.Id,
- ArtistId = model.ArtistId,
- Label = model.Label,
- Path = model.Path,
- ProfileId = model.ProfileId,
- Monitored = model.Monitored,
- ReleaseDate = model.ReleaseDate,
- Genres = model.Genres,
- Title = model.Title,
- Images = model.Images,
- Ratings = model.Ratings,
- Duration = model.Duration,
- AlbumType = model.AlbumType
- };
- }
-
- public static Album ToModel(this AlbumResource resource)
- {
- if (resource == null) return null;
-
- return new Core.Music.Album
- {
- Id = resource.Id,
- ArtistId = resource.ArtistId,
- Label = resource.Label,
- Path = resource.Path,
- Monitored = resource.Monitored,
- ProfileId = resource.ProfileId,
- ReleaseDate = resource.ReleaseDate,
- Genres = resource.Genres,
- Title = resource.Title,
- Images = resource.Images,
- Ratings = resource.Ratings,
- AlbumType = resource.AlbumType
- };
- }
-
- public static List ToResource(this IEnumerable models)
- {
- return models.Select(ToResource).ToList();
- }
-
- public static List ToModel(this IEnumerable resources)
- {
- return resources?.Select(ToModel).ToList() ?? new List();
- }
- }
-}
diff --git a/src/NzbDrone.Api/Albums/AlbumStatisticsResource.cs b/src/NzbDrone.Api/Albums/AlbumStatisticsResource.cs
deleted file mode 100644
index 13ffb2e4b..000000000
--- a/src/NzbDrone.Api/Albums/AlbumStatisticsResource.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-using System;
-using NzbDrone.Core.ArtistStats;
-
-namespace NzbDrone.Api.Albums
-{
- public class AlbumStatisticsResource
- {
- public int TrackFileCount { get; set; }
- public int TrackCount { get; set; }
- public int TotalTrackCount { get; set; }
- public long SizeOnDisk { get; set; }
-
- public decimal PercentOfTracks
- {
- get
- {
- if (TrackCount == 0)
- {
- return 0;
- }
-
- return (decimal)TrackFileCount / (decimal)TrackCount * 100;
- }
- }
- }
-
- public static class AlbumStatisticsResourceMapper
- {
- public static AlbumStatisticsResource ToResource(this AlbumStatistics model)
- {
- if (model == null)
- {
- return null;
- }
-
- return new AlbumStatisticsResource
- {
- TrackFileCount = model.TrackFileCount,
- TrackCount = model.TrackCount,
- TotalTrackCount = model.TotalTrackCount,
- SizeOnDisk = model.SizeOnDisk
- };
- }
- }
-}
diff --git a/src/NzbDrone.Api/Blacklist/BlacklistModule.cs b/src/NzbDrone.Api/Blacklist/BlacklistModule.cs
deleted file mode 100644
index 6ee093e49..000000000
--- a/src/NzbDrone.Api/Blacklist/BlacklistModule.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-using NzbDrone.Core.Blacklisting;
-using NzbDrone.Core.Datastore;
-using Lidarr.Http;
-
-namespace NzbDrone.Api.Blacklist
-{
- public class BlacklistModule : LidarrRestModule
- {
- private readonly IBlacklistService _blacklistService;
-
- public BlacklistModule(IBlacklistService blacklistService)
- {
- _blacklistService = blacklistService;
- GetResourcePaged = GetBlacklist;
- DeleteResource = DeleteBlacklist;
- }
-
- private PagingResource GetBlacklist(PagingResource pagingResource)
- {
- var pagingSpec = pagingResource.MapToPagingSpec("id", SortDirection.Ascending);
-
- return ApplyToPage(_blacklistService.Paged, pagingSpec, BlacklistResourceMapper.MapToResource);
- }
-
- private void DeleteBlacklist(int id)
- {
- _blacklistService.Delete(id);
- }
- }
-}
diff --git a/src/NzbDrone.Api/Blacklist/BlacklistResource.cs b/src/NzbDrone.Api/Blacklist/BlacklistResource.cs
deleted file mode 100644
index 563f9d95a..000000000
--- a/src/NzbDrone.Api/Blacklist/BlacklistResource.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-using System;
-using System.Collections.Generic;
-using Lidarr.Http.REST;
-using NzbDrone.Core.Qualities;
-using NzbDrone.Api.Music;
-using NzbDrone.Core.Indexers;
-using NzbDrone.Core.Languages;
-
-namespace NzbDrone.Api.Blacklist
-{
- public class BlacklistResource : RestResource
- {
- public int ArtistId { get; set; }
- public List AlbumIds { get; set; }
- public string SourceTitle { get; set; }
- public QualityModel Quality { get; set; }
- public DateTime Date { get; set; }
- public DownloadProtocol Protocol { get; set; }
- public string Indexer { get; set; }
- public string Message { get; set; }
- public Language Language { get; set; }
-
- public ArtistResource Artist { get; set; }
- }
-
- public static class BlacklistResourceMapper
- {
- public static BlacklistResource MapToResource(this Core.Blacklisting.Blacklist model)
- {
- if (model == null) return null;
-
- return new BlacklistResource
- {
- Id = model.Id,
-
- ArtistId = model.ArtistId,
- AlbumIds = model.AlbumIds,
- SourceTitle = model.SourceTitle,
- Quality = model.Quality,
- Date = model.Date,
- Protocol = model.Protocol,
- Indexer = model.Indexer,
- Message = model.Message,
-
- Artist = model.Artist.ToResource()
- };
- }
- }
-}
diff --git a/src/NzbDrone.Api/Calendar/CalendarFeedModule.cs b/src/NzbDrone.Api/Calendar/CalendarFeedModule.cs
deleted file mode 100644
index e65a42833..000000000
--- a/src/NzbDrone.Api/Calendar/CalendarFeedModule.cs
+++ /dev/null
@@ -1,130 +0,0 @@
-using Nancy;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using Ical.Net;
-using Ical.Net.DataTypes;
-using Ical.Net.Interfaces.Serialization;
-using Ical.Net.Serialization;
-using Ical.Net.Serialization.iCalendar.Factory;
-using NzbDrone.Core.Tv;
-using NzbDrone.Core.Music;
-using Nancy.Responses;
-using NzbDrone.Core.Tags;
-using NzbDrone.Common.Extensions;
-
-namespace NzbDrone.Api.Calendar
-{
- public class CalendarFeedModule : NzbDroneFeedModule
- {
- private readonly IAlbumService _albumService;
- private readonly ITagService _tagService;
-
- public CalendarFeedModule(IAlbumService albumService, ITagService tagService)
- : base("calendar")
- {
- _albumService = albumService;
- _tagService = tagService;
-
- Get["/NzbDrone.ics"] = options => GetCalendarFeed();
- Get["/Lidarr.ics"] = options => GetCalendarFeed();
- }
-
- private Response GetCalendarFeed()
- {
- var pastDays = 7;
- var futureDays = 28;
- var start = DateTime.Today.AddDays(-pastDays);
- var end = DateTime.Today.AddDays(futureDays);
- var unmonitored = false;
- var premiersOnly = false;
- var asAllDay = false;
- var tags = new List();
-
- // TODO: Remove start/end parameters in v3, they don't work well for iCal
- var queryStart = Request.Query.Start;
- var queryEnd = Request.Query.End;
- var queryPastDays = Request.Query.PastDays;
- var queryFutureDays = Request.Query.FutureDays;
- var queryUnmonitored = Request.Query.Unmonitored;
- var queryPremiersOnly = Request.Query.PremiersOnly;
- var queryAsAllDay = Request.Query.AsAllDay;
- var queryTags = Request.Query.Tags;
-
- if (queryStart.HasValue) start = DateTime.Parse(queryStart.Value);
- if (queryEnd.HasValue) end = DateTime.Parse(queryEnd.Value);
-
- if (queryPastDays.HasValue)
- {
- pastDays = int.Parse(queryPastDays.Value);
- start = DateTime.Today.AddDays(-pastDays);
- }
-
- if (queryFutureDays.HasValue)
- {
- futureDays = int.Parse(queryFutureDays.Value);
- end = DateTime.Today.AddDays(futureDays);
- }
-
- if (queryUnmonitored.HasValue)
- {
- unmonitored = bool.Parse(queryUnmonitored.Value);
- }
-
- if (queryPremiersOnly.HasValue)
- {
- premiersOnly = bool.Parse(queryPremiersOnly.Value);
- }
-
- if (queryAsAllDay.HasValue)
- {
- asAllDay = bool.Parse(queryAsAllDay.Value);
- }
-
- if (queryTags.HasValue)
- {
- var tagInput = (string)queryTags.Value.ToString();
- tags.AddRange(tagInput.Split(',').Select(_tagService.GetTag).Select(t => t.Id));
- }
-
- var albums = _albumService.AlbumsBetweenDates(start, end, unmonitored);
- var calendar = new Ical.Net.Calendar
- {
- // This will need to point to the hosted web site
- // TODO
- ProductId = "-//lidarr.audio//Lidarr//EN"
- };
-
-
-
- foreach (var album in albums.OrderBy(v => v.ReleaseDate))
- {
- //if (premiersOnly && (album.SeasonNumber == 0 || album.EpisodeNumber != 1))
- //{
- // continue;
- //}
-
- if (tags.Any() && tags.None(album.Artist.Tags.Contains))
- {
- continue;
- }
-
- var occurrence = calendar.Create();
- occurrence.Uid = "NzbDrone_album_" + album.Id;
- //occurrence.Status = album.HasFile ? EventStatus.Confirmed : EventStatus.Tentative;
- //occurrence.Description = album.Overview;
- //occurrence.Categories = new List() { album.Artist. };
-
- occurrence.Start = new CalDateTime(album.ReleaseDate.Value) { HasTime = false };
-
- occurrence.Summary =$"{album.Artist.Name} - {album.Title}";
-
- }
-
- var serializer = (IStringSerializer) new SerializerFactory().Build(calendar.GetType(), new SerializationContext());
- var icalendar = serializer.SerializeToString(calendar);
-
- return new TextResponse(icalendar, "text/calendar");
- }
- }
-}
diff --git a/src/NzbDrone.Api/Calendar/CalendarModule.cs b/src/NzbDrone.Api/Calendar/CalendarModule.cs
deleted file mode 100644
index 5a857c699..000000000
--- a/src/NzbDrone.Api/Calendar/CalendarModule.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using NzbDrone.Api.Episodes;
-using NzbDrone.Api.Albums;
-using NzbDrone.Core.DecisionEngine;
-using NzbDrone.Core.Tv;
-using NzbDrone.Core.Music;
-using NzbDrone.Core.ArtistStats;
-using NzbDrone.SignalR;
-
-namespace NzbDrone.Api.Calendar
-{
- public class CalendarModule : AlbumModuleWithSignalR
- {
- public CalendarModule(IAlbumService albumService,
- IArtistStatisticsService artistStatisticsService,
- IArtistService artistService,
- IUpgradableSpecification upgradableSpecification,
- IBroadcastSignalRMessage signalRBroadcaster)
- : base(albumService, artistStatisticsService, artistService, upgradableSpecification, signalRBroadcaster, "calendar")
- {
- GetResourceAll = GetCalendar;
- }
-
- private List GetCalendar()
- {
- var start = DateTime.Today;
- var end = DateTime.Today.AddDays(2);
- var includeUnmonitored = false;
-
- var queryStart = Request.Query.Start;
- var queryEnd = Request.Query.End;
- var queryIncludeUnmonitored = Request.Query.Unmonitored;
-
- if (queryStart.HasValue) start = DateTime.Parse(queryStart.Value);
- if (queryEnd.HasValue) end = DateTime.Parse(queryEnd.Value);
- if (queryIncludeUnmonitored.HasValue) includeUnmonitored = Convert.ToBoolean(queryIncludeUnmonitored.Value);
-
- var resources = MapToResource(_albumService.AlbumsBetweenDates(start, end, includeUnmonitored), true);
-
- return resources.OrderBy(e => e.ReleaseDate).ToList();
- }
- }
-}
diff --git a/src/NzbDrone.Api/Commands/CommandModule.cs b/src/NzbDrone.Api/Commands/CommandModule.cs
deleted file mode 100644
index ecf2a6f5c..000000000
--- a/src/NzbDrone.Api/Commands/CommandModule.cs
+++ /dev/null
@@ -1,68 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using Lidarr.Http.Extensions;
-using NzbDrone.Common;
-using NzbDrone.Core.Datastore.Events;
-using NzbDrone.Core.Messaging.Commands;
-using NzbDrone.Core.Messaging.Events;
-using NzbDrone.Core.ProgressMessaging;
-using NzbDrone.SignalR;
-using Lidarr.Http;
-using Lidarr.Http.Mapping;
-using Lidarr.Http.Validation;
-
-
-namespace NzbDrone.Api.Commands
-{
- public class CommandModule : LidarrRestModuleWithSignalR, IHandle
- {
- private readonly IManageCommandQueue _commandQueueManager;
- private readonly IServiceFactory _serviceFactory;
-
- public CommandModule(IManageCommandQueue commandQueueManager,
- IBroadcastSignalRMessage signalRBroadcaster,
- IServiceFactory serviceFactory)
- : base(signalRBroadcaster)
- {
- _commandQueueManager = commandQueueManager;
- _serviceFactory = serviceFactory;
-
- GetResourceById = GetCommand;
- CreateResource = StartCommand;
- GetResourceAll = GetStartedCommands;
-
- PostValidator.RuleFor(c => c.Name).NotBlank();
- }
-
- private CommandResource GetCommand(int id)
- {
- return _commandQueueManager.Get(id).ToResource();
- }
-
- private int StartCommand(CommandResource commandResource)
- {
- var commandType = _serviceFactory.GetImplementations(typeof(Command))
- .Single(c => c.Name.Replace("Command", "").Equals(commandResource.Name, StringComparison.InvariantCultureIgnoreCase));
-
- dynamic command = Request.Body.FromJson(commandType);
- command.Trigger = CommandTrigger.Manual;
-
- var trackedCommand = _commandQueueManager.Push(command, CommandPriority.Normal, CommandTrigger.Manual);
- return trackedCommand.Id;
- }
-
- private List GetStartedCommands()
- {
- return _commandQueueManager.GetStarted().ToResource();
- }
-
- public void Handle(CommandUpdatedEvent message)
- {
- if (message.Command.Body.SendUpdatesToClient)
- {
- BroadcastResourceChange(ModelAction.Updated, message.Command.ToResource());
- }
- }
- }
-}
diff --git a/src/NzbDrone.Api/Commands/CommandResource.cs b/src/NzbDrone.Api/Commands/CommandResource.cs
deleted file mode 100644
index 5fd2db0ed..000000000
--- a/src/NzbDrone.Api/Commands/CommandResource.cs
+++ /dev/null
@@ -1,130 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using Newtonsoft.Json;
-using Lidarr.Http.REST;
-using NzbDrone.Core.Messaging.Commands;
-
-namespace NzbDrone.Api.Commands
-{
- public class CommandResource : RestResource
- {
- public string Name { get; set; }
- public string Message { get; set; }
- public object Body { get; set; }
- public CommandPriority Priority { get; set; }
- public CommandStatus Status { get; set; }
- public DateTime Queued { get; set; }
- public DateTime? Started { get; set; }
- public DateTime? Ended { get; set; }
- public TimeSpan? Duration { get; set; }
- public string Exception { get; set; }
- public CommandTrigger Trigger { get; set; }
-
- [JsonIgnore]
- public string CompletionMessage { get; set; }
-
- //Legacy
- public CommandStatus State
- {
- get
- {
- return Status;
- }
-
- set { }
- }
-
- public bool Manual
- {
- get
- {
- return Trigger == CommandTrigger.Manual;
- }
-
- set { }
- }
-
- public DateTime StartedOn
- {
- get
- {
- return Queued;
- }
-
- set { }
- }
-
- public DateTime? StateChangeTime
- {
- get
- {
-
- if (Started.HasValue) return Started.Value;
-
- return Ended;
- }
-
- set { }
- }
-
- public bool SendUpdatesToClient
- {
- get
- {
- if (Body != null) return (Body as Command).SendUpdatesToClient;
-
- return false;
- }
-
- set { }
- }
-
- public bool UpdateScheduledTask
- {
- get
- {
- if (Body != null) return (Body as Command).UpdateScheduledTask;
-
- return false;
- }
-
- set { }
- }
-
- public DateTime? LastExecutionTime { get; set; }
- }
-
- public static class CommandResourceMapper
- {
- public static CommandResource ToResource(this CommandModel model)
- {
- if (model == null) return null;
-
- return new CommandResource
- {
- Id = model.Id,
-
- Name = model.Name,
- Message = model.Message,
- Body = model.Body,
- Priority = model.Priority,
- Status = model.Status,
- Queued = model.QueuedAt,
- Started = model.StartedAt,
- Ended = model.EndedAt,
- Duration = model.Duration,
- Exception = model.Exception,
- Trigger = model.Trigger,
-
- CompletionMessage = model.Body.CompletionMessage,
- LastExecutionTime = model.Body.LastExecutionTime
- };
- }
-
- public static List ToResource(this IEnumerable models)
- {
- return models.Select(ToResource).ToList();
- }
- }
-}
diff --git a/src/NzbDrone.Api/Config/DownloadClientConfigModule.cs b/src/NzbDrone.Api/Config/DownloadClientConfigModule.cs
deleted file mode 100644
index 3e19e7564..000000000
--- a/src/NzbDrone.Api/Config/DownloadClientConfigModule.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using FluentValidation;
-using NzbDrone.Core.Configuration;
-using NzbDrone.Core.Validation.Paths;
-
-namespace NzbDrone.Api.Config
-{
- public class DownloadClientConfigModule : NzbDroneConfigModule
- {
- public DownloadClientConfigModule(IConfigService configService)
- : base(configService)
- {
-
- }
-
- protected override DownloadClientConfigResource ToResource(IConfigService model)
- {
- return DownloadClientConfigResourceMapper.ToResource(model);
- }
- }
-}
diff --git a/src/NzbDrone.Api/Config/DownloadClientConfigResource.cs b/src/NzbDrone.Api/Config/DownloadClientConfigResource.cs
deleted file mode 100644
index 836c4d29a..000000000
--- a/src/NzbDrone.Api/Config/DownloadClientConfigResource.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-using Lidarr.Http.REST;
-using NzbDrone.Core.Configuration;
-
-namespace NzbDrone.Api.Config
-{
- public class DownloadClientConfigResource : RestResource
- {
- public string DownloadClientWorkingFolders { get; set; }
-
- public bool EnableCompletedDownloadHandling { get; set; }
- public bool RemoveCompletedDownloads { get; set; }
-
- public bool AutoRedownloadFailed { get; set; }
- public bool RemoveFailedDownloads { get; set; }
- }
-
- public static class DownloadClientConfigResourceMapper
- {
- public static DownloadClientConfigResource ToResource(IConfigService model)
- {
- return new DownloadClientConfigResource
- {
- DownloadClientWorkingFolders = model.DownloadClientWorkingFolders,
-
- EnableCompletedDownloadHandling = model.EnableCompletedDownloadHandling,
- RemoveCompletedDownloads = model.RemoveCompletedDownloads,
-
- AutoRedownloadFailed = model.AutoRedownloadFailed,
- RemoveFailedDownloads = model.RemoveFailedDownloads
- };
- }
- }
-}
diff --git a/src/NzbDrone.Api/Config/HostConfigModule.cs b/src/NzbDrone.Api/Config/HostConfigModule.cs
deleted file mode 100644
index 7bf5a7f5a..000000000
--- a/src/NzbDrone.Api/Config/HostConfigModule.cs
+++ /dev/null
@@ -1,86 +0,0 @@
-using System.Linq;
-using System.Reflection;
-using FluentValidation;
-using NzbDrone.Common.EnvironmentInfo;
-using NzbDrone.Common.Extensions;
-using NzbDrone.Core.Authentication;
-using NzbDrone.Core.Configuration;
-using NzbDrone.Core.Update;
-using NzbDrone.Core.Validation;
-using NzbDrone.Core.Validation.Paths;
-using Lidarr.Http;
-
-namespace NzbDrone.Api.Config
-{
- public class HostConfigModule : LidarrRestModule
- {
- private readonly IConfigFileProvider _configFileProvider;
- private readonly IConfigService _configService;
- private readonly IUserService _userService;
-
- public HostConfigModule(IConfigFileProvider configFileProvider, IConfigService configService, IUserService userService)
- : base("/config/host")
- {
- _configFileProvider = configFileProvider;
- _configService = configService;
- _userService = userService;
-
- GetResourceSingle = GetHostConfig;
- GetResourceById = GetHostConfig;
- UpdateResource = SaveHostConfig;
-
- SharedValidator.RuleFor(c => c.BindAddress)
- .ValidIp4Address()
- .NotListenAllIp4Address()
- .When(c => c.BindAddress != "*");
-
- SharedValidator.RuleFor(c => c.Port).ValidPort();
-
- SharedValidator.RuleFor(c => c.UrlBase).ValidUrlBase();
-
- SharedValidator.RuleFor(c => c.Username).NotEmpty().When(c => c.AuthenticationMethod != AuthenticationType.None);
- SharedValidator.RuleFor(c => c.Password).NotEmpty().When(c => c.AuthenticationMethod != AuthenticationType.None);
-
- SharedValidator.RuleFor(c => c.SslPort).ValidPort().When(c => c.EnableSsl);
- SharedValidator.RuleFor(c => c.SslCertHash).NotEmpty().When(c => c.EnableSsl && OsInfo.IsWindows);
-
- SharedValidator.RuleFor(c => c.Branch).NotEmpty().WithMessage("Branch name is required, 'master' is the default");
- SharedValidator.RuleFor(c => c.UpdateScriptPath).IsValidPath().When(c => c.UpdateMechanism == UpdateMechanism.Script);
- }
-
- private HostConfigResource GetHostConfig()
- {
- var resource = _configFileProvider.ToResource(_configService);
- resource.Id = 1;
-
- var user = _userService.FindUser();
- if (user != null)
- {
- resource.Username = user.Username;
- resource.Password = user.Password;
- }
-
- return resource;
- }
-
- private HostConfigResource GetHostConfig(int id)
- {
- return GetHostConfig();
- }
-
- private void SaveHostConfig(HostConfigResource resource)
- {
- var dictionary = resource.GetType()
- .GetProperties(BindingFlags.Instance | BindingFlags.Public)
- .ToDictionary(prop => prop.Name, prop => prop.GetValue(resource, null));
-
- _configFileProvider.SaveConfigDictionary(dictionary);
- _configService.SaveConfigDictionary(dictionary);
-
- if (resource.Username.IsNotNullOrWhiteSpace() && resource.Password.IsNotNullOrWhiteSpace())
- {
- _userService.Upsert(resource.Username, resource.Password);
- }
- }
- }
-}
diff --git a/src/NzbDrone.Api/Config/HostConfigResource.cs b/src/NzbDrone.Api/Config/HostConfigResource.cs
deleted file mode 100644
index 312571f0f..000000000
--- a/src/NzbDrone.Api/Config/HostConfigResource.cs
+++ /dev/null
@@ -1,73 +0,0 @@
-using Lidarr.Http.REST;
-using NzbDrone.Core.Authentication;
-using NzbDrone.Core.Configuration;
-using NzbDrone.Core.Update;
-using NzbDrone.Common.Http.Proxy;
-
-namespace NzbDrone.Api.Config
-{
- public class HostConfigResource : RestResource
- {
- public string BindAddress { get; set; }
- public int Port { get; set; }
- public int SslPort { get; set; }
- public bool EnableSsl { get; set; }
- public bool LaunchBrowser { get; set; }
- public AuthenticationType AuthenticationMethod { get; set; }
- public bool AnalyticsEnabled { get; set; }
- public string Username { get; set; }
- public string Password { get; set; }
- public string LogLevel { get; set; }
- public string Branch { get; set; }
- public string ApiKey { get; set; }
- public string SslCertHash { get; set; }
- public string UrlBase { get; set; }
- public bool UpdateAutomatically { get; set; }
- public UpdateMechanism UpdateMechanism { get; set; }
- public string UpdateScriptPath { get; set; }
- public bool ProxyEnabled { get; set; }
- public ProxyType ProxyType { get; set; }
- public string ProxyHostname { get; set; }
- public int ProxyPort { get; set; }
- public string ProxyUsername { get; set; }
- public string ProxyPassword { get; set; }
- public string ProxyBypassFilter { get; set; }
- public bool ProxyBypassLocalAddresses { get; set; }
- }
-
- public static class HostConfigResourceMapper
- {
- public static HostConfigResource ToResource(this IConfigFileProvider model, IConfigService configService)
- {
- // TODO: Clean this mess up. don't mix data from multiple classes, use sub-resources instead?
- return new HostConfigResource
- {
- BindAddress = model.BindAddress,
- Port = model.Port,
- SslPort = model.SslPort,
- EnableSsl = model.EnableSsl,
- LaunchBrowser = model.LaunchBrowser,
- AuthenticationMethod = model.AuthenticationMethod,
- AnalyticsEnabled = model.AnalyticsEnabled,
- //Username
- //Password
- LogLevel = model.LogLevel,
- Branch = model.Branch,
- ApiKey = model.ApiKey,
- SslCertHash = model.SslCertHash,
- UrlBase = model.UrlBase,
- UpdateAutomatically = model.UpdateAutomatically,
- UpdateMechanism = model.UpdateMechanism,
- UpdateScriptPath = model.UpdateScriptPath,
- ProxyEnabled = configService.ProxyEnabled,
- ProxyType = configService.ProxyType,
- ProxyHostname = configService.ProxyHostname,
- ProxyPort = configService.ProxyPort,
- ProxyUsername = configService.ProxyUsername,
- ProxyPassword = configService.ProxyPassword,
- ProxyBypassFilter = configService.ProxyBypassFilter,
- ProxyBypassLocalAddresses = configService.ProxyBypassLocalAddresses
- };
- }
- }
-}
diff --git a/src/NzbDrone.Api/Config/IndexerConfigModule.cs b/src/NzbDrone.Api/Config/IndexerConfigModule.cs
deleted file mode 100644
index 9a290e650..000000000
--- a/src/NzbDrone.Api/Config/IndexerConfigModule.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-using FluentValidation;
-using Lidarr.Http.Validation;
-using NzbDrone.Core.Configuration;
-
-namespace NzbDrone.Api.Config
-{
- public class IndexerConfigModule : NzbDroneConfigModule
- {
-
- public IndexerConfigModule(IConfigService configService)
- : base(configService)
- {
- SharedValidator.RuleFor(c => c.MinimumAge)
- .GreaterThanOrEqualTo(0);
-
- SharedValidator.RuleFor(c => c.Retention)
- .GreaterThanOrEqualTo(0);
-
- SharedValidator.RuleFor(c => c.RssSyncInterval)
- .IsValidRssSyncInterval();
- }
-
- protected override IndexerConfigResource ToResource(IConfigService model)
- {
- return IndexerConfigResourceMapper.ToResource(model);
- }
- }
-}
diff --git a/src/NzbDrone.Api/Config/IndexerConfigResource.cs b/src/NzbDrone.Api/Config/IndexerConfigResource.cs
deleted file mode 100644
index 4a14e3bdd..000000000
--- a/src/NzbDrone.Api/Config/IndexerConfigResource.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using Lidarr.Http.REST;
-using NzbDrone.Core.Configuration;
-
-namespace NzbDrone.Api.Config
-{
- public class IndexerConfigResource : RestResource
- {
- public int MinimumAge { get; set; }
- public int Retention { get; set; }
- public int RssSyncInterval { get; set; }
- }
-
- public static class IndexerConfigResourceMapper
- {
- public static IndexerConfigResource ToResource(IConfigService model)
- {
- return new IndexerConfigResource
- {
- MinimumAge = model.MinimumAge,
- Retention = model.Retention,
- RssSyncInterval = model.RssSyncInterval,
- };
- }
- }
-}
diff --git a/src/NzbDrone.Api/Config/MediaManagementConfigModule.cs b/src/NzbDrone.Api/Config/MediaManagementConfigModule.cs
deleted file mode 100644
index 8b35e53ed..000000000
--- a/src/NzbDrone.Api/Config/MediaManagementConfigModule.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using FluentValidation;
-using NzbDrone.Core.Configuration;
-using NzbDrone.Core.Validation.Paths;
-
-namespace NzbDrone.Api.Config
-{
- public class MediaManagementConfigModule : NzbDroneConfigModule
- {
- public MediaManagementConfigModule(IConfigService configService, PathExistsValidator pathExistsValidator)
- : base(configService)
- {
- SharedValidator.RuleFor(c => c.FileChmod).NotEmpty();
- SharedValidator.RuleFor(c => c.FolderChmod).NotEmpty();
- SharedValidator.RuleFor(c => c.RecycleBin).IsValidPath().SetValidator(pathExistsValidator).When(c => !string.IsNullOrWhiteSpace(c.RecycleBin));
- }
-
- protected override MediaManagementConfigResource ToResource(IConfigService model)
- {
- return MediaManagementConfigResourceMapper.ToResource(model);
- }
- }
-}
\ No newline at end of file
diff --git a/src/NzbDrone.Api/Config/MediaManagementConfigResource.cs b/src/NzbDrone.Api/Config/MediaManagementConfigResource.cs
deleted file mode 100644
index 281533067..000000000
--- a/src/NzbDrone.Api/Config/MediaManagementConfigResource.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-using Lidarr.Http.REST;
-using NzbDrone.Core.Configuration;
-using NzbDrone.Core.MediaFiles;
-
-namespace NzbDrone.Api.Config
-{
- public class MediaManagementConfigResource : RestResource
- {
- public bool AutoUnmonitorPreviouslyDownloadedTracks { get; set; }
- public string RecycleBin { get; set; }
- public bool AutoDownloadPropers { get; set; }
- public bool CreateEmptyArtistFolders { get; set; }
- public FileDateType FileDate { get; set; }
-
- public bool SetPermissionsLinux { get; set; }
- public string FileChmod { get; set; }
- public string FolderChmod { get; set; }
- public string ChownUser { get; set; }
- public string ChownGroup { get; set; }
-
- public bool SkipFreeSpaceCheckWhenImporting { get; set; }
- public bool CopyUsingHardlinks { get; set; }
- public bool ImportExtraFiles { get; set; }
- public string ExtraFileExtensions { get; set; }
- public bool EnableMediaInfo { get; set; }
- }
-
- public static class MediaManagementConfigResourceMapper
- {
- public static MediaManagementConfigResource ToResource(IConfigService model)
- {
- return new MediaManagementConfigResource
- {
- AutoUnmonitorPreviouslyDownloadedTracks = model.AutoUnmonitorPreviouslyDownloadedTracks,
- RecycleBin = model.RecycleBin,
- AutoDownloadPropers = model.AutoDownloadPropers,
- CreateEmptyArtistFolders = model.CreateEmptyArtistFolders,
- FileDate = model.FileDate,
-
- SetPermissionsLinux = model.SetPermissionsLinux,
- FileChmod = model.FileChmod,
- FolderChmod = model.FolderChmod,
- ChownUser = model.ChownUser,
- ChownGroup = model.ChownGroup,
-
- SkipFreeSpaceCheckWhenImporting = model.SkipFreeSpaceCheckWhenImporting,
- CopyUsingHardlinks = model.CopyUsingHardlinks,
- ImportExtraFiles = model.ImportExtraFiles,
- ExtraFileExtensions = model.ExtraFileExtensions,
- EnableMediaInfo = model.EnableMediaInfo
- };
- }
- }
-}
diff --git a/src/NzbDrone.Api/Config/NamingConfigModule.cs b/src/NzbDrone.Api/Config/NamingConfigModule.cs
deleted file mode 100644
index 395e7f15e..000000000
--- a/src/NzbDrone.Api/Config/NamingConfigModule.cs
+++ /dev/null
@@ -1,112 +0,0 @@
-using System.Collections.Generic;
-using System.Linq;
-using FluentValidation;
-using FluentValidation.Results;
-using Nancy.Responses;
-using NzbDrone.Common.Extensions;
-using NzbDrone.Core.Organizer;
-using Nancy.ModelBinding;
-using Lidarr.Http.Extensions;
-using Lidarr.Http;
-using Lidarr.Http.Mapping;
-
-namespace NzbDrone.Api.Config
-{
- public class NamingConfigModule : LidarrRestModule
- {
- private readonly INamingConfigService _namingConfigService;
- private readonly IFilenameSampleService _filenameSampleService;
- private readonly IFilenameValidationService _filenameValidationService;
- private readonly IBuildFileNames _filenameBuilder;
-
- public NamingConfigModule(INamingConfigService namingConfigService,
- IFilenameSampleService filenameSampleService,
- IFilenameValidationService filenameValidationService,
- IBuildFileNames filenameBuilder)
- : base("config/naming")
- {
- _namingConfigService = namingConfigService;
- _filenameSampleService = filenameSampleService;
- _filenameValidationService = filenameValidationService;
- _filenameBuilder = filenameBuilder;
- GetResourceSingle = GetNamingConfig;
- GetResourceById = GetNamingConfig;
- UpdateResource = UpdateNamingConfig;
-
- Get["/samples"] = x => GetExamples(this.Bind());
-
- SharedValidator.RuleFor(c => c.MultiEpisodeStyle).InclusiveBetween(0, 5);
- SharedValidator.RuleFor(c => c.StandardTrackFormat).ValidTrackFormat();
- SharedValidator.RuleFor(c => c.ArtistFolderFormat).ValidArtistFolderFormat();
- SharedValidator.RuleFor(c => c.AlbumFolderFormat).ValidAlbumFolderFormat();
- }
-
- private void UpdateNamingConfig(NamingConfigResource resource)
- {
- var nameSpec = resource.ToModel();
- ValidateFormatResult(nameSpec);
-
- _namingConfigService.Save(nameSpec);
- }
-
- private NamingConfigResource GetNamingConfig()
- {
- var nameSpec = _namingConfigService.GetConfig();
- var resource = nameSpec.ToResource();
-
- if (resource.StandardTrackFormat.IsNotNullOrWhiteSpace())
- {
- var basicConfig = _filenameBuilder.GetBasicNamingConfig(nameSpec);
- basicConfig.AddToResource(resource);
- }
-
- return resource;
- }
-
- private NamingConfigResource GetNamingConfig(int id)
- {
- return GetNamingConfig();
- }
-
- private JsonResponse GetExamples(NamingConfigResource config)
- {
- var nameSpec = config.ToModel();
- var sampleResource = new NamingSampleResource();
-
-
- var singleTrackSampleResult = _filenameSampleService.GetStandardTrackSample(nameSpec);
-
- sampleResource.SingleTrackExample = _filenameValidationService.ValidateTrackFilename(singleTrackSampleResult) != null
- ? "Invalid format"
- : singleTrackSampleResult.FileName;
-
- sampleResource.ArtistFolderExample = nameSpec.ArtistFolderFormat.IsNullOrWhiteSpace()
- ? "Invalid format"
- : _filenameSampleService.GetArtistFolderSample(nameSpec);
-
- sampleResource.AlbumFolderExample = nameSpec.AlbumFolderFormat.IsNullOrWhiteSpace()
- ? "Invalid format"
- : _filenameSampleService.GetAlbumFolderSample(nameSpec);
-
- return sampleResource.AsResponse();
- }
-
- private void ValidateFormatResult(NamingConfig nameSpec)
- {
-
- var singleTrackSampleResult = _filenameSampleService.GetStandardTrackSample(nameSpec);
-
- var singleTrackValidationResult = _filenameValidationService.ValidateTrackFilename(singleTrackSampleResult);
-
- var validationFailures = new List();
-
- validationFailures.AddIfNotNull(singleTrackValidationResult);
-
-
- if (validationFailures.Any())
- {
- throw new ValidationException(validationFailures.DistinctBy(v => v.PropertyName).ToArray());
- }
- }
- }
-}
diff --git a/src/NzbDrone.Api/Config/NamingConfigResource.cs b/src/NzbDrone.Api/Config/NamingConfigResource.cs
deleted file mode 100644
index dd8572847..000000000
--- a/src/NzbDrone.Api/Config/NamingConfigResource.cs
+++ /dev/null
@@ -1,68 +0,0 @@
-using Lidarr.Http.REST;
-using NzbDrone.Core.Organizer;
-
-namespace NzbDrone.Api.Config
-{
- public class NamingConfigResource : RestResource
- {
- public bool RenameTracks { get; set; }
- public bool ReplaceIllegalCharacters { get; set; }
- public int MultiEpisodeStyle { get; set; }
- public string StandardTrackFormat { get; set; }
- public string ArtistFolderFormat { get; set; }
- public string AlbumFolderFormat { get; set; }
- public bool IncludeArtistName { get; set; }
- public bool IncludeAlbumTitle { get; set; }
- public bool IncludeQuality { get; set; }
- public bool ReplaceSpaces { get; set; }
- public string Separator { get; set; }
- public string NumberStyle { get; set; }
- }
-
- public static class NamingConfigResourceMapper
- {
- public static NamingConfigResource ToResource(this NamingConfig model)
- {
- return new NamingConfigResource
- {
- Id = model.Id,
-
- RenameTracks = model.RenameTracks,
- ReplaceIllegalCharacters = model.ReplaceIllegalCharacters,
- StandardTrackFormat = model.StandardTrackFormat,
- ArtistFolderFormat = model.ArtistFolderFormat,
- AlbumFolderFormat = model.AlbumFolderFormat
- //IncludeSeriesTitle
- //IncludeEpisodeTitle
- //IncludeQuality
- //ReplaceSpaces
- //Separator
- //NumberStyle
- };
- }
-
- public static void AddToResource(this BasicNamingConfig basicNamingConfig, NamingConfigResource resource)
- {
- resource.IncludeArtistName = basicNamingConfig.IncludeArtistName;
- resource.IncludeAlbumTitle = basicNamingConfig.IncludeAlbumTitle;
- resource.IncludeQuality = basicNamingConfig.IncludeQuality;
- resource.ReplaceSpaces = basicNamingConfig.ReplaceSpaces;
- resource.Separator = basicNamingConfig.Separator;
- resource.NumberStyle = basicNamingConfig.NumberStyle;
- }
-
- public static NamingConfig ToModel(this NamingConfigResource resource)
- {
- return new NamingConfig
- {
- Id = resource.Id,
-
- RenameTracks = resource.RenameTracks,
- ReplaceIllegalCharacters = resource.ReplaceIllegalCharacters,
- StandardTrackFormat = resource.StandardTrackFormat,
- ArtistFolderFormat = resource.ArtistFolderFormat,
- AlbumFolderFormat = resource.AlbumFolderFormat
- };
- }
- }
-}
diff --git a/src/NzbDrone.Api/Config/NamingSampleResource.cs b/src/NzbDrone.Api/Config/NamingSampleResource.cs
deleted file mode 100644
index f6d6d15b3..000000000
--- a/src/NzbDrone.Api/Config/NamingSampleResource.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-namespace NzbDrone.Api.Config
-{
- public class NamingSampleResource
- {
- public string SingleEpisodeExample { get; set; }
- public string SingleTrackExample { get; set; }
- public string MultiEpisodeExample { get; set; }
- public string DailyEpisodeExample { get; set; }
- public string AnimeEpisodeExample { get; set; }
- public string AnimeMultiEpisodeExample { get; set; }
- public string SeriesFolderExample { get; set; }
- public string SeasonFolderExample { get; set; }
- public string ArtistFolderExample { get; set; }
- public string AlbumFolderExample { get; set; }
- }
-}
\ No newline at end of file
diff --git a/src/NzbDrone.Api/Config/NzbDroneConfigModule.cs b/src/NzbDrone.Api/Config/NzbDroneConfigModule.cs
deleted file mode 100644
index 49a4af748..000000000
--- a/src/NzbDrone.Api/Config/NzbDroneConfigModule.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-using System.Linq;
-using System.Reflection;
-using Lidarr.Http.REST;
-using NzbDrone.Core.Configuration;
-using Lidarr.Http;
-
-namespace NzbDrone.Api.Config
-{
- public abstract class NzbDroneConfigModule : LidarrRestModule where TResource : RestResource, new()
- {
- private readonly IConfigService _configService;
-
- protected NzbDroneConfigModule(IConfigService configService)
- : this(new TResource().ResourceName.Replace("config", ""), configService)
- {
- }
-
- protected NzbDroneConfigModule(string resource, IConfigService configService) :
- base("config/" + resource.Trim('/'))
- {
- _configService = configService;
-
- GetResourceSingle = GetConfig;
- GetResourceById = GetConfig;
- UpdateResource = SaveConfig;
- }
-
- private TResource GetConfig()
- {
- var resource = ToResource(_configService);
- resource.Id = 1;
-
- return resource;
- }
-
- protected abstract TResource ToResource(IConfigService model);
-
- private TResource GetConfig(int id)
- {
- return GetConfig();
- }
-
- private void SaveConfig(TResource resource)
- {
- var dictionary = resource.GetType()
- .GetProperties(BindingFlags.Instance | BindingFlags.Public)
- .ToDictionary(prop => prop.Name, prop => prop.GetValue(resource, null));
-
- _configService.SaveConfigDictionary(dictionary);
- }
- }
-}
diff --git a/src/NzbDrone.Api/Config/UiConfigModule.cs b/src/NzbDrone.Api/Config/UiConfigModule.cs
deleted file mode 100644
index 1762acaca..000000000
--- a/src/NzbDrone.Api/Config/UiConfigModule.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using NzbDrone.Core.Configuration;
-
-namespace NzbDrone.Api.Config
-{
- public class UiConfigModule : NzbDroneConfigModule
- {
- public UiConfigModule(IConfigService configService)
- : base(configService)
- {
-
- }
-
- protected override UiConfigResource ToResource(IConfigService model)
- {
- return UiConfigResourceMapper.ToResource(model);
- }
- }
-}
\ No newline at end of file
diff --git a/src/NzbDrone.Api/Config/UiConfigResource.cs b/src/NzbDrone.Api/Config/UiConfigResource.cs
deleted file mode 100644
index 44e6ff0b1..000000000
--- a/src/NzbDrone.Api/Config/UiConfigResource.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-using Lidarr.Http.REST;
-using NzbDrone.Core.Configuration;
-
-namespace NzbDrone.Api.Config
-{
- public class UiConfigResource : RestResource
- {
- //Calendar
- public int FirstDayOfWeek { get; set; }
- public string CalendarWeekColumnHeader { get; set; }
-
- //Dates
- public string ShortDateFormat { get; set; }
- public string LongDateFormat { get; set; }
- public string TimeFormat { get; set; }
- public bool ShowRelativeDates { get; set; }
-
- public bool EnableColorImpairedMode { get; set; }
- }
-
- public static class UiConfigResourceMapper
- {
- public static UiConfigResource ToResource(IConfigService model)
- {
- return new UiConfigResource
- {
- FirstDayOfWeek = model.FirstDayOfWeek,
- CalendarWeekColumnHeader = model.CalendarWeekColumnHeader,
-
- ShortDateFormat = model.ShortDateFormat,
- LongDateFormat = model.LongDateFormat,
- TimeFormat = model.TimeFormat,
- ShowRelativeDates = model.ShowRelativeDates,
-
- EnableColorImpairedMode = model.EnableColorImpairedMode,
- };
- }
- }
-}
diff --git a/src/NzbDrone.Api/DiskSpace/DiskSpaceModule.cs b/src/NzbDrone.Api/DiskSpace/DiskSpaceModule.cs
deleted file mode 100644
index c59ef45e0..000000000
--- a/src/NzbDrone.Api/DiskSpace/DiskSpaceModule.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-using System.Collections.Generic;
-using NzbDrone.Core.DiskSpace;
-using Lidarr.Http;
-
-namespace NzbDrone.Api.DiskSpace
-{
- public class DiskSpaceModule : LidarrRestModule
- {
- private readonly IDiskSpaceService _diskSpaceService;
-
- public DiskSpaceModule(IDiskSpaceService diskSpaceService)
- : base("diskspace")
- {
- _diskSpaceService = diskSpaceService;
- GetResourceAll = GetFreeSpace;
- }
-
-
- public List GetFreeSpace()
- {
- return _diskSpaceService.GetFreeSpace().ConvertAll(DiskSpaceResourceMapper.MapToResource);
- }
- }
-}
diff --git a/src/NzbDrone.Api/DiskSpace/DiskSpaceResource.cs b/src/NzbDrone.Api/DiskSpace/DiskSpaceResource.cs
deleted file mode 100644
index 71069da5b..000000000
--- a/src/NzbDrone.Api/DiskSpace/DiskSpaceResource.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-using Lidarr.Http.REST;
-
-namespace NzbDrone.Api.DiskSpace
-{
- public class DiskSpaceResource : RestResource
- {
- public string Path { get; set; }
- public string Label { get; set; }
- public long FreeSpace { get; set; }
- public long TotalSpace { get; set; }
- }
-
- public static class DiskSpaceResourceMapper
- {
- public static DiskSpaceResource MapToResource(this Core.DiskSpace.DiskSpace model)
- {
- if (model == null) return null;
-
- return new DiskSpaceResource
- {
- Path = model.Path,
- Label = model.Label,
- FreeSpace = model.FreeSpace,
- TotalSpace = model.TotalSpace
- };
- }
- }
-}
diff --git a/src/NzbDrone.Api/DownloadClient/DownloadClientModule.cs b/src/NzbDrone.Api/DownloadClient/DownloadClientModule.cs
deleted file mode 100644
index d7568189f..000000000
--- a/src/NzbDrone.Api/DownloadClient/DownloadClientModule.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-using NzbDrone.Core.Download;
-
-namespace NzbDrone.Api.DownloadClient
-{
- public class DownloadClientModule : ProviderModuleBase
- {
- public DownloadClientModule(IDownloadClientFactory downloadClientFactory)
- : base(downloadClientFactory, "downloadclient")
- {
- }
-
- protected override void MapToResource(DownloadClientResource resource, DownloadClientDefinition definition)
- {
- base.MapToResource(resource, definition);
-
- resource.Enable = definition.Enable;
- resource.Protocol = definition.Protocol;
- }
-
- protected override void MapToModel(DownloadClientDefinition definition, DownloadClientResource resource)
- {
- base.MapToModel(definition, resource);
-
- definition.Enable = resource.Enable;
- definition.Protocol = resource.Protocol;
- }
-
- protected override void Validate(DownloadClientDefinition definition, bool includeWarnings)
- {
- if (!definition.Enable) return;
- base.Validate(definition, includeWarnings);
- }
- }
-}
\ No newline at end of file
diff --git a/src/NzbDrone.Api/DownloadClient/DownloadClientResource.cs b/src/NzbDrone.Api/DownloadClient/DownloadClientResource.cs
deleted file mode 100644
index a7156e08d..000000000
--- a/src/NzbDrone.Api/DownloadClient/DownloadClientResource.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using NzbDrone.Core.Indexers;
-
-namespace NzbDrone.Api.DownloadClient
-{
- public class DownloadClientResource : ProviderResource
- {
- public bool Enable { get; set; }
- public DownloadProtocol Protocol { get; set; }
- }
-}
\ No newline at end of file
diff --git a/src/NzbDrone.Api/EpisodeFiles/EpisodeFileModule.cs b/src/NzbDrone.Api/EpisodeFiles/EpisodeFileModule.cs
deleted file mode 100644
index f4536c79a..000000000
--- a/src/NzbDrone.Api/EpisodeFiles/EpisodeFileModule.cs
+++ /dev/null
@@ -1,98 +0,0 @@
-using System.Collections.Generic;
-using System.IO;
-using NLog;
-using Lidarr.Http;
-using NzbDrone.Common.Disk;
-using NzbDrone.Common.Extensions;
-using NzbDrone.Core.Datastore.Events;
-using NzbDrone.Core.MediaFiles;
-using NzbDrone.Core.MediaFiles.Events;
-using NzbDrone.Core.Messaging.Events;
-using NzbDrone.Core.Tv;
-using NzbDrone.Core.DecisionEngine;
-using NzbDrone.SignalR;
-using System;
-
-namespace NzbDrone.Api.EpisodeFiles
-{
- public class EpisodeFileModule : LidarrRestModuleWithSignalR,
- IHandle
- {
- private readonly IMediaFileService _mediaFileService;
- private readonly IDiskProvider _diskProvider;
- private readonly IRecycleBinProvider _recycleBinProvider;
- private readonly ISeriesService _seriesService;
- private readonly IUpgradableSpecification _upgradableSpecification;
- private readonly Logger _logger;
-
- public EpisodeFileModule(IBroadcastSignalRMessage signalRBroadcaster,
- IMediaFileService mediaFileService,
- IDiskProvider diskProvider,
- IRecycleBinProvider recycleBinProvider,
- ISeriesService seriesService,
- IUpgradableSpecification upgradableSpecification,
- Logger logger)
- : base(signalRBroadcaster)
- {
- _mediaFileService = mediaFileService;
- _diskProvider = diskProvider;
- _recycleBinProvider = recycleBinProvider;
- _seriesService = seriesService;
- _upgradableSpecification = upgradableSpecification;
- _logger = logger;
- GetResourceById = GetEpisodeFile;
- GetResourceAll = GetEpisodeFiles;
- UpdateResource = SetQuality;
- DeleteResource = DeleteEpisodeFile;
- }
-
- private EpisodeFileResource GetEpisodeFile(int id)
- {
- throw new NotImplementedException();
- //var episodeFile = _mediaFileService.Get(id);
- //var series = _seriesService.GetSeries(episodeFile.SeriesId);
-
- //return episodeFile.ToResource(series, _qualityUpgradableSpecification);
- }
-
- private List GetEpisodeFiles()
- {
- throw new NotImplementedException();
- //if (!Request.Query.SeriesId.HasValue)
- //{
- // throw new BadRequestException("seriesId is missing");
- //}
-
- //var seriesId = (int)Request.Query.SeriesId;
-
- //var series = _seriesService.GetSeries(seriesId);
-
- //return _mediaFileService.GetFilesBySeries(seriesId).ConvertAll(f => f.ToResource(series, _qualityUpgradableSpecification));
- }
-
- private void SetQuality(EpisodeFileResource episodeFileResource)
- {
- var episodeFile = _mediaFileService.Get(episodeFileResource.Id);
- episodeFile.Quality = episodeFileResource.Quality;
- _mediaFileService.Update(episodeFile);
- }
-
- private void DeleteEpisodeFile(int id)
- {
- throw new NotImplementedException();
- //var episodeFile = _mediaFileService.Get(id);
- //var series = _seriesService.GetSeries(episodeFile.SeriesId);
- //var fullPath = Path.Combine(series.Path, episodeFile.RelativePath);
- //var subfolder = _diskProvider.GetParentFolder(series.Path).GetRelativePath(_diskProvider.GetParentFolder(fullPath));
-
- //_logger.Info("Deleting episode file: {0}", fullPath);
- //_recycleBinProvider.DeleteFile(fullPath, subfolder);
- //_mediaFileService.Delete(episodeFile, DeleteMediaFileReason.Manual);
- }
-
- public void Handle(EpisodeFileAddedEvent message)
- {
- BroadcastResourceChange(ModelAction.Updated, message.EpisodeFile.Id);
- }
- }
-}
diff --git a/src/NzbDrone.Api/EpisodeFiles/EpisodeFileResource.cs b/src/NzbDrone.Api/EpisodeFiles/EpisodeFileResource.cs
deleted file mode 100644
index a284a8d4f..000000000
--- a/src/NzbDrone.Api/EpisodeFiles/EpisodeFileResource.cs
+++ /dev/null
@@ -1,69 +0,0 @@
-using System;
-using System.IO;
-using Lidarr.Http.REST;
-using NzbDrone.Core.DecisionEngine;
-using NzbDrone.Core.MediaFiles;
-using NzbDrone.Core.Qualities;
-using NzbDrone.Core.Languages;
-
-namespace NzbDrone.Api.EpisodeFiles
-{
- public class EpisodeFileResource : RestResource
- {
- public int SeriesId { get; set; }
- public int SeasonNumber { get; set; }
- public string RelativePath { get; set; }
- public string Path { get; set; }
- public long Size { get; set; }
- public DateTime DateAdded { get; set; }
- public string SceneName { get; set; }
- public QualityModel Quality { get; set; }
- public Language Language { get; set; }
-
- public bool QualityCutoffNotMet { get; set; }
- }
-
- public static class EpisodeFileResourceMapper
- {
- private static EpisodeFileResource ToResource(this EpisodeFile model)
- {
- if (model == null) return null;
-
- return new EpisodeFileResource
- {
- Id = model.Id,
-
- SeriesId = model.SeriesId,
- SeasonNumber = model.SeasonNumber,
- RelativePath = model.RelativePath,
- //Path
- Size = model.Size,
- DateAdded = model.DateAdded,
- SceneName = model.SceneName,
- Quality = model.Quality,
- //QualityCutoffNotMet
- };
- }
-
- public static EpisodeFileResource ToResource(this EpisodeFile model, Core.Tv.Series series, IUpgradableSpecification upgradableSpecification)
- {
- if (model == null) return null;
-
- return new EpisodeFileResource
- {
- Id = model.Id,
-
- SeriesId = model.SeriesId,
- SeasonNumber = model.SeasonNumber,
- RelativePath = model.RelativePath,
- Path = Path.Combine(series.Path, model.RelativePath),
- Size = model.Size,
- DateAdded = model.DateAdded,
- SceneName = model.SceneName,
- Quality = model.Quality,
- Language = model.Language,
- QualityCutoffNotMet = upgradableSpecification.CutoffNotMet(series.Profile.Value, series.LanguageProfile.Value, model.Quality, model.Language)
- };
- }
- }
-}
diff --git a/src/NzbDrone.Api/Episodes/EpisodeModule.cs b/src/NzbDrone.Api/Episodes/EpisodeModule.cs
deleted file mode 100644
index fb4b8933d..000000000
--- a/src/NzbDrone.Api/Episodes/EpisodeModule.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-using System.Collections.Generic;
-using Lidarr.Http.REST;
-using NzbDrone.Core.Tv;
-using NzbDrone.Core.DecisionEngine;
-using NzbDrone.SignalR;
-
-namespace NzbDrone.Api.Episodes
-{
- public class EpisodeModule : EpisodeModuleWithSignalR
- {
- public EpisodeModule(ISeriesService seriesService,
- IEpisodeService episodeService,
- IUpgradableSpecification qualityUpgradableSpecification,
- IBroadcastSignalRMessage signalRBroadcaster)
- : base(episodeService, seriesService, qualityUpgradableSpecification, signalRBroadcaster)
- {
- GetResourceAll = GetEpisodes;
- UpdateResource = SetMonitored;
- }
-
- private List GetEpisodes()
- {
- if (!Request.Query.SeriesId.HasValue)
- {
- throw new BadRequestException("seriesId is missing");
- }
-
- var seriesId = (int)Request.Query.SeriesId;
-
- var resources = MapToResource(_episodeService.GetEpisodeBySeries(seriesId), false, true);
-
- return resources;
- }
-
- private void SetMonitored(EpisodeResource episodeResource)
- {
- _episodeService.SetEpisodeMonitored(episodeResource.Id, episodeResource.Monitored);
- }
- }
-}
diff --git a/src/NzbDrone.Api/Episodes/EpisodeModuleWithSignalR.cs b/src/NzbDrone.Api/Episodes/EpisodeModuleWithSignalR.cs
deleted file mode 100644
index a170f49f8..000000000
--- a/src/NzbDrone.Api/Episodes/EpisodeModuleWithSignalR.cs
+++ /dev/null
@@ -1,127 +0,0 @@
-using System.Collections.Generic;
-using NzbDrone.Common.Extensions;
-using NzbDrone.Api.EpisodeFiles;
-using NzbDrone.Api.Series;
-using NzbDrone.Core.Datastore.Events;
-using NzbDrone.Core.DecisionEngine;
-using NzbDrone.Core.Download;
-using NzbDrone.Core.MediaFiles.Events;
-using NzbDrone.Core.Messaging.Events;
-using NzbDrone.Core.Tv;
-using NzbDrone.SignalR;
-using Lidarr.Http;
-
-namespace NzbDrone.Api.Episodes
-{
- public abstract class EpisodeModuleWithSignalR : LidarrRestModuleWithSignalR,
- IHandle,
- IHandle
- {
- protected readonly IEpisodeService _episodeService;
- protected readonly ISeriesService _seriesService;
- protected readonly IUpgradableSpecification _qualityUpgradableSpecification;
-
- protected EpisodeModuleWithSignalR(IEpisodeService episodeService,
- ISeriesService seriesService,
- IUpgradableSpecification qualityUpgradableSpecification,
- IBroadcastSignalRMessage signalRBroadcaster)
- : base(signalRBroadcaster)
- {
- _episodeService = episodeService;
- _seriesService = seriesService;
- _qualityUpgradableSpecification = qualityUpgradableSpecification;
-
- GetResourceById = GetEpisode;
- }
-
- protected EpisodeModuleWithSignalR(IEpisodeService episodeService,
- ISeriesService seriesService,
- IUpgradableSpecification qualityUpgradableSpecification,
- IBroadcastSignalRMessage signalRBroadcaster,
- string resource)
- : base(signalRBroadcaster, resource)
- {
- _episodeService = episodeService;
- _seriesService = seriesService;
- _qualityUpgradableSpecification = qualityUpgradableSpecification;
-
- GetResourceById = GetEpisode;
- }
-
- protected EpisodeResource GetEpisode(int id)
- {
- var episode = _episodeService.GetEpisode(id);
- var resource = MapToResource(episode, true, true);
- return resource;
- }
-
- protected EpisodeResource MapToResource(Episode episode, bool includeSeries, bool includeEpisodeFile)
- {
- var resource = episode.ToResource();
-
- if (includeSeries || includeEpisodeFile)
- {
- var series = episode.Series ?? _seriesService.GetSeries(episode.SeriesId);
-
- if (includeSeries)
- {
- resource.Series = series.ToResource();
- }
- if (includeEpisodeFile && episode.EpisodeFileId != 0)
- {
- resource.EpisodeFile = episode.EpisodeFile.Value.ToResource(series, _qualityUpgradableSpecification);
- }
- }
-
- return resource;
- }
-
- protected List MapToResource(List episodes, bool includeSeries, bool includeEpisodeFile)
- {
- var result = episodes.ToResource();
-
- if (includeSeries || includeEpisodeFile)
- {
- var seriesDict = new Dictionary();
- for (var i = 0; i < episodes.Count; i++)
- {
- var episode = episodes[i];
- var resource = result[i];
-
- var series = episode.Series ?? seriesDict.GetValueOrDefault(episodes[i].SeriesId) ?? _seriesService.GetSeries(episodes[i].SeriesId);
- seriesDict[series.Id] = series;
-
- if (includeSeries)
- {
- resource.Series = series.ToResource();
- }
- if (includeEpisodeFile && episodes[i].EpisodeFileId != 0)
- {
- resource.EpisodeFile = episodes[i].EpisodeFile.Value.ToResource(series, _qualityUpgradableSpecification);
- }
- }
- }
-
- return result;
- }
-
- public void Handle(EpisodeGrabbedEvent message)
- {
- foreach (var episode in message.Episode.Episodes)
- {
- var resource = episode.ToResource();
- resource.Grabbed = true;
-
- BroadcastResourceChange(ModelAction.Updated, resource);
- }
- }
-
- public void Handle(EpisodeDownloadedEvent message)
- {
- foreach (var episode in message.Episode.Episodes)
- {
- BroadcastResourceChange(ModelAction.Updated, episode.Id);
- }
- }
- }
-}
diff --git a/src/NzbDrone.Api/Episodes/EpisodeResource.cs b/src/NzbDrone.Api/Episodes/EpisodeResource.cs
deleted file mode 100644
index 8faadb272..000000000
--- a/src/NzbDrone.Api/Episodes/EpisodeResource.cs
+++ /dev/null
@@ -1,78 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using Newtonsoft.Json;
-using NzbDrone.Api.EpisodeFiles;
-using Lidarr.Http.REST;
-using NzbDrone.Api.Series;
-using NzbDrone.Core.Tv;
-
-namespace NzbDrone.Api.Episodes
-{
- public class EpisodeResource : RestResource
- {
- public int SeriesId { get; set; }
- public int EpisodeFileId { get; set; }
- public int SeasonNumber { get; set; }
- public int EpisodeNumber { get; set; }
- public string Title { get; set; }
- public string AirDate { get; set; }
- public DateTime? AirDateUtc { get; set; }
- public string Overview { get; set; }
- public EpisodeFileResource EpisodeFile { get; set; }
-
- public bool HasFile { get; set; }
- public bool Monitored { get; set; }
- public int? AbsoluteEpisodeNumber { get; set; }
- public int? SceneAbsoluteEpisodeNumber { get; set; }
- public int? SceneEpisodeNumber { get; set; }
- public int? SceneSeasonNumber { get; set; }
- public bool UnverifiedSceneNumbering { get; set; }
- public string SeriesTitle { get; set; }
- public SeriesResource Series { get; set; }
-
- //Hiding this so people don't think its usable (only used to set the initial state)
- [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
- public bool Grabbed { get; set; }
- }
-
- public static class EpisodeResourceMapper
- {
- public static EpisodeResource ToResource(this Episode model)
- {
- if (model == null) return null;
-
- return new EpisodeResource
- {
- Id = model.Id,
-
- SeriesId = model.SeriesId,
- EpisodeFileId = model.EpisodeFileId,
- SeasonNumber = model.SeasonNumber,
- EpisodeNumber = model.EpisodeNumber,
- Title = model.Title,
- AirDate = model.AirDate,
- AirDateUtc = model.AirDateUtc,
- Overview = model.Overview,
- //EpisodeFile
-
- HasFile = model.HasFile,
- Monitored = model.Monitored,
- AbsoluteEpisodeNumber = model.AbsoluteEpisodeNumber,
- SceneAbsoluteEpisodeNumber = model.SceneAbsoluteEpisodeNumber,
- SceneEpisodeNumber = model.SceneEpisodeNumber,
- SceneSeasonNumber = model.SceneSeasonNumber,
- UnverifiedSceneNumbering = model.UnverifiedSceneNumbering,
- SeriesTitle = model.SeriesTitle,
- //Series = model.Series.MapToResource(),
- };
- }
-
- public static List ToResource(this IEnumerable models)
- {
- if (models == null) return null;
-
- return models.Select(ToResource).ToList();
- }
- }
-}
diff --git a/src/NzbDrone.Api/FileSystem/FileSystemModule.cs b/src/NzbDrone.Api/FileSystem/FileSystemModule.cs
deleted file mode 100644
index 4e3ac967e..000000000
--- a/src/NzbDrone.Api/FileSystem/FileSystemModule.cs
+++ /dev/null
@@ -1,76 +0,0 @@
-using System;
-using System.IO;
-using System.Linq;
-using Nancy;
-using Lidarr.Http.Extensions;
-using NzbDrone.Common.Disk;
-using NzbDrone.Common.Extensions;
-using NzbDrone.Core.MediaFiles;
-
-namespace NzbDrone.Api.FileSystem
-{
- public class FileSystemModule : NzbDroneApiModule
- {
- private readonly IFileSystemLookupService _fileSystemLookupService;
- private readonly IDiskProvider _diskProvider;
- private readonly IDiskScanService _diskScanService;
-
- public FileSystemModule(IFileSystemLookupService fileSystemLookupService,
- IDiskProvider diskProvider,
- IDiskScanService diskScanService)
- : base("/filesystem")
- {
- _fileSystemLookupService = fileSystemLookupService;
- _diskProvider = diskProvider;
- _diskScanService = diskScanService;
- Get["/"] = x => GetContents();
- Get["/type"] = x => GetEntityType();
- Get["/mediafiles"] = x => GetMediaFiles();
- }
-
- private Response GetContents()
- {
- var pathQuery = Request.Query.path;
- var includeFilesQuery = Request.Query.includeFiles;
- bool includeFiles = false;
-
- if (includeFilesQuery.HasValue)
- {
- includeFiles = Convert.ToBoolean(includeFilesQuery.Value);
- }
-
- return _fileSystemLookupService.LookupContents((string)pathQuery.Value, includeFiles).AsResponse();
- }
-
- private Response GetEntityType()
- {
- var pathQuery = Request.Query.path;
- var path = (string)pathQuery.Value;
-
- if (_diskProvider.FileExists(path))
- {
- return new { type = "file" }.AsResponse();
- }
-
- //Return folder even if it doesn't exist on disk to avoid leaking anything from the UI about the underlying system
- return new { type = "folder" }.AsResponse();
- }
-
- private Response GetMediaFiles()
- {
- var pathQuery = Request.Query.path;
- var path = (string)pathQuery.Value;
-
- if (!_diskProvider.FolderExists(path))
- {
- return new string[0].AsResponse();
- }
-
- return _diskScanService.GetAudioFiles(path).Select(f => new {
- Path = f,
- RelativePath = path.GetRelativePath(f),
- Name = Path.GetFileName(f)
- }).AsResponse();
- }
- }
-}
diff --git a/src/NzbDrone.Api/Health/HealthModule.cs b/src/NzbDrone.Api/Health/HealthModule.cs
deleted file mode 100644
index d5fa9140d..000000000
--- a/src/NzbDrone.Api/Health/HealthModule.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-using System.Collections.Generic;
-using NzbDrone.Core.Datastore.Events;
-using NzbDrone.Core.HealthCheck;
-using NzbDrone.Core.Messaging.Events;
-using NzbDrone.SignalR;
-using Lidarr.Http;
-
-namespace NzbDrone.Api.Health
-{
- public class HealthModule : LidarrRestModuleWithSignalR,
- IHandle
- {
- private readonly IHealthCheckService _healthCheckService;
-
- public HealthModule(IBroadcastSignalRMessage signalRBroadcaster, IHealthCheckService healthCheckService)
- : base(signalRBroadcaster)
- {
- _healthCheckService = healthCheckService;
- GetResourceAll = GetHealth;
- }
-
- private List GetHealth()
- {
- return _healthCheckService.Results().ToResource();
- }
-
- public void Handle(HealthCheckCompleteEvent message)
- {
- BroadcastResourceChange(ModelAction.Sync);
- }
- }
-}
diff --git a/src/NzbDrone.Api/Health/HealthResource.cs b/src/NzbDrone.Api/Health/HealthResource.cs
deleted file mode 100644
index 32a78bd53..000000000
--- a/src/NzbDrone.Api/Health/HealthResource.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-using System.Collections.Generic;
-using System.Linq;
-using Lidarr.Http.REST;
-using NzbDrone.Common.Http;
-using NzbDrone.Core.HealthCheck;
-
-namespace NzbDrone.Api.Health
-{
- public class HealthResource : RestResource
- {
- public HealthCheckResult Type { get; set; }
- public string Message { get; set; }
- public HttpUri WikiUrl { get; set; }
- }
-
- public static class HealthResourceMapper
- {
- public static HealthResource ToResource(this HealthCheck model)
- {
- if (model == null) return null;
-
- return new HealthResource
- {
- Id = model.Id,
-
- Type = model.Type,
- Message = model.Message,
- WikiUrl = model.WikiUrl
- };
- }
-
- public static List ToResource(this IEnumerable models)
- {
- return models.Select(ToResource).ToList();
- }
- }
-}
diff --git a/src/NzbDrone.Api/History/HistoryModule.cs b/src/NzbDrone.Api/History/HistoryModule.cs
deleted file mode 100644
index 59e58df27..000000000
--- a/src/NzbDrone.Api/History/HistoryModule.cs
+++ /dev/null
@@ -1,80 +0,0 @@
-using System;
-using Nancy;
-using NzbDrone.Api.Episodes;
-using NzbDrone.Api.Albums;
-using Lidarr.Http.Extensions;
-using NzbDrone.Api.Series;
-using NzbDrone.Api.Music;
-using NzbDrone.Core.Datastore;
-using NzbDrone.Core.DecisionEngine;
-using NzbDrone.Core.Download;
-using NzbDrone.Core.History;
-using Lidarr.Http;
-
-namespace NzbDrone.Api.History
-{
- public class HistoryModule : LidarrRestModule
- {
- private readonly IHistoryService _historyService;
- private readonly IUpgradableSpecification _upgradableSpecification;
- private readonly IFailedDownloadService _failedDownloadService;
-
- public HistoryModule(IHistoryService historyService,
- IUpgradableSpecification qualityUpgradableSpecification,
- IFailedDownloadService failedDownloadService)
- {
- _historyService = historyService;
- _upgradableSpecification = qualityUpgradableSpecification;
- _failedDownloadService = failedDownloadService;
- GetResourcePaged = GetHistory;
-
- Post["/failed"] = x => MarkAsFailed();
- }
-
- protected HistoryResource MapToResource(Core.History.History model)
- {
- var resource = model.ToResource();
-
- resource.Artist = model.Artist.ToResource();
- resource.Album = model.Album.ToResource();
-
- if (model.Artist != null)
- {
- resource.QualityCutoffNotMet = _upgradableSpecification.CutoffNotMet(model.Artist.Profile.Value,
- model.Artist.LanguageProfile,
- model.Quality,
- model.Language);
- }
-
- return resource;
- }
-
- private PagingResource GetHistory(PagingResource pagingResource)
- {
- var albumId = Request.Query.AlbumId;
-
- var pagingSpec = pagingResource.MapToPagingSpec("date", SortDirection.Descending);
-
- if (pagingResource.FilterKey == "eventType")
- {
- var filterValue = (HistoryEventType)Convert.ToInt32(pagingResource.FilterValue);
- pagingSpec.FilterExpression = v => v.EventType == filterValue;
- }
-
- if (albumId.HasValue)
- {
- int i = (int)albumId;
- pagingSpec.FilterExpression = h => h.AlbumId == i;
- }
-
- return ApplyToPage(_historyService.Paged, pagingSpec, MapToResource);
- }
-
- private Response MarkAsFailed()
- {
- var id = (int)Request.Form.Id;
- _failedDownloadService.MarkAsFailed(id);
- return new object().AsResponse();
- }
- }
-}
diff --git a/src/NzbDrone.Api/History/HistoryResource.cs b/src/NzbDrone.Api/History/HistoryResource.cs
deleted file mode 100644
index 327331be9..000000000
--- a/src/NzbDrone.Api/History/HistoryResource.cs
+++ /dev/null
@@ -1,60 +0,0 @@
-using System;
-using System.Collections.Generic;
-using NzbDrone.Api.Episodes;
-using NzbDrone.Api.Albums;
-using Lidarr.Http.REST;
-using NzbDrone.Api.Series;
-using NzbDrone.Api.Music;
-using NzbDrone.Core.History;
-using NzbDrone.Core.Qualities;
-using NzbDrone.Core.Languages;
-
-
-namespace NzbDrone.Api.History
-{
- public class HistoryResource : RestResource
- {
- public int ArtistId { get; set; }
- public int AlbumId { get; set; }
- public string SourceTitle { get; set; }
- public QualityModel Quality { get; set; }
- public bool QualityCutoffNotMet { get; set; }
- public DateTime Date { get; set; }
- public string DownloadId { get; set; }
- public Language Language { get; set; }
-
- public HistoryEventType EventType { get; set; }
-
- public Dictionary Data { get; set; }
-
- public AlbumResource Album { get; set; }
- public ArtistResource Artist { get; set; }
- }
-
- public static class HistoryResourceMapper
- {
- public static HistoryResource ToResource(this Core.History.History model)
- {
- if (model == null) return null;
-
- return new HistoryResource
- {
- Id = model.Id,
-
- AlbumId = model.AlbumId,
- ArtistId = model.ArtistId,
- SourceTitle = model.SourceTitle,
- Quality = model.Quality,
- //QualityCutoffNotMet
- Date = model.Date,
- DownloadId = model.DownloadId,
-
- EventType = model.EventType,
-
- Data = model.Data
- //Episode
- //Series
- };
- }
- }
-}
diff --git a/src/NzbDrone.Api/Indexers/IndexerModule.cs b/src/NzbDrone.Api/Indexers/IndexerModule.cs
deleted file mode 100644
index c66fa7db6..000000000
--- a/src/NzbDrone.Api/Indexers/IndexerModule.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-using NzbDrone.Core.Indexers;
-
-namespace NzbDrone.Api.Indexers
-{
- public class IndexerModule : ProviderModuleBase
- {
- public IndexerModule(IndexerFactory indexerFactory)
- : base(indexerFactory, "indexer")
- {
- }
-
- protected override void MapToResource(IndexerResource resource, IndexerDefinition definition)
- {
- base.MapToResource(resource, definition);
-
- resource.EnableRss = definition.EnableRss;
- resource.EnableSearch = definition.EnableSearch;
- resource.SupportsRss = definition.SupportsRss;
- resource.SupportsSearch = definition.SupportsSearch;
- resource.Protocol = definition.Protocol;
- }
-
- protected override void MapToModel(IndexerDefinition definition, IndexerResource resource)
- {
- base.MapToModel(definition, resource);
-
- definition.EnableRss = resource.EnableRss;
- definition.EnableSearch = resource.EnableSearch;
- }
-
- protected override void Validate(IndexerDefinition definition, bool includeWarnings)
- {
- if (!definition.Enable) return;
- base.Validate(definition, includeWarnings);
- }
- }
-}
\ No newline at end of file
diff --git a/src/NzbDrone.Api/Indexers/IndexerResource.cs b/src/NzbDrone.Api/Indexers/IndexerResource.cs
deleted file mode 100644
index 26bb27cb9..000000000
--- a/src/NzbDrone.Api/Indexers/IndexerResource.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-using NzbDrone.Core.Indexers;
-
-namespace NzbDrone.Api.Indexers
-{
- public class IndexerResource : ProviderResource
- {
- public bool EnableRss { get; set; }
- public bool EnableSearch { get; set; }
- public bool SupportsRss { get; set; }
- public bool SupportsSearch { get; set; }
- public DownloadProtocol Protocol { get; set; }
- }
-}
\ No newline at end of file
diff --git a/src/NzbDrone.Api/Indexers/ReleaseModule.cs b/src/NzbDrone.Api/Indexers/ReleaseModule.cs
deleted file mode 100644
index 6b90afbbb..000000000
--- a/src/NzbDrone.Api/Indexers/ReleaseModule.cs
+++ /dev/null
@@ -1,120 +0,0 @@
-using System;
-using System.Collections.Generic;
-using FluentValidation;
-using Nancy;
-using NLog;
-using NzbDrone.Core.DecisionEngine;
-using NzbDrone.Core.Download;
-using NzbDrone.Core.Exceptions;
-using NzbDrone.Core.IndexerSearch;
-using NzbDrone.Core.Indexers;
-using NzbDrone.Core.Parser.Model;
-using Nancy.ModelBinding;
-using Lidarr.Http.Extensions;
-using NzbDrone.Common.Cache;
-using HttpStatusCode = System.Net.HttpStatusCode;
-
-namespace NzbDrone.Api.Indexers
-{
- public class ReleaseModule : ReleaseModuleBase
- {
- private readonly IFetchAndParseRss _rssFetcherAndParser;
- private readonly ISearchForNzb _nzbSearchService;
- private readonly IMakeDownloadDecision _downloadDecisionMaker;
- private readonly IPrioritizeDownloadDecision _prioritizeDownloadDecision;
- private readonly IDownloadService _downloadService;
- private readonly Logger _logger;
-
- private readonly ICached _remoteAlbumCache;
-
- public ReleaseModule(IFetchAndParseRss rssFetcherAndParser,
- ISearchForNzb nzbSearchService,
- IMakeDownloadDecision downloadDecisionMaker,
- IPrioritizeDownloadDecision prioritizeDownloadDecision,
- IDownloadService downloadService,
- ICacheManager cacheManager,
- Logger logger)
- {
- _rssFetcherAndParser = rssFetcherAndParser;
- _nzbSearchService = nzbSearchService;
- _downloadDecisionMaker = downloadDecisionMaker;
- _prioritizeDownloadDecision = prioritizeDownloadDecision;
- _downloadService = downloadService;
- _logger = logger;
-
- GetResourceAll = GetReleases;
- Post["/"] = x => DownloadRelease(this.Bind());
-
- PostValidator.RuleFor(s => s.DownloadAllowed).Equal(true);
- PostValidator.RuleFor(s => s.Guid).NotEmpty();
-
- _remoteAlbumCache = cacheManager.GetCache(GetType(), "remoteAlbums");
- }
-
- private Response DownloadRelease(ReleaseResource release)
- {
- var remoteAlbum = _remoteAlbumCache.Find(release.Guid);
-
- if (remoteAlbum == null)
- {
- _logger.Debug("Couldn't find requested release in cache, cache timeout probably expired.");
-
- return new NotFoundResponse();
- }
-
- try
- {
- _downloadService.DownloadReport(remoteAlbum);
- }
- catch (ReleaseDownloadException ex)
- {
- _logger.Error(ex);
- throw new NzbDroneClientException(HttpStatusCode.Conflict, "Getting release from indexer failed");
- }
-
- return release.AsResponse();
- }
-
- private List GetReleases()
- {
- if (Request.Query.albumId != null)
- {
- return GetAlbumReleases(Request.Query.albumId);
- }
-
- return GetRss();
- }
-
- private List GetAlbumReleases(int albumId)
- {
- try
- {
- var decisions = _nzbSearchService.AlbumSearch(albumId, true, true);
- var prioritizedDecisions = _prioritizeDownloadDecision.PrioritizeDecisions(decisions);
-
- return MapDecisions(prioritizedDecisions);
- }
- catch (Exception ex)
- {
- _logger.Error(ex, "Album search failed");
- }
-
- return new List();
- }
-
- private List GetRss()
- {
- var reports = _rssFetcherAndParser.Fetch();
- var decisions = _downloadDecisionMaker.GetRssDecision(reports);
- var prioritizedDecisions = _prioritizeDownloadDecision.PrioritizeDecisions(decisions);
-
- return MapDecisions(prioritizedDecisions);
- }
-
- protected override ReleaseResource MapDecision(DownloadDecision decision, int initialWeight)
- {
- _remoteAlbumCache.Set(decision.RemoteAlbum.Release.Guid, decision.RemoteAlbum, TimeSpan.FromMinutes(30));
- return base.MapDecision(decision, initialWeight);
- }
- }
-}
diff --git a/src/NzbDrone.Api/Indexers/ReleaseModuleBase.cs b/src/NzbDrone.Api/Indexers/ReleaseModuleBase.cs
deleted file mode 100644
index 47fae1b06..000000000
--- a/src/NzbDrone.Api/Indexers/ReleaseModuleBase.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-using System.Collections.Generic;
-using NzbDrone.Core.DecisionEngine;
-using Lidarr.Http;
-
-namespace NzbDrone.Api.Indexers
-{
- public abstract class ReleaseModuleBase : LidarrRestModule
- {
- protected virtual List MapDecisions(IEnumerable decisions)
- {
- var result = new List();
-
- foreach (var downloadDecision in decisions)
- {
- var release = MapDecision(downloadDecision, result.Count);
-
- result.Add(release);
- }
-
- return result;
- }
-
- protected virtual ReleaseResource MapDecision(DownloadDecision decision, int initialWeight)
- {
- var release = decision.ToResource();
-
- release.ReleaseWeight = initialWeight;
-
- if (decision.RemoteAlbum.Artist != null)
- {
- release.QualityWeight = decision.RemoteAlbum.Artist
- .Profile.Value
- .Items.FindIndex(v => v.Quality == release.Quality.Quality) * 100;
- }
-
- release.QualityWeight += release.Quality.Revision.Real * 10;
- release.QualityWeight += release.Quality.Revision.Version;
-
- return release;
- }
- }
-}
diff --git a/src/NzbDrone.Api/Indexers/ReleasePushModule.cs b/src/NzbDrone.Api/Indexers/ReleasePushModule.cs
deleted file mode 100644
index 65c7d46d5..000000000
--- a/src/NzbDrone.Api/Indexers/ReleasePushModule.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-using Nancy;
-using Nancy.ModelBinding;
-using FluentValidation;
-using NzbDrone.Core.DecisionEngine;
-using NzbDrone.Core.Download;
-using System.Collections.Generic;
-using System.Linq;
-using NzbDrone.Core.Parser.Model;
-using Lidarr.Http.Extensions;
-using NLog;
-
-namespace NzbDrone.Api.Indexers
-{
- class ReleasePushModule : ReleaseModuleBase
- {
- private readonly IMakeDownloadDecision _downloadDecisionMaker;
- private readonly IProcessDownloadDecisions _downloadDecisionProcessor;
- private readonly Logger _logger;
-
- public ReleasePushModule(IMakeDownloadDecision downloadDecisionMaker,
- IProcessDownloadDecisions downloadDecisionProcessor,
- Logger logger)
- {
- _downloadDecisionMaker = downloadDecisionMaker;
- _downloadDecisionProcessor = downloadDecisionProcessor;
- _logger = logger;
-
- Post["/push"] = x => ProcessRelease(this.Bind());
-
- PostValidator.RuleFor(s => s.Title).NotEmpty();
- PostValidator.RuleFor(s => s.DownloadUrl).NotEmpty();
- PostValidator.RuleFor(s => s.Protocol).NotEmpty();
- PostValidator.RuleFor(s => s.PublishDate).NotEmpty();
- }
-
- private Response ProcessRelease(ReleaseResource release)
- {
- _logger.Info("Release pushed: {0} - {1}", release.Title, release.DownloadUrl);
-
- var info = release.ToModel();
-
- info.Guid = "PUSH-" + info.DownloadUrl;
-
- var decisions = _downloadDecisionMaker.GetRssDecision(new List { info });
- _downloadDecisionProcessor.ProcessDecisions(decisions);
-
- return MapDecisions(decisions).First().AsResponse();
- }
- }
-}
diff --git a/src/NzbDrone.Api/Indexers/ReleaseResource.cs b/src/NzbDrone.Api/Indexers/ReleaseResource.cs
deleted file mode 100644
index 544a86325..000000000
--- a/src/NzbDrone.Api/Indexers/ReleaseResource.cs
+++ /dev/null
@@ -1,158 +0,0 @@
-using System;
-using System.Collections.Generic;
-using Newtonsoft.Json;
-using Lidarr.Http.REST;
-using NzbDrone.Core.Parser;
-using NzbDrone.Core.Qualities;
-using NzbDrone.Core.Indexers;
-using NzbDrone.Core.Languages;
-using NzbDrone.Core.Parser.Model;
-using NzbDrone.Core.DecisionEngine;
-using System.Linq;
-
-namespace NzbDrone.Api.Indexers
-{
- public class ReleaseResource : RestResource
- {
- public string Guid { get; set; }
- public QualityModel Quality { get; set; }
- public int QualityWeight { get; set; }
- public int Age { get; set; }
- public double AgeHours { get; set; }
- public double AgeMinutes { get; set; }
- public long Size { get; set; }
- public int IndexerId { get; set; }
- public string Indexer { get; set; }
- public string ReleaseGroup { get; set; }
- public string ReleaseHash { get; set; }
- public string Title { get; set; }
- public Language Language { get; set; }
- public string ReleaseDate { get; set; }
- public string ArtistName { get; set; }
- public string AlbumTitle { get; set; }
- public bool Approved { get; set; }
- public bool TemporarilyRejected { get; set; }
- public bool Rejected { get; set; }
- public IEnumerable Rejections { get; set; }
- public DateTime PublishDate { get; set; }
- public string CommentUrl { get; set; }
- public string DownloadUrl { get; set; }
- public string InfoUrl { get; set; }
- public bool DownloadAllowed { get; set; }
- public int ReleaseWeight { get; set; }
-
-
- public string MagnetUrl { get; set; }
- public string InfoHash { get; set; }
- public int? Seeders { get; set; }
- public int? Leechers { get; set; }
- public DownloadProtocol Protocol { get; set; }
-
-
- // TODO: Remove in v3
- // Used to support the original Release Push implementation
- // JsonIgnore so we don't serialize it, but can still parse it
- [JsonIgnore]
- public DownloadProtocol DownloadProtocol
- {
- get
- {
- return Protocol;
- }
- set
- {
- if (value > 0 && Protocol == 0)
- {
- Protocol = value;
- }
- }
- }
-
- public bool IsDaily { get; set; }
- public bool IsAbsoluteNumbering { get; set; }
- public bool IsPossibleSpecialEpisode { get; set; }
- public bool Special { get; set; }
- }
-
- public static class ReleaseResourceMapper
- {
- public static ReleaseResource ToResource(this DownloadDecision model)
- {
- var releaseInfo = model.RemoteAlbum.Release;
- var parsedAlbumInfo = model.RemoteAlbum.ParsedAlbumInfo;
- var remoteAlbum = model.RemoteAlbum;
- var torrentInfo = (model.RemoteAlbum.Release as TorrentInfo) ?? new TorrentInfo();
-
- // TODO: Clean this mess up. don't mix data from multiple classes, use sub-resources instead? (Got a huge Deja Vu, didn't we talk about this already once?)
- return new ReleaseResource
- {
- Guid = releaseInfo.Guid,
- Quality = parsedAlbumInfo.Quality,
- //QualityWeight
- Age = releaseInfo.Age,
- AgeHours = releaseInfo.AgeHours,
- AgeMinutes = releaseInfo.AgeMinutes,
- Size = releaseInfo.Size,
- IndexerId = releaseInfo.IndexerId,
- Indexer = releaseInfo.Indexer,
- ReleaseGroup = parsedAlbumInfo.ReleaseGroup,
- ReleaseHash = parsedAlbumInfo.ReleaseHash,
- Title = releaseInfo.Title,
- Language = parsedAlbumInfo.Language,
- ReleaseDate = parsedAlbumInfo.ReleaseDate,
- ArtistName = parsedAlbumInfo.ArtistName,
- AlbumTitle = parsedAlbumInfo.AlbumTitle,
- Approved = model.Approved,
- TemporarilyRejected = model.TemporarilyRejected,
- Rejected = model.Rejected,
- Rejections = model.Rejections.Select(r => r.Reason).ToList(),
- PublishDate = releaseInfo.PublishDate,
- CommentUrl = releaseInfo.CommentUrl,
- DownloadUrl = releaseInfo.DownloadUrl,
- InfoUrl = releaseInfo.InfoUrl,
- DownloadAllowed = remoteAlbum.DownloadAllowed,
- //ReleaseWeight
-
- MagnetUrl = torrentInfo.MagnetUrl,
- InfoHash = torrentInfo.InfoHash,
- Seeders = torrentInfo.Seeders,
- Leechers = (torrentInfo.Peers.HasValue && torrentInfo.Seeders.HasValue) ? (torrentInfo.Peers.Value - torrentInfo.Seeders.Value) : (int?)null,
- Protocol = releaseInfo.DownloadProtocol,
- };
-
- }
-
- public static ReleaseInfo ToModel(this ReleaseResource resource)
- {
- ReleaseInfo model;
-
- if (resource.Protocol == DownloadProtocol.Torrent)
- {
- model = new TorrentInfo
- {
- MagnetUrl = resource.MagnetUrl,
- InfoHash = resource.InfoHash,
- Seeders = resource.Seeders,
- Peers = (resource.Seeders.HasValue && resource.Leechers.HasValue) ? (resource.Seeders + resource.Leechers) : null
- };
- }
- else
- {
- model = new ReleaseInfo();
- }
-
- model.Guid = resource.Guid;
- model.Title = resource.Title;
- model.Size = resource.Size;
- model.DownloadUrl = resource.DownloadUrl;
- model.InfoUrl = resource.InfoUrl;
- model.CommentUrl = resource.CommentUrl;
- model.IndexerId = resource.IndexerId;
- model.Indexer = resource.Indexer;
- model.DownloadProtocol = resource.DownloadProtocol;
- model.PublishDate = resource.PublishDate;
-
- return model;
- }
- }
-}
diff --git a/src/NzbDrone.Api/Logs/LogFileModule.cs b/src/NzbDrone.Api/Logs/LogFileModule.cs
deleted file mode 100644
index bed6f7de2..000000000
--- a/src/NzbDrone.Api/Logs/LogFileModule.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using System.Collections.Generic;
-using System.IO;
-using NzbDrone.Common.Disk;
-using NzbDrone.Common.EnvironmentInfo;
-using NzbDrone.Common.Extensions;
-using NzbDrone.Core.Configuration;
-
-namespace NzbDrone.Api.Logs
-{
- public class LogFileModule : LogFileModuleBase
- {
- private readonly IAppFolderInfo _appFolderInfo;
- private readonly IDiskProvider _diskProvider;
-
- public LogFileModule(IAppFolderInfo appFolderInfo,
- IDiskProvider diskProvider,
- IConfigFileProvider configFileProvider)
- : base(diskProvider, configFileProvider, "")
- {
- _appFolderInfo = appFolderInfo;
- _diskProvider = diskProvider;
- }
-
- protected override IEnumerable GetLogFiles()
- {
- return _diskProvider.GetFiles(_appFolderInfo.GetLogFolder(), SearchOption.TopDirectoryOnly);
- }
-
- protected override string GetLogFilePath(string filename)
- {
- return Path.Combine(_appFolderInfo.GetLogFolder(), filename);
- }
-
- protected override string DownloadUrlRoot => "logfile";
- }
-}
\ No newline at end of file
diff --git a/src/NzbDrone.Api/Logs/LogFileModuleBase.cs b/src/NzbDrone.Api/Logs/LogFileModuleBase.cs
deleted file mode 100644
index 4af69e543..000000000
--- a/src/NzbDrone.Api/Logs/LogFileModuleBase.cs
+++ /dev/null
@@ -1,72 +0,0 @@
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using NzbDrone.Common.Disk;
-using Nancy;
-using Nancy.Responses;
-using NzbDrone.Core.Configuration;
-using Lidarr.Http;
-
-namespace NzbDrone.Api.Logs
-{
- public abstract class LogFileModuleBase : LidarrRestModule
- {
- protected const string LOGFILE_ROUTE = @"/(?[-.a-zA-Z0-9]+?\.txt)";
-
- private readonly IDiskProvider _diskProvider;
- private readonly IConfigFileProvider _configFileProvider;
-
- public LogFileModuleBase(IDiskProvider diskProvider,
- IConfigFileProvider configFileProvider,
- string route)
- : base("log/file" + route)
- {
- _diskProvider = diskProvider;
- _configFileProvider = configFileProvider;
- GetResourceAll = GetLogFilesResponse;
-
- Get[LOGFILE_ROUTE] = options => GetLogFileResponse(options.filename);
- }
-
- private List GetLogFilesResponse()
- {
- var result = new List();
-
- var files = GetLogFiles().ToList();
-
- for (int i = 0; i < files.Count; i++)
- {
- var file = files[i];
- var filename = Path.GetFileName(file);
-
- result.Add(new LogFileResource
- {
- Id = i + 1,
- Filename = filename,
- LastWriteTime = _diskProvider.FileGetLastWrite(file),
- ContentsUrl = string.Format("{0}/api/{1}/{2}", _configFileProvider.UrlBase, Resource, filename),
- DownloadUrl = string.Format("{0}/{1}/{2}", _configFileProvider.UrlBase, DownloadUrlRoot, filename)
- });
- }
-
- return result.OrderByDescending(l => l.LastWriteTime).ToList();
- }
-
- private Response GetLogFileResponse(string filename)
- {
- var filePath = GetLogFilePath(filename);
-
- if (!_diskProvider.FileExists(filePath))
- return new NotFoundResponse();
-
- var data = _diskProvider.ReadAllText(filePath);
-
- return new TextResponse(data);
- }
-
- protected abstract IEnumerable GetLogFiles();
- protected abstract string GetLogFilePath(string filename);
-
- protected abstract string DownloadUrlRoot { get; }
- }
-}
diff --git a/src/NzbDrone.Api/Logs/LogFileResource.cs b/src/NzbDrone.Api/Logs/LogFileResource.cs
deleted file mode 100644
index e0ccc1924..000000000
--- a/src/NzbDrone.Api/Logs/LogFileResource.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-using System;
-using Lidarr.Http.REST;
-
-namespace NzbDrone.Api.Logs
-{
- public class LogFileResource : RestResource
- {
- public string Filename { get; set; }
- public DateTime LastWriteTime { get; set; }
- public string ContentsUrl { get; set; }
- public string DownloadUrl { get; set; }
- }
-}
diff --git a/src/NzbDrone.Api/Logs/LogModule.cs b/src/NzbDrone.Api/Logs/LogModule.cs
deleted file mode 100644
index 323333132..000000000
--- a/src/NzbDrone.Api/Logs/LogModule.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-using NzbDrone.Core.Instrumentation;
-using Lidarr.Http;
-using Lidarr.Http.Mapping;
-
-namespace NzbDrone.Api.Logs
-{
- public class LogModule : LidarrRestModule
- {
- private readonly ILogService _logService;
-
- public LogModule(ILogService logService)
- {
- _logService = logService;
- GetResourcePaged = GetLogs;
- }
-
- private PagingResource GetLogs(PagingResource pagingResource)
- {
- var pageSpec = pagingResource.MapToPagingSpec();
-
- if (pageSpec.SortKey == "time")
- {
- pageSpec.SortKey = "id";
- }
-
- if (pagingResource.FilterKey == "level")
- {
- switch (pagingResource.FilterValue)
- {
- case "Fatal":
- pageSpec.FilterExpression = h => h.Level == "Fatal";
- break;
- case "Error":
- pageSpec.FilterExpression = h => h.Level == "Fatal" || h.Level == "Error";
- break;
- case "Warn":
- pageSpec.FilterExpression = h => h.Level == "Fatal" || h.Level == "Error" || h.Level == "Warn";
- break;
- case "Info":
- pageSpec.FilterExpression = h => h.Level == "Fatal" || h.Level == "Error" || h.Level == "Warn" || h.Level == "Info";
- break;
- case "Debug":
- pageSpec.FilterExpression = h => h.Level == "Fatal" || h.Level == "Error" || h.Level == "Warn" || h.Level == "Info" || h.Level == "Debug";
- break;
- case "Trace":
- pageSpec.FilterExpression = h => h.Level == "Fatal" || h.Level == "Error" || h.Level == "Warn" || h.Level == "Info" || h.Level == "Debug" || h.Level == "Trace";
- break;
- }
- }
-
- return ApplyToPage(_logService.Paged, pageSpec, LogResourceMapper.ToResource);
- }
- }
-}
diff --git a/src/NzbDrone.Api/Logs/LogResource.cs b/src/NzbDrone.Api/Logs/LogResource.cs
deleted file mode 100644
index 4f98dfeb8..000000000
--- a/src/NzbDrone.Api/Logs/LogResource.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-using System;
-using Lidarr.Http.REST;
-
-namespace NzbDrone.Api.Logs
-{
- public class LogResource : RestResource
- {
- public DateTime Time { get; set; }
- public string Exception { get; set; }
- public string ExceptionType { get; set; }
- public string Level { get; set; }
- public string Logger { get; set; }
- public string Message { get; set; }
- }
-
- public static class LogResourceMapper
- {
- public static LogResource ToResource(this Core.Instrumentation.Log model)
- {
- if (model == null) return null;
-
- return new LogResource
- {
- Id = model.Id,
-
- Time = model.Time,
- Exception = model.Exception,
- ExceptionType = model.ExceptionType,
- Level = model.Level,
- Logger = model.Logger,
- Message = model.Message
- };
- }
- }
-}
diff --git a/src/NzbDrone.Api/Logs/UpdateLogFileModule.cs b/src/NzbDrone.Api/Logs/UpdateLogFileModule.cs
deleted file mode 100644
index 5c4f81f02..000000000
--- a/src/NzbDrone.Api/Logs/UpdateLogFileModule.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Text.RegularExpressions;
-using NzbDrone.Common.Disk;
-using NzbDrone.Common.EnvironmentInfo;
-using NzbDrone.Common.Extensions;
-using NzbDrone.Core.Configuration;
-
-namespace NzbDrone.Api.Logs
-{
- public class UpdateLogFileModule : LogFileModuleBase
- {
- private readonly IAppFolderInfo _appFolderInfo;
- private readonly IDiskProvider _diskProvider;
-
- public UpdateLogFileModule(IAppFolderInfo appFolderInfo,
- IDiskProvider diskProvider,
- IConfigFileProvider configFileProvider)
- : base(diskProvider, configFileProvider, "/update")
- {
- _appFolderInfo = appFolderInfo;
- _diskProvider = diskProvider;
- }
-
- protected override IEnumerable GetLogFiles()
- {
- if (!_diskProvider.FolderExists(_appFolderInfo.GetUpdateLogFolder())) return Enumerable.Empty();
-
- return _diskProvider.GetFiles(_appFolderInfo.GetUpdateLogFolder(), SearchOption.TopDirectoryOnly)
- .Where(f => Regex.IsMatch(Path.GetFileName(f), LOGFILE_ROUTE.TrimStart('/'), RegexOptions.IgnoreCase))
- .ToList();
- }
-
- protected override string GetLogFilePath(string filename)
- {
- return Path.Combine(_appFolderInfo.GetUpdateLogFolder(), filename);
- }
-
- protected override string DownloadUrlRoot => "updatelogfile";
- }
-}
\ No newline at end of file
diff --git a/src/NzbDrone.Api/ManualImport/ManualImportModule.cs b/src/NzbDrone.Api/ManualImport/ManualImportModule.cs
deleted file mode 100644
index 1b2201c4b..000000000
--- a/src/NzbDrone.Api/ManualImport/ManualImportModule.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-using System.Collections.Generic;
-using System.Linq;
-using NzbDrone.Core.MediaFiles.TrackImport.Manual;
-using NzbDrone.Core.Qualities;
-using Lidarr.Http;
-
-namespace NzbDrone.Api.ManualImport
-{
- public class ManualImportModule : LidarrRestModule
- {
- private readonly IManualImportService _manualImportService;
-
- public ManualImportModule(IManualImportService manualImportService)
- : base("/manualimport")
- {
- _manualImportService = manualImportService;
-
- GetResourceAll = GetMediaFiles;
- }
-
- private List GetMediaFiles()
- {
- var folderQuery = Request.Query.folder;
- var folder = (string)folderQuery.Value;
-
- var downloadIdQuery = Request.Query.downloadId;
- var downloadId = (string)downloadIdQuery.Value;
-
- return _manualImportService.GetMediaFiles(folder, downloadId).ToResource().Select(AddQualityWeight).ToList();
- }
-
- private ManualImportResource AddQualityWeight(ManualImportResource item)
- {
- if (item.Quality != null)
- {
- item.QualityWeight = Quality.DefaultQualityDefinitions.Single(q => q.Quality == item.Quality.Quality).Weight;
- item.QualityWeight += item.Quality.Revision.Real * 10;
- item.QualityWeight += item.Quality.Revision.Version;
- }
-
- return item;
- }
- }
-}
diff --git a/src/NzbDrone.Api/ManualImport/ManualImportResource.cs b/src/NzbDrone.Api/ManualImport/ManualImportResource.cs
deleted file mode 100644
index 7a7dad567..000000000
--- a/src/NzbDrone.Api/ManualImport/ManualImportResource.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-using System.Collections.Generic;
-using System.Linq;
-using NzbDrone.Api.Episodes;
-using Lidarr.Http.REST;
-using NzbDrone.Api.Series;
-using NzbDrone.Common.Crypto;
-using NzbDrone.Core.DecisionEngine;
-using NzbDrone.Core.Qualities;
-
-namespace NzbDrone.Api.ManualImport
-{
- public class ManualImportResource : RestResource
- {
- public string Path { get; set; }
- public string RelativePath { get; set; }
- public string Name { get; set; }
- public long Size { get; set; }
- public QualityModel Quality { get; set; }
- public int QualityWeight { get; set; }
- public string DownloadId { get; set; }
- public IEnumerable Rejections { get; set; }
- }
-
- public static class ManualImportResourceMapper
- {
- public static ManualImportResource ToResource(this Core.MediaFiles.TrackImport.Manual.ManualImportItem model)
- {
- if (model == null) return null;
-
- return new ManualImportResource
- {
- Id = HashConverter.GetHashInt31(model.Path),
-
- Path = model.Path,
- RelativePath = model.RelativePath,
- Name = model.Name,
- Size = model.Size,
- Quality = model.Quality,
- //QualityWeight
- DownloadId = model.DownloadId,
- Rejections = model.Rejections
- };
- }
-
- public static List ToResource(this IEnumerable models)
- {
- return models.Select(ToResource).ToList();
- }
- }
-}
diff --git a/src/NzbDrone.Api/MediaCovers/MediaCoverModule.cs b/src/NzbDrone.Api/MediaCovers/MediaCoverModule.cs
deleted file mode 100644
index a4ad78ef4..000000000
--- a/src/NzbDrone.Api/MediaCovers/MediaCoverModule.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-using System.IO;
-using System.Text.RegularExpressions;
-using Nancy;
-using Nancy.Responses;
-using NzbDrone.Common.Disk;
-using NzbDrone.Common.EnvironmentInfo;
-using NzbDrone.Common.Extensions;
-
-namespace NzbDrone.Api.MediaCovers
-{
- public class MediaCoverModule : NzbDroneApiModule
- {
- private static readonly Regex RegexResizedImage = new Regex(@"-\d+\.jpg$", RegexOptions.Compiled | RegexOptions.IgnoreCase);
-
- private const string MEDIA_COVER_ROUTE = @"/(?\d+)/(?(.+)\.(jpg|png|gif))";
-
- private readonly IAppFolderInfo _appFolderInfo;
- private readonly IDiskProvider _diskProvider;
-
- public MediaCoverModule(IAppFolderInfo appFolderInfo, IDiskProvider diskProvider) : base("MediaCover")
- {
- _appFolderInfo = appFolderInfo;
- _diskProvider = diskProvider;
-
- Get[MEDIA_COVER_ROUTE] = options => GetMediaCover(options.seriesId, options.filename);
- }
-
- private Response GetMediaCover(int seriesId, string filename)
- {
- var filePath = Path.Combine(_appFolderInfo.GetAppDataPath(), "MediaCover", seriesId.ToString(), filename);
-
- if (!_diskProvider.FileExists(filePath) || _diskProvider.GetFileSize(filePath) == 0)
- {
- // Return the full sized image if someone requests a non-existing resized one.
- // TODO: This code can be removed later once everyone had the update for a while.
- var basefilePath = RegexResizedImage.Replace(filePath, ".jpg");
- if (basefilePath == filePath || !_diskProvider.FileExists(basefilePath))
- {
- return new NotFoundResponse();
- }
- filePath = basefilePath;
- }
-
- return new StreamResponse(() => File.OpenRead(filePath), MimeTypes.GetMimeType(filePath));
- }
- }
-}
diff --git a/src/NzbDrone.Api/Metadata/MetadataModule.cs b/src/NzbDrone.Api/Metadata/MetadataModule.cs
deleted file mode 100644
index ab88ab044..000000000
--- a/src/NzbDrone.Api/Metadata/MetadataModule.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-using NzbDrone.Core.Extras.Metadata;
-
-namespace NzbDrone.Api.Metadata
-{
- public class MetadataModule : ProviderModuleBase
- {
- public MetadataModule(IMetadataFactory metadataFactory)
- : base(metadataFactory, "metadata")
- {
- }
-
- protected override void MapToResource(MetadataResource resource, MetadataDefinition definition)
- {
- base.MapToResource(resource, definition);
-
- resource.Enable = definition.Enable;
- }
-
- protected override void MapToModel(MetadataDefinition definition, MetadataResource resource)
- {
- base.MapToModel(definition, resource);
-
- definition.Enable = resource.Enable;
- }
-
- protected override void Validate(MetadataDefinition definition, bool includeWarnings)
- {
- if (!definition.Enable) return;
- base.Validate(definition, includeWarnings);
- }
- }
-}
\ No newline at end of file
diff --git a/src/NzbDrone.Api/Metadata/MetadataResource.cs b/src/NzbDrone.Api/Metadata/MetadataResource.cs
deleted file mode 100644
index fa9f58b64..000000000
--- a/src/NzbDrone.Api/Metadata/MetadataResource.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace NzbDrone.Api.Metadata
-{
- public class MetadataResource : ProviderResource
- {
- public bool Enable { get; set; }
- }
-}
\ No newline at end of file
diff --git a/src/NzbDrone.Api/Music/ArtistBulkImportModule.cs b/src/NzbDrone.Api/Music/ArtistBulkImportModule.cs
deleted file mode 100644
index fe0a4542d..000000000
--- a/src/NzbDrone.Api/Music/ArtistBulkImportModule.cs
+++ /dev/null
@@ -1,153 +0,0 @@
-using System.Collections;
-using System.Collections.Generic;
-using Nancy;
-using Lidarr.Http.REST;
-using Lidarr.Http.Extensions;
-using NzbDrone.Core.MediaCover;
-using NzbDrone.Core.MetadataSource;
-using NzbDrone.Core.Parser;
-using System.Linq;
-using System;
-using Marr.Data;
-using NzbDrone.Common.Extensions;
-using NzbDrone.Core.Datastore;
-using NzbDrone.Core.MediaFiles;
-using NzbDrone.Core.MediaFiles.TrackImport;
-using NzbDrone.Core.RootFolders;
-using NzbDrone.Common.Cache;
-using NzbDrone.Core.Music;
-using Lidarr.Http;
-
-namespace NzbDrone.Api.Music
-{
-
- public class UnmappedComparer : IComparer
- {
- public int Compare(UnmappedFolder a, UnmappedFolder b)
- {
- return a.Name.CompareTo(b.Name);
- }
- }
-
- public class MusicBulkImportModule : LidarrRestModule
- {
- private readonly ISearchForNewArtist _searchProxy;
- private readonly IRootFolderService _rootFolderService;
- private readonly IMakeImportDecision _importDecisionMaker;
- private readonly IDiskScanService _diskScanService;
- private readonly ICached _mappedArtists;
- private readonly IArtistService _artistService;
-
- public MusicBulkImportModule(ISearchForNewArtist searchProxy,
- IRootFolderService rootFolderService,
- IMakeImportDecision importDecisionMaker,
- IDiskScanService diskScanService,
- ICacheManager cacheManager,
- IArtistService artistService
- )
- : base("/artist/bulkimport")
- {
- _searchProxy = searchProxy;
- _rootFolderService = rootFolderService;
- _importDecisionMaker = importDecisionMaker;
- _diskScanService = diskScanService;
- _mappedArtists = cacheManager.GetCache(GetType(), "mappedArtistsCache");
- _artistService = artistService;
- Get["/"] = x => Search();
- }
-
-
- private Response Search()
- {
- if (Request.Query.Id == 0)
- {
- throw new BadRequestException("Invalid Query");
- }
-
- RootFolder rootFolder = _rootFolderService.Get(Request.Query.Id);
-
- var unmapped = rootFolder.UnmappedFolders.OrderBy(f => f.Name).ToList();
-
- var paged = unmapped;
-
- var mapped = paged.Select(page =>
- {
- Artist m = null;
-
- var mappedArtist = _mappedArtists.Find(page.Name);
-
- if (mappedArtist != null)
- {
- return mappedArtist;
- }
-
- var files = _diskScanService.GetAudioFiles(page.Path);
-
- // Check for music files in directory
- if (files.Count() == 0)
- {
- return null;
- }
-
- var parsedTitle = Parser.ParseMusicPath(files.FirstOrDefault());
- if (parsedTitle == null || parsedTitle.ArtistTitle == null)
- {
- m = new Artist
- {
- Name = page.Name.Replace(".", " ").Replace("-", " "),
- Path = page.Path,
- };
- }
- else
- {
- m = new Artist
- {
- Name = parsedTitle.ArtistTitle,
- Path = page.Path
- };
- }
-
- var searchResults = _searchProxy.SearchForNewArtist(m.Name);
-
- if (searchResults == null || searchResults.Count == 0)
- {
- return null;
- };
-
- mappedArtist = searchResults.First();
-
- if (mappedArtist != null)
- {
- mappedArtist.Monitored = true;
- mappedArtist.Path = page.Path;
-
- _mappedArtists.Set(page.Name, mappedArtist, TimeSpan.FromDays(2));
-
- return mappedArtist;
- }
-
- return null;
- });
-
- var mapping = MapToResource(mapped.Where(m => m != null)).ToList().AsResponse();
-
- return mapping;
- }
-
-
- private static IEnumerable MapToResource(IEnumerable artists)
- {
- foreach (var currentArtist in artists)
- {
- var resource = currentArtist.ToResource();
- var poster = currentArtist.Images.FirstOrDefault(c => c.CoverType == MediaCoverTypes.Poster);
- if (poster != null)
- {
- resource.RemotePoster = poster.Url;
- }
-
- yield return resource;
- }
- }
- }
-}
diff --git a/src/NzbDrone.Api/Music/ArtistEditorModule.cs b/src/NzbDrone.Api/Music/ArtistEditorModule.cs
deleted file mode 100644
index 6d250f25e..000000000
--- a/src/NzbDrone.Api/Music/ArtistEditorModule.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-using System.Collections.Generic;
-using System.Linq;
-using Nancy;
-using Lidarr.Http.Extensions;
-using NzbDrone.Core.Music;
-
-namespace NzbDrone.Api.Music
-{
- public class ArtistEditorModule : NzbDroneApiModule
- {
- private readonly IArtistService _artistService;
-
- public ArtistEditorModule(IArtistService seriesService)
- : base("/artist/editor")
- {
- _artistService = seriesService;
- Put["/"] = artist => SaveAll();
- }
-
- private Response SaveAll()
- {
- var resources = Request.Body.FromJson>();
-
- var artist = resources.Select(artistResource => artistResource.ToModel(_artistService.GetArtist(artistResource.Id))).ToList();
-
- return _artistService.UpdateArtists(artist)
- .ToResource()
- .AsResponse(HttpStatusCode.Accepted);
- }
- }
-}
diff --git a/src/NzbDrone.Api/Music/ArtistLookupModule.cs b/src/NzbDrone.Api/Music/ArtistLookupModule.cs
deleted file mode 100644
index c7bec8f84..000000000
--- a/src/NzbDrone.Api/Music/ArtistLookupModule.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-using Nancy;
-using Lidarr.Http.Extensions;
-using NzbDrone.Core.MediaCover;
-using NzbDrone.Core.MetadataSource;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Lidarr.Http;
-
-namespace NzbDrone.Api.Music
-{
- public class ArtistLookupModule : LidarrRestModule
- {
- private readonly ISearchForNewArtist _searchProxy;
-
- public ArtistLookupModule(ISearchForNewArtist searchProxy)
- : base("/artist/lookup")
- {
- _searchProxy = searchProxy;
- Get["/"] = x => Search();
- }
-
-
- private Response Search()
- {
- var iTunesResults = _searchProxy.SearchForNewArtist((string)Request.Query.term);
- return MapToResource(iTunesResults).AsResponse();
- }
-
-
- private static IEnumerable MapToResource(IEnumerable artists)
- {
- foreach (var currentArtist in artists)
- {
- var resource = currentArtist.ToResource();
- var poster = currentArtist.Images.FirstOrDefault(c => c.CoverType == MediaCoverTypes.Poster);
- if (poster != null)
- {
- resource.RemotePoster = poster.Url;
- }
-
- yield return resource;
- }
- }
- }
-}
diff --git a/src/NzbDrone.Api/Music/ArtistModule.cs b/src/NzbDrone.Api/Music/ArtistModule.cs
deleted file mode 100644
index 3e1b97b65..000000000
--- a/src/NzbDrone.Api/Music/ArtistModule.cs
+++ /dev/null
@@ -1,226 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using FluentValidation;
-using NzbDrone.Common.Extensions;
-using NzbDrone.Core.Datastore.Events;
-using NzbDrone.Core.MediaCover;
-using NzbDrone.Core.MediaFiles;
-using NzbDrone.Core.MediaFiles.Events;
-using NzbDrone.Core.Messaging.Events;
-using NzbDrone.Core.Music;
-using NzbDrone.Core.Music.Events;
-using NzbDrone.Core.ArtistStats;
-using NzbDrone.Core.Validation;
-using NzbDrone.Core.Validation.Paths;
-using NzbDrone.SignalR;
-using Lidarr.Http;
-using Lidarr.Http.Mapping;
-
-namespace NzbDrone.Api.Music
-{
- public class ArtistModule : LidarrRestModuleWithSignalR,
- IHandle,
- IHandle,
- IHandle,
- IHandle,
- IHandle,
- IHandle
- //IHandle
- {
- private readonly IArtistService _artistService;
- private readonly IAddArtistService _addArtistService;
- private readonly IArtistStatisticsService _artistStatisticsService;
- private readonly IMapCoversToLocal _coverMapper;
-
- public ArtistModule(IBroadcastSignalRMessage signalRBroadcaster,
- IArtistService artistService,
- IAddArtistService addArtistService,
- IArtistStatisticsService artistStatisticsService,
- IMapCoversToLocal coverMapper,
- RootFolderValidator rootFolderValidator,
- ArtistPathValidator seriesPathValidator,
- ArtistExistsValidator artistExistsValidator,
- SeriesAncestorValidator seriesAncestorValidator,
- ProfileExistsValidator profileExistsValidator,
- LanguageProfileExistsValidator languageProfileExistsValidator
- )
- : base(signalRBroadcaster)
- {
- _artistService = artistService;
- _addArtistService = addArtistService;
- _artistStatisticsService = artistStatisticsService;
-
- _coverMapper = coverMapper;
-
- GetResourceAll = AllArtist;
- GetResourceById = GetArtist;
- CreateResource = AddArtist;
- UpdateResource = UpdatArtist;
- DeleteResource = DeleteArtist;
-
- SharedValidator.RuleFor(s => s.ProfileId).ValidId();
- SharedValidator.RuleFor(s => s.LanguageProfileId);
-
- SharedValidator.RuleFor(s => s.Path)
- .Cascade(CascadeMode.StopOnFirstFailure)
- .IsValidPath()
- .SetValidator(rootFolderValidator)
- .SetValidator(seriesPathValidator)
- .SetValidator(seriesAncestorValidator)
- .When(s => !s.Path.IsNullOrWhiteSpace());
-
- SharedValidator.RuleFor(s => s.ProfileId).SetValidator(profileExistsValidator);
- SharedValidator.RuleFor(s => s.LanguageProfileId).SetValidator(languageProfileExistsValidator);
-
- PostValidator.RuleFor(s => s.Path).IsValidPath().When(s => s.RootFolderPath.IsNullOrWhiteSpace());
- PostValidator.RuleFor(s => s.RootFolderPath).IsValidPath().When(s => s.Path.IsNullOrWhiteSpace());
- PostValidator.RuleFor(s => s.ForeignArtistId).NotEqual("").SetValidator(artistExistsValidator);
-
- PutValidator.RuleFor(s => s.Path).IsValidPath();
- }
-
- private ArtistResource GetArtist(int id)
- {
- var artist = _artistService.GetArtist(id);
- return MapToResource(artist);
- }
-
- private ArtistResource MapToResource(Artist artist)
- {
- if (artist == null) return null;
-
- var resource = artist.ToResource();
- MapCoversToLocal(resource);
- FetchAndLinkArtistStatistics(resource);
- //PopulateAlternateTitles(resource);
-
- return resource;
- }
-
- private List AllArtist()
- {
- var artistStats = _artistStatisticsService.ArtistStatistics();
- var artistResources = _artistService.GetAllArtists().ToResource();
-
- MapCoversToLocal(artistResources.ToArray());
- LinkArtistStatistics(artistResources, artistStats);
- //PopulateAlternateTitles(seriesResources);
-
- return artistResources;
- }
-
- private int AddArtist(ArtistResource artistResource)
- {
- var model = artistResource.ToModel();
-
- return _addArtistService.AddArtist(model).Id;
- }
-
- private void UpdatArtist(ArtistResource artistResource)
- {
- var model = artistResource.ToModel(_artistService.GetArtist(artistResource.Id));
-
- _artistService.UpdateArtist(model);
-
- BroadcastResourceChange(ModelAction.Updated, artistResource.Id);
- }
-
- private void DeleteArtist(int id)
- {
- var deleteFiles = false;
- var deleteFilesQuery = Request.Query.deleteFiles;
-
- if (deleteFilesQuery.HasValue)
- {
- deleteFiles = Convert.ToBoolean(deleteFilesQuery.Value);
- }
-
- _artistService.DeleteArtist(id, deleteFiles);
- }
-
- private void MapCoversToLocal(params ArtistResource[] artists)
- {
- foreach (var artistResource in artists)
- {
- _coverMapper.ConvertToLocalUrls(artistResource.Id, artistResource.Images);
- }
- }
-
- private void FetchAndLinkArtistStatistics(ArtistResource resource)
- {
- LinkArtistStatistics(resource, _artistStatisticsService.ArtistStatistics(resource.Id));
- }
-
-
- private void LinkArtistStatistics(List resources, List artistStatistics)
- {
- var dictArtistStats = artistStatistics.ToDictionary(v => v.ArtistId);
-
- foreach (var artist in resources)
- {
- var stats = dictArtistStats.GetValueOrDefault(artist.Id);
- if (stats == null) continue;
-
- LinkArtistStatistics(artist, stats);
- }
- }
-
- private void LinkArtistStatistics(ArtistResource resource, ArtistStatistics artistStatistics)
- {
- resource.TotalTrackCount = artistStatistics.TotalTrackCount;
- resource.TrackCount = artistStatistics.TrackCount;
- resource.TrackFileCount = artistStatistics.TrackFileCount;
- resource.SizeOnDisk = artistStatistics.SizeOnDisk;
- resource.AlbumCount = artistStatistics.AlbumCount;
-
- //if (artistStatistics.AlbumStatistics != null)
- //{
- // var dictSeasonStats = artistStatistics.SeasonStatistics.ToDictionary(v => v.SeasonNumber);
-
- // foreach (var album in resource.Albums)
- // {
- // album.Statistics = dictSeasonStats.GetValueOrDefault(album.Id).ToResource();
- // }
- //}
- }
-
- public void Handle(TrackImportedEvent message)
- {
- BroadcastResourceChange(ModelAction.Updated, message.ImportedTrack.ArtistId);
- }
-
- public void Handle(TrackFileDeletedEvent message)
- {
- if (message.Reason == DeleteMediaFileReason.Upgrade) return;
-
- BroadcastResourceChange(ModelAction.Updated, message.TrackFile.ArtistId);
- }
-
- public void Handle(ArtistUpdatedEvent message)
- {
- BroadcastResourceChange(ModelAction.Updated, message.Artist.Id);
- }
-
- public void Handle(ArtistEditedEvent message)
- {
- BroadcastResourceChange(ModelAction.Updated, message.Artist.Id);
- }
-
- public void Handle(ArtistDeletedEvent message)
- {
- BroadcastResourceChange(ModelAction.Deleted, message.Artist.ToResource());
- }
-
- public void Handle(ArtistRenamedEvent message)
- {
- BroadcastResourceChange(ModelAction.Updated, message.Artist.Id);
- }
-
- //public void Handle(MediaCoversUpdatedEvent message)
- //{
- // BroadcastResourceChange(ModelAction.Updated, message.Artist.Id);
- //}
-
- }
-}
diff --git a/src/NzbDrone.Api/Music/ArtistResource.cs b/src/NzbDrone.Api/Music/ArtistResource.cs
deleted file mode 100644
index 47537cf71..000000000
--- a/src/NzbDrone.Api/Music/ArtistResource.cs
+++ /dev/null
@@ -1,189 +0,0 @@
-using Lidarr.Http.REST;
-using NzbDrone.Api.Albums;
-using NzbDrone.Core.MediaCover;
-using NzbDrone.Core.Music;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace NzbDrone.Api.Music
-{
- public class ArtistResource : RestResource
- {
- public ArtistResource()
- {
- Monitored = true;
- }
-
-
- //View Only
- public string Name { get; set; }
- public string ForeignArtistId { get; set; }
- public string MBId { get; set; }
- public int TADBId { get; set; }
- public int DiscogsId { get; set; }
- public string AllMusicId { get; set; }
- public string Overview { get; set; }
-
- public int? AlbumCount{ get; set; }
- public int? TotalTrackCount { get; set; }
- public int? TrackCount { get; set; }
- public int? TrackFileCount { get; set; }
- public long? SizeOnDisk { get; set; }
- //public SeriesStatusType Status { get; set; }
-
- public List Images { get; set; }
- public List Members { get; set; }
-
- public string RemotePoster { get; set; }
- public List Albums { get; set; }
-
-
- //View & Edit
- public string Path { get; set; }
- public int ProfileId { get; set; }
- public int LanguageProfileId { get; set; }
-
- //Editing Only
- public bool AlbumFolder { get; set; }
- public bool Monitored { get; set; }
-
- public string RootFolderPath { get; set; }
- //public string Certification { get; set; }
- public List Genres { get; set; }
- public string CleanName { get; set; }
- public string SortName { get; set; }
- public HashSet Tags { get; set; }
- public DateTime Added { get; set; }
- public AddArtistOptions AddOptions { get; set; }
- public Ratings Ratings { get; set; }
- public string NameSlug { get; set; }
- }
-
- public static class ArtistResourceMapper
- {
- public static ArtistResource ToResource(this Core.Music.Artist model)
- {
- if (model == null) return null;
-
- return new ArtistResource
- {
- Id = model.Id,
- MBId = model.MBId,
- TADBId = model.TADBId,
- DiscogsId = model.DiscogsId,
- AllMusicId = model.AMId,
- Name = model.Name,
- CleanName = model.CleanName,
-
- //AlternateTitles
- SortName = model.SortName,
-
- //TotalTrackCount
- //TrackCount
- //TrackFileCount
- //SizeOnDisk
- //Status = resource.Status,
- Overview = model.Overview,
- //NextAiring
- //PreviousAiring
- //Network = resource.Network,
- //AirTime = resource.AirTime,
- Images = model.Images,
- Members = model.Members,
- //Albums = model.Albums.ToResource(),
- //Year = resource.Year,
-
- Path = model.Path,
- ProfileId = model.ProfileId,
- LanguageProfileId = model.LanguageProfileId,
-
- Monitored = model.Monitored,
- AlbumFolder = model.AlbumFolder,
-
- //UseSceneNumbering = resource.UseSceneNumbering,
- //Runtime = resource.Runtime,
- //TvdbId = resource.TvdbId,
- //TvRageId = resource.TvRageId,
- //TvMazeId = resource.TvMazeId,
- //FirstAired = resource.FirstAired,
- //LastInfoSync = resource.LastInfoSync,
- //SeriesType = resource.SeriesType,
- ForeignArtistId = model.ForeignArtistId,
- NameSlug = model.NameSlug,
-
- RootFolderPath = model.RootFolderPath,
- Genres = model.Genres,
- Tags = model.Tags,
- Added = model.Added,
- AddOptions = model.AddOptions,
- Ratings = model.Ratings,
- };
- }
-
- public static Core.Music.Artist ToModel(this ArtistResource resource)
- {
- if (resource == null) return null;
-
- return new Core.Music.Artist
- {
- Id = resource.Id,
-
- Name = resource.Name,
- CleanName = resource.CleanName,
- //AlternateTitles
- SortName = resource.SortName,
- MBId = resource.MBId,
- TADBId = resource.TADBId,
- DiscogsId = resource.DiscogsId,
- AMId = resource.AllMusicId, //TODO change model and DB to AllMusic instead of AM
- //TotalEpisodeCount
- //TrackCount
- //TrackFileCount
- //SizeOnDisk
- //Status = resource.Status,
- Overview = resource.Overview,
- //NextAiring
- //PreviousAiring
- //Network = resource.Network,
- //AirTime = resource.AirTime,
- Images = resource.Images,
- Members = resource.Members,
- //Albums = resource.Albums.ToModel(),
- //Year = resource.Year,
-
- Path = resource.Path,
- ProfileId = resource.ProfileId,
- LanguageProfileId = resource.LanguageProfileId,
- AlbumFolder = resource.AlbumFolder,
-
- Monitored = resource.Monitored,
- //LastInfoSync = resource.LastInfoSync,
- ForeignArtistId = resource.ForeignArtistId,
- NameSlug = resource.NameSlug,
-
- RootFolderPath = resource.RootFolderPath,
- Genres = resource.Genres,
- Tags = resource.Tags,
- Added = resource.Added,
- AddOptions = resource.AddOptions,
- Ratings = resource.Ratings
- };
- }
-
- public static Core.Music.Artist ToModel(this ArtistResource resource, Core.Music.Artist artist)
- {
- var updatedArtist = resource.ToModel();
-
- artist.ApplyChanges(updatedArtist);
-
- return artist;
- }
-
- public static List ToResource(this IEnumerable artist)
- {
- return artist.Select(ToResource).ToList();
- }
- }
-}
diff --git a/src/NzbDrone.Api/Music/ListImport.cs b/src/NzbDrone.Api/Music/ListImport.cs
deleted file mode 100644
index 8488456fd..000000000
--- a/src/NzbDrone.Api/Music/ListImport.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-using System.Collections.Generic;
-using System.Linq;
-using Nancy;
-using Nancy.Extensions;
-using Lidarr.Http.Extensions;
-using NzbDrone.Core.Music;
-
-namespace NzbDrone.Api.Music
-{
- public class ListImportModule : NzbDroneApiModule
- {
- private readonly IAddArtistService _artistService;
-
- public ListImportModule(IAddArtistService artistService)
- : base("/artist/import")
- {
- _artistService = artistService;
- Put["/"] = Artist => SaveAll();
- }
-
- private Response SaveAll()
- {
- var resources = Request.Body.FromJson>();
-
- var Artists = resources.Select(ArtistResource => (ArtistResource.ToModel())).Where(m => m != null).DistinctBy(m => m.ForeignArtistId).ToList();
-
- return _artistService.AddArtists(Artists).ToResource().AsResponse(HttpStatusCode.Accepted);
- }
- }
-}
diff --git a/src/NzbDrone.Api/Notifications/NotificationModule.cs b/src/NzbDrone.Api/Notifications/NotificationModule.cs
deleted file mode 100644
index 88f42a043..000000000
--- a/src/NzbDrone.Api/Notifications/NotificationModule.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-using NzbDrone.Core.Notifications;
-
-namespace NzbDrone.Api.Notifications
-{
- public class NotificationModule : ProviderModuleBase
- {
- public NotificationModule(NotificationFactory notificationFactory)
- : base(notificationFactory, "notification")
- {
- }
-
- protected override void MapToResource(NotificationResource resource, NotificationDefinition definition)
- {
- base.MapToResource(resource, definition);
-
- resource.OnGrab = definition.OnGrab;
- resource.OnDownload = definition.OnDownload;
- resource.OnUpgrade = definition.OnUpgrade;
- resource.OnRename = definition.OnRename;
- resource.SupportsOnGrab = definition.SupportsOnGrab;
- resource.SupportsOnDownload = definition.SupportsOnDownload;
- resource.SupportsOnUpgrade = definition.SupportsOnUpgrade;
- resource.SupportsOnRename = definition.SupportsOnRename;
- resource.Tags = definition.Tags;
- }
-
- protected override void MapToModel(NotificationDefinition definition, NotificationResource resource)
- {
- base.MapToModel(definition, resource);
-
- definition.OnGrab = resource.OnGrab;
- definition.OnDownload = resource.OnDownload;
- definition.OnUpgrade = resource.OnUpgrade;
- definition.OnRename = resource.OnRename;
- definition.SupportsOnGrab = resource.SupportsOnGrab;
- definition.SupportsOnDownload = resource.SupportsOnDownload;
- definition.SupportsOnUpgrade = resource.SupportsOnUpgrade;
- definition.SupportsOnRename = resource.SupportsOnRename;
- definition.Tags = resource.Tags;
- }
-
- protected override void Validate(NotificationDefinition definition, bool includeWarnings)
- {
- if (!definition.OnGrab && !definition.OnDownload) return;
- base.Validate(definition, includeWarnings);
- }
- }
-}
\ No newline at end of file
diff --git a/src/NzbDrone.Api/Notifications/NotificationResource.cs b/src/NzbDrone.Api/Notifications/NotificationResource.cs
deleted file mode 100644
index f3fa11327..000000000
--- a/src/NzbDrone.Api/Notifications/NotificationResource.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-using System.Collections.Generic;
-
-namespace NzbDrone.Api.Notifications
-{
- public class NotificationResource : ProviderResource
- {
- public bool OnGrab { get; set; }
- public bool OnDownload { get; set; }
- public bool OnUpgrade { get; set; }
- public bool OnRename { get; set; }
- public bool SupportsOnGrab { get; set; }
- public bool SupportsOnDownload { get; set; }
- public bool SupportsOnUpgrade { get; set; }
- public bool SupportsOnRename { get; set; }
- public HashSet Tags { get; set; }
- }
-}
\ No newline at end of file
diff --git a/src/NzbDrone.Api/NzbDrone.Api.csproj b/src/NzbDrone.Api/NzbDrone.Api.csproj
deleted file mode 100644
index 5bff82b8d..000000000
--- a/src/NzbDrone.Api/NzbDrone.Api.csproj
+++ /dev/null
@@ -1,243 +0,0 @@
-
-
-
-
- Debug
- x86
- {FD286DF8-2D3A-4394-8AD5-443FADE55FB2}
- Library
- Properties
- NzbDrone.Api
- NzbDrone.Api
- v4.6.1
- 512
- ..\
- true
-
-
- 12.0.0
- 2.0
-
-
- true
- ..\..\_output\
- DEBUG;TRACE
- full
- x86
- prompt
- MinimumRecommendedRules.ruleset
- 4
- false
- false
-
-
- ..\..\_output\
- TRACE
- true
- pdbonly
- x86
- prompt
- MinimumRecommendedRules.ruleset
- 4
- false
-
-
-
- ..\packages\Ical.Net.2.2.32\lib\net46\antlr.runtime.dll
-
-
- ..\packages\FluentValidation.6.2.1.0\lib\Net45\FluentValidation.dll
-
-
- ..\packages\Ical.Net.2.2.32\lib\net46\Ical.Net.dll
-
-
- ..\packages\Ical.Net.2.2.32\lib\net46\Ical.Net.Collections.dll
-
-
- ..\packages\Nancy.1.4.4\lib\net40\Nancy.dll
-
-
- ..\packages\Nancy.Authentication.Basic.1.4.1\lib\net40\Nancy.Authentication.Basic.dll
-
-
- ..\packages\Nancy.Authentication.Forms.1.4.1\lib\net40\Nancy.Authentication.Forms.dll
-
-
- ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll
-
-
- ..\packages\NLog.4.4.3\lib\net45\NLog.dll
-
-
- ..\packages\Ical.Net.2.2.32\lib\net46\NodaTime.dll
-
-
-
-
-
-
- False
- ..\Libraries\Sqlite\System.Data.SQLite.dll
-
-
-
-
- Properties\SharedAssemblyInfo.cs
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {F6FC6BE7-0847-4817-A1ED-223DC647C3D7}
- Marr.Data
-
-
- {F2BE0FDF-6E47-4827-A420-DD4EF82407F8}
- NzbDrone.Common
-
-
- {FF5EE3B6-913B-47CE-9CEB-11C51B4E1205}
- NzbDrone.Core
-
-
- {7C2CC69F-5CA0-4E5C-85CB-983F9F6C3B36}
- NzbDrone.SignalR
-
-
- {5370bff7-1bd7-46bc-af06-7d9ea5cda1d6}
- Lidarr.Http
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/NzbDrone.Api/NzbDroneApiModule.cs b/src/NzbDrone.Api/NzbDroneApiModule.cs
deleted file mode 100644
index ad8131487..000000000
--- a/src/NzbDrone.Api/NzbDroneApiModule.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using Nancy;
-
-namespace NzbDrone.Api
-{
- public abstract class NzbDroneApiModule : NancyModule
- {
- protected NzbDroneApiModule(string resource)
- : base("/api/" + resource.Trim('/'))
- {
- }
- }
-}
\ No newline at end of file
diff --git a/src/NzbDrone.Api/NzbDroneFeedModule.cs b/src/NzbDrone.Api/NzbDroneFeedModule.cs
deleted file mode 100644
index d79307bef..000000000
--- a/src/NzbDrone.Api/NzbDroneFeedModule.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using Nancy;
-
-namespace NzbDrone.Api
-{
- public abstract class NzbDroneFeedModule : NancyModule
- {
- protected NzbDroneFeedModule(string resource)
- : base("/feed/" + resource.Trim('/'))
- {
- }
- }
-}
\ No newline at end of file
diff --git a/src/NzbDrone.Api/Parse/ParseModule.cs b/src/NzbDrone.Api/Parse/ParseModule.cs
deleted file mode 100644
index d3448d5ba..000000000
--- a/src/NzbDrone.Api/Parse/ParseModule.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-using NzbDrone.Api.Albums;
-using NzbDrone.Api.Music;
-using NzbDrone.Core.Parser;
-using Lidarr.Http;
-
-namespace NzbDrone.Api.Parse
-{
- public class ParseModule : LidarrRestModule
- {
- private readonly IParsingService _parsingService;
-
- public ParseModule(IParsingService parsingService)
- {
- _parsingService = parsingService;
-
- GetResourceSingle = Parse;
- }
-
- private ParseResource Parse()
- {
- var title = Request.Query.Title.Value as string;
- var parsedAlbumInfo = Parser.ParseAlbumTitle(title);
-
- if (parsedAlbumInfo == null)
- {
- return null;
- }
-
- var remoteAlbum = _parsingService.Map(parsedAlbumInfo);
-
- if (remoteAlbum != null)
- {
- return new ParseResource
- {
- Title = title,
- ParsedAlbumInfo = remoteAlbum.ParsedAlbumInfo,
- Artist = remoteAlbum.Artist.ToResource(),
- Albums = remoteAlbum.Albums.ToResource()
- };
- }
- else
- {
- return new ParseResource
- {
- Title = title,
- ParsedAlbumInfo = parsedAlbumInfo
- };
- }
- }
- }
-}
diff --git a/src/NzbDrone.Api/Parse/ParseResource.cs b/src/NzbDrone.Api/Parse/ParseResource.cs
deleted file mode 100644
index 91ab9adb6..000000000
--- a/src/NzbDrone.Api/Parse/ParseResource.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-using System.Collections.Generic;
-using Lidarr.Http.REST;
-using NzbDrone.Api.Music;
-using NzbDrone.Api.Albums;
-using NzbDrone.Core.Parser.Model;
-
-namespace NzbDrone.Api.Parse
-{
- public class ParseResource : RestResource
- {
- public string Title { get; set; }
- public ParsedAlbumInfo ParsedAlbumInfo { get; set; }
- public ArtistResource Artist { get; set; }
- public List Albums { get; set; }
- }
-}
diff --git a/src/NzbDrone.Api/Profiles/Delay/DelayProfileModule.cs b/src/NzbDrone.Api/Profiles/Delay/DelayProfileModule.cs
deleted file mode 100644
index 61aa00ea3..000000000
--- a/src/NzbDrone.Api/Profiles/Delay/DelayProfileModule.cs
+++ /dev/null
@@ -1,76 +0,0 @@
-using System.Collections.Generic;
-using FluentValidation;
-using FluentValidation.Results;
-using Lidarr.Http.REST;
-using Lidarr.Http.Validation;
-using NzbDrone.Core.Profiles.Delay;
-using Lidarr.Http;
-
-namespace NzbDrone.Api.Profiles.Delay
-{
- public class DelayProfileModule : LidarrRestModule
- {
- private readonly IDelayProfileService _delayProfileService;
-
- public DelayProfileModule(IDelayProfileService delayProfileService, DelayProfileTagInUseValidator tagInUseValidator)
- {
- _delayProfileService = delayProfileService;
-
- GetResourceAll = GetAll;
- GetResourceById = GetById;
- UpdateResource = Update;
- CreateResource = Create;
- DeleteResource = DeleteProfile;
-
- SharedValidator.RuleFor(d => d.Tags).NotEmpty().When(d => d.Id != 1);
- SharedValidator.RuleFor(d => d.Tags).EmptyCollection().When(d => d.Id == 1);
- SharedValidator.RuleFor(d => d.Tags).SetValidator(tagInUseValidator);
- SharedValidator.RuleFor(d => d.UsenetDelay).GreaterThanOrEqualTo(0);
- SharedValidator.RuleFor(d => d.TorrentDelay).GreaterThanOrEqualTo(0);
-
- SharedValidator.Custom(delayProfile =>
- {
- if (!delayProfile.EnableUsenet && !delayProfile.EnableTorrent)
- {
- return new ValidationFailure("", "Either Usenet or Torrent should be enabled");
- }
-
- return null;
- });
- }
-
- private int Create(DelayProfileResource resource)
- {
- var model = resource.ToModel();
- model = _delayProfileService.Add(model);
-
- return model.Id;
- }
-
- private void DeleteProfile(int id)
- {
- if (id == 1)
- {
- throw new MethodNotAllowedException("Cannot delete global delay profile");
- }
-
- _delayProfileService.Delete(id);
- }
-
- private void Update(DelayProfileResource resource)
- {
- var model = resource.ToModel();
- _delayProfileService.Update(model);
- }
-
- private DelayProfileResource GetById(int id)
- {
- return _delayProfileService.Get(id).ToResource();
- }
-
- private List GetAll()
- {
- return _delayProfileService.All().ToResource();
- }
- }
-}
diff --git a/src/NzbDrone.Api/Profiles/Delay/DelayProfileResource.cs b/src/NzbDrone.Api/Profiles/Delay/DelayProfileResource.cs
deleted file mode 100644
index cfc1f39b9..000000000
--- a/src/NzbDrone.Api/Profiles/Delay/DelayProfileResource.cs
+++ /dev/null
@@ -1,63 +0,0 @@
-using System.Collections.Generic;
-using System.Linq;
-using Lidarr.Http.REST;
-using NzbDrone.Core.Indexers;
-using NzbDrone.Core.Profiles.Delay;
-
-namespace NzbDrone.Api.Profiles.Delay
-{
- public class DelayProfileResource : RestResource
- {
- public bool EnableUsenet { get; set; }
- public bool EnableTorrent { get; set; }
- public DownloadProtocol PreferredProtocol { get; set; }
- public int UsenetDelay { get; set; }
- public int TorrentDelay { get; set; }
- public int Order { get; set; }
- public HashSet Tags { get; set; }
- }
-
- public static class DelayProfileResourceMapper
- {
- public static DelayProfileResource ToResource(this DelayProfile model)
- {
- if (model == null) return null;
-
- return new DelayProfileResource
- {
- Id = model.Id,
-
- EnableUsenet = model.EnableUsenet,
- EnableTorrent = model.EnableTorrent,
- PreferredProtocol = model.PreferredProtocol,
- UsenetDelay = model.UsenetDelay,
- TorrentDelay = model.TorrentDelay,
- Order = model.Order,
- Tags = new HashSet(model.Tags)
- };
- }
-
- public static DelayProfile ToModel(this DelayProfileResource resource)
- {
- if (resource == null) return null;
-
- return new DelayProfile
- {
- Id = resource.Id,
-
- EnableUsenet = resource.EnableUsenet,
- EnableTorrent = resource.EnableTorrent,
- PreferredProtocol = resource.PreferredProtocol,
- UsenetDelay = resource.UsenetDelay,
- TorrentDelay = resource.TorrentDelay,
- Order = resource.Order,
- Tags = new HashSet(resource.Tags)
- };
- }
-
- public static List ToResource(this IEnumerable models)
- {
- return models.Select(ToResource).ToList();
- }
- }
-}
diff --git a/src/NzbDrone.Api/Profiles/Languages/LanguageModule.cs b/src/NzbDrone.Api/Profiles/Languages/LanguageModule.cs
deleted file mode 100644
index 63cc61362..000000000
--- a/src/NzbDrone.Api/Profiles/Languages/LanguageModule.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using NzbDrone.Core.Languages;
-using Lidarr.Http;
-
-namespace NzbDrone.Api.Profiles.Languages
-{
- public class LanguageModule : LidarrRestModule
- {
- public LanguageModule()
- {
- GetResourceAll = GetAll;
- GetResourceById = GetById;
- }
-
- private LanguageResource GetById(int id)
- {
- var language = (Language)id;
-
- return new LanguageResource
- {
- Id = (int)language,
- Name = language.ToString()
- };
- }
-
- private List GetAll()
- {
- return ((Language[])Enum.GetValues(typeof (Language)))
- .Select(l => new LanguageResource
- {
- Id = (int) l,
- Name = l.ToString()
- })
- .OrderBy(l => l.Name)
- .ToList();
- }
- }
-}
diff --git a/src/NzbDrone.Api/Profiles/Languages/LanguageResource.cs b/src/NzbDrone.Api/Profiles/Languages/LanguageResource.cs
deleted file mode 100644
index ca1b81aed..000000000
--- a/src/NzbDrone.Api/Profiles/Languages/LanguageResource.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-using Newtonsoft.Json;
-using Lidarr.Http.REST;
-
-namespace NzbDrone.Api.Profiles.Languages
-{
- public class LanguageResource : RestResource
- {
- [JsonProperty(DefaultValueHandling = DefaultValueHandling.Include)]
- public new int Id { get; set; }
- public string Name { get; set; }
- public string NameLower => Name.ToLowerInvariant();
- }
-}
diff --git a/src/NzbDrone.Api/Profiles/LegacyProfileModule.cs b/src/NzbDrone.Api/Profiles/LegacyProfileModule.cs
deleted file mode 100644
index d0e6b744e..000000000
--- a/src/NzbDrone.Api/Profiles/LegacyProfileModule.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-using System.Text;
-using Nancy;
-
-namespace NzbDrone.Api.Profiles
-{
- class LegacyProfileModule : NzbDroneApiModule
- {
- public LegacyProfileModule()
- : base("qualityprofile")
- {
- Get["/"] = x =>
- {
- string queryString = ConvertQueryParams(Request.Query);
- var url = string.Format("/api/profile?{0}", queryString);
-
- return Response.AsRedirect(url);
- };
- }
-
- private string ConvertQueryParams(DynamicDictionary query)
- {
- var sb = new StringBuilder();
-
- foreach (var key in query)
- {
- var value = query[key];
-
- sb.AppendFormat("&{0}={1}", key, value);
- }
-
- return sb.ToString().Trim('&');
- }
- }
-}
diff --git a/src/NzbDrone.Api/Profiles/ProfileModule.cs b/src/NzbDrone.Api/Profiles/ProfileModule.cs
deleted file mode 100644
index 35a51c82b..000000000
--- a/src/NzbDrone.Api/Profiles/ProfileModule.cs
+++ /dev/null
@@ -1,57 +0,0 @@
-using System.Collections.Generic;
-using FluentValidation;
-using NzbDrone.Core.Profiles.Qualities;
-using NzbDrone.Core.Validation;
-using Lidarr.Http;
-using Lidarr.Http.Mapping;
-
-namespace NzbDrone.Api.Profiles
-{
- public class ProfileModule : LidarrRestModule
- {
- private readonly IProfileService _profileService;
-
- public ProfileModule(IProfileService profileService)
- {
- _profileService = profileService;
- SharedValidator.RuleFor(c => c.Name).NotEmpty();
- SharedValidator.RuleFor(c => c.Cutoff).NotNull();
- SharedValidator.RuleFor(c => c.Items).MustHaveAllowedQuality();
-
- GetResourceAll = GetAll;
- GetResourceById = GetById;
- UpdateResource = Update;
- CreateResource = Create;
- DeleteResource = DeleteProfile;
- }
-
- private int Create(ProfileResource resource)
- {
- var model = resource.ToModel();
-
- return _profileService.Add(model).Id;
- }
-
- private void DeleteProfile(int id)
- {
- _profileService.Delete(id);
- }
-
- private void Update(ProfileResource resource)
- {
- var model = resource.ToModel();
-
- _profileService.Update(model);
- }
-
- private ProfileResource GetById(int id)
- {
- return _profileService.Get(id).ToResource();
- }
-
- private List GetAll()
- {
- return _profileService.All().ToResource();
- }
- }
-}
diff --git a/src/NzbDrone.Api/Profiles/ProfileResource.cs b/src/NzbDrone.Api/Profiles/ProfileResource.cs
deleted file mode 100644
index 3660cbec0..000000000
--- a/src/NzbDrone.Api/Profiles/ProfileResource.cs
+++ /dev/null
@@ -1,81 +0,0 @@
-using System.Collections.Generic;
-using System.Linq;
-using Lidarr.Http.REST;
-using NzbDrone.Core.Parser;
-using NzbDrone.Core.Profiles;
-using NzbDrone.Core.Profiles.Qualities;
-using NzbDrone.Core.Qualities;
-
-namespace NzbDrone.Api.Profiles
-{
- public class ProfileResource : RestResource
- {
- public string Name { get; set; }
- public Quality Cutoff { get; set; }
- public List Items { get; set; }
- }
-
- public class ProfileQualityItemResource : RestResource
- {
- public Quality Quality { get; set; }
- public bool Allowed { get; set; }
- }
-
- public static class ProfileResourceMapper
- {
- public static ProfileResource ToResource(this Profile model)
- {
- if (model == null) return null;
-
- return new ProfileResource
- {
- Id = model.Id,
-
- Name = model.Name,
- Cutoff = model.Cutoff,
- Items = model.Items.ConvertAll(ToResource)
- };
- }
-
- public static ProfileQualityItemResource ToResource(this ProfileQualityItem model)
- {
- if (model == null) return null;
-
- return new ProfileQualityItemResource
- {
- Quality = model.Quality,
- Allowed = model.Allowed
- };
- }
-
- public static Profile ToModel(this ProfileResource resource)
- {
- if (resource == null) return null;
-
- return new Profile
- {
- Id = resource.Id,
-
- Name = resource.Name,
- Cutoff = (Quality)resource.Cutoff.Id,
- Items = resource.Items.ConvertAll(ToModel)
- };
- }
-
- public static ProfileQualityItem ToModel(this ProfileQualityItemResource resource)
- {
- if (resource == null) return null;
-
- return new ProfileQualityItem
- {
- Quality = (Quality)resource.Quality.Id,
- Allowed = resource.Allowed
- };
- }
-
- public static List ToResource(this IEnumerable models)
- {
- return models.Select(ToResource).ToList();
- }
- }
-}
diff --git a/src/NzbDrone.Api/Profiles/ProfileSchemaModule.cs b/src/NzbDrone.Api/Profiles/ProfileSchemaModule.cs
deleted file mode 100644
index da8cb5797..000000000
--- a/src/NzbDrone.Api/Profiles/ProfileSchemaModule.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-using System.Collections.Generic;
-using System.Linq;
-using NzbDrone.Core.Parser;
-using NzbDrone.Core.Profiles.Qualities;
-using NzbDrone.Core.Qualities;
-using Lidarr.Http;
-using Lidarr.Http.Mapping;
-
-namespace NzbDrone.Api.Profiles
-{
- public class ProfileSchemaModule : LidarrRestModule
- {
- private readonly IQualityDefinitionService _qualityDefinitionService;
-
- public ProfileSchemaModule(IQualityDefinitionService qualityDefinitionService)
- : base("/profile/schema")
- {
- _qualityDefinitionService = qualityDefinitionService;
-
- GetResourceAll = GetAll;
- }
-
- private List GetAll()
- {
- var items = _qualityDefinitionService.All()
- .OrderBy(v => v.Weight)
- .Select(v => new ProfileQualityItem { Quality = v.Quality, Allowed = false })
- .ToList();
-
- var profile = new Profile();
- profile.Cutoff = Quality.Unknown;
- profile.Items = items;
-
- return new List { profile.ToResource() };
- }
- }
-}
diff --git a/src/NzbDrone.Api/Profiles/ProfileValidation.cs b/src/NzbDrone.Api/Profiles/ProfileValidation.cs
deleted file mode 100644
index 003c96f39..000000000
--- a/src/NzbDrone.Api/Profiles/ProfileValidation.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-using System.Collections.Generic;
-using System.Linq;
-using FluentValidation;
-using FluentValidation.Validators;
-
-namespace NzbDrone.Api.Profiles
-{
- public static class ProfileValidation
- {
- public static IRuleBuilderOptions> MustHaveAllowedQuality(this IRuleBuilder> ruleBuilder)
- {
- ruleBuilder.SetValidator(new NotEmptyValidator(null));
-
- return ruleBuilder.SetValidator(new AllowedValidator());
- }
- }
-
- public class AllowedValidator : PropertyValidator
- {
- public AllowedValidator()
- : base("Must contain at least one allowed quality")
- {
-
- }
-
- protected override bool IsValid(PropertyValidatorContext context)
- {
- var list = context.PropertyValue as IList;
-
- if (list == null)
- {
- return false;
- }
-
- if (!list.Any(c => c.Allowed))
- {
- return false;
- }
-
- return true;
- }
- }
-}
diff --git a/src/NzbDrone.Api/Properties/AssemblyInfo.cs b/src/NzbDrone.Api/Properties/AssemblyInfo.cs
deleted file mode 100644
index 6149a06c4..000000000
--- a/src/NzbDrone.Api/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-[assembly: AssemblyTitle("NzbDrone.Api")]
-
-[assembly: Guid("4c0922d7-979e-4ff7-b44b-b8ac2100eeb5")]
-
-[assembly: AssemblyVersion("10.0.0.*")]
-
-[assembly: InternalsVisibleTo("NzbDrone.Core")]
diff --git a/src/NzbDrone.Api/ProviderModuleBase.cs b/src/NzbDrone.Api/ProviderModuleBase.cs
deleted file mode 100644
index 0bb676896..000000000
--- a/src/NzbDrone.Api/ProviderModuleBase.cs
+++ /dev/null
@@ -1,228 +0,0 @@
-using System.Collections.Generic;
-using System.Linq;
-using FluentValidation;
-using FluentValidation.Results;
-using Nancy;
-using Lidarr.Http.ClientSchema;
-using Lidarr.Http.Extensions;
-using NzbDrone.Common.Reflection;
-using NzbDrone.Core.ThingiProvider;
-using NzbDrone.Core.Validation;
-using Newtonsoft.Json;
-using Lidarr.Http;
-using Lidarr.Http.Mapping;
-
-namespace NzbDrone.Api
-{
- public abstract class ProviderModuleBase : LidarrRestModule
- where TProviderDefinition : ProviderDefinition, new()
- where TProvider : IProvider
- where TProviderResource : ProviderResource, new()
- {
- private readonly IProviderFactory _providerFactory;
-
- protected ProviderModuleBase(IProviderFactory providerFactory, string resource)
- : base(resource)
- {
- _providerFactory = providerFactory;
-
- Get["schema"] = x => GetTemplates();
- Post["test"] = x => Test(ReadResourceFromRequest(true));
- Post["action/{action}"] = x => RequestAction(x.action, ReadResourceFromRequest(true));
-
- GetResourceAll = GetAll;
- GetResourceById = GetProviderById;
- CreateResource = CreateProvider;
- UpdateResource = UpdateProvider;
- DeleteResource = DeleteProvider;
-
- SharedValidator.RuleFor(c => c.Name).NotEmpty();
- SharedValidator.RuleFor(c => c.Name).Must((v,c) => !_providerFactory.All().Any(p => p.Name == c && p.Id != v.Id)).WithMessage("Should be unique");
- SharedValidator.RuleFor(c => c.Implementation).NotEmpty();
- SharedValidator.RuleFor(c => c.ConfigContract).NotEmpty();
-
- PostValidator.RuleFor(c => c.Fields).NotNull();
- }
-
- private TProviderResource GetProviderById(int id)
- {
- var definition = _providerFactory.Get(id);
- _providerFactory.SetProviderCharacteristics(definition);
-
- var resource = new TProviderResource();
- MapToResource(resource, definition);
-
- return resource;
- }
-
- private List GetAll()
- {
- var providerDefinitions = _providerFactory.All().OrderBy(p => p.ImplementationName);
-
- var result = new List(providerDefinitions.Count());
-
- foreach (var definition in providerDefinitions)
- {
- _providerFactory.SetProviderCharacteristics(definition);
-
- var providerResource = new TProviderResource();
- MapToResource(providerResource, definition);
-
- result.Add(providerResource);
- }
-
- return result.OrderBy(p => p.Name).ToList();
- }
-
- private int CreateProvider(TProviderResource providerResource)
- {
- var providerDefinition = GetDefinition(providerResource, false);
-
- if (providerDefinition.Enable)
- {
- Test(providerDefinition, false);
- }
-
- providerDefinition = _providerFactory.Create(providerDefinition);
-
- return providerDefinition.Id;
- }
-
- private void UpdateProvider(TProviderResource providerResource)
- {
- var providerDefinition = GetDefinition(providerResource, false);
-
- _providerFactory.Update(providerDefinition);
- }
-
- private TProviderDefinition GetDefinition(TProviderResource providerResource, bool includeWarnings = false, bool validate = true)
- {
- var definition = new TProviderDefinition();
-
- MapToModel(definition, providerResource);
-
- if (validate)
- {
- Validate(definition, includeWarnings);
- }
-
- return definition;
- }
-
- protected virtual void MapToResource(TProviderResource resource, TProviderDefinition definition)
- {
- resource.Id = definition.Id;
-
- resource.Name = definition.Name;
- resource.ImplementationName = definition.ImplementationName;
- resource.Implementation = definition.Implementation;
- resource.ConfigContract = definition.ConfigContract;
- resource.Message = definition.Message;
-
- resource.Fields = SchemaBuilder.ToSchema(definition.Settings);
-
- resource.InfoLink = string.Format("https://github.com/Lidarr/Lidarr/wiki/Supported-{0}#{1}",
- typeof(TProviderResource).Name.Replace("Resource", "s"),
- definition.Implementation.ToLower());
- }
-
- protected virtual void MapToModel(TProviderDefinition definition, TProviderResource resource)
- {
- definition.Id = resource.Id;
-
- definition.Name = resource.Name;
- definition.ImplementationName = resource.ImplementationName;
- definition.Implementation = resource.Implementation;
- definition.ConfigContract = resource.ConfigContract;
- definition.Message = resource.Message;
-
- var configContract = ReflectionExtensions.CoreAssembly.FindTypeByName(definition.ConfigContract);
- definition.Settings = (IProviderConfig)SchemaBuilder.ReadFromSchema(resource.Fields, configContract);
- }
-
- private void DeleteProvider(int id)
- {
- _providerFactory.Delete(id);
- }
-
- private Response GetTemplates()
- {
- var defaultDefinitions = _providerFactory.GetDefaultDefinitions().OrderBy(p => p.ImplementationName).ToList();
-
- var result = new List(defaultDefinitions.Count());
-
- foreach (var providerDefinition in defaultDefinitions)
- {
- var providerResource = new TProviderResource();
- MapToResource(providerResource, providerDefinition);
-
- var presetDefinitions = _providerFactory.GetPresetDefinitions(providerDefinition);
-
- providerResource.Presets = presetDefinitions.Select(v =>
- {
- var presetResource = new TProviderResource();
- MapToResource(presetResource, v);
-
- return presetResource as ProviderResource;
- }).ToList();
-
- result.Add(providerResource);
- }
-
- return result.AsResponse();
- }
-
- private Response Test(TProviderResource providerResource)
- {
- // Don't validate when getting the definition so we can validate afterwards (avoids validation being skipped because the provider is disabled)
- var providerDefinition = GetDefinition(providerResource, true, false);
-
- Validate(providerDefinition, true);
- Test(providerDefinition, true);
-
- return "{}";
- }
-
-
- private Response RequestAction(string action, TProviderResource providerResource)
- {
- var providerDefinition = GetDefinition(providerResource, true, false);
-
- var query = ((IDictionary)Request.Query.ToDictionary()).ToDictionary(k => k.Key, k => k.Value.ToString());
-
- var data = _providerFactory.RequestAction(providerDefinition, action, query);
- Response resp = JsonConvert.SerializeObject(data);
- resp.ContentType = "application/json";
- return resp;
- }
-
- protected virtual void Validate(TProviderDefinition definition, bool includeWarnings)
- {
- var validationResult = definition.Settings.Validate();
-
- VerifyValidationResult(validationResult, includeWarnings);
- }
-
- protected virtual void Test(TProviderDefinition definition, bool includeWarnings)
- {
- var validationResult = _providerFactory.Test(definition);
-
- VerifyValidationResult(validationResult, includeWarnings);
- }
-
- protected void VerifyValidationResult(ValidationResult validationResult, bool includeWarnings)
- {
- var result = new NzbDroneValidationResult(validationResult.Errors);
-
- if (includeWarnings && (!result.IsValid || result.HasWarnings))
- {
- throw new ValidationException(result.Failures);
- }
-
- if (!result.IsValid)
- {
- throw new ValidationException(result.Errors);
- }
- }
- }
-}
diff --git a/src/NzbDrone.Api/ProviderResource.cs b/src/NzbDrone.Api/ProviderResource.cs
deleted file mode 100644
index 3ddbd5e37..000000000
--- a/src/NzbDrone.Api/ProviderResource.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using System.Collections.Generic;
-using Lidarr.Http.ClientSchema;
-using Lidarr.Http.REST;
-using NzbDrone.Core.ThingiProvider;
-
-namespace NzbDrone.Api
-{
- public class ProviderResource : RestResource
- {
- public string Name { get; set; }
- public List Fields { get; set; }
- public string ImplementationName { get; set; }
- public string Implementation { get; set; }
- public string ConfigContract { get; set; }
- public string InfoLink { get; set; }
- public ProviderMessage Message { get; set; }
-
- public List Presets { get; set; }
- }
-}
diff --git a/src/NzbDrone.Api/Qualities/QualityDefinitionModule.cs b/src/NzbDrone.Api/Qualities/QualityDefinitionModule.cs
deleted file mode 100644
index 2ac7a7a3d..000000000
--- a/src/NzbDrone.Api/Qualities/QualityDefinitionModule.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-using System.Collections.Generic;
-using NzbDrone.Core.Qualities;
-using Lidarr.Http;
-using Lidarr.Http.Mapping;
-
-namespace NzbDrone.Api.Qualities
-{
- public class QualityDefinitionModule : LidarrRestModule
- {
- private readonly IQualityDefinitionService _qualityDefinitionService;
-
- public QualityDefinitionModule(IQualityDefinitionService qualityDefinitionService)
- {
- _qualityDefinitionService = qualityDefinitionService;
-
- GetResourceAll = GetAll;
-
- GetResourceById = GetById;
-
- UpdateResource = Update;
- }
-
- private void Update(QualityDefinitionResource resource)
- {
- var model = resource.ToModel();
- _qualityDefinitionService.Update(model);
- }
-
- private QualityDefinitionResource GetById(int id)
- {
- return _qualityDefinitionService.GetById(id).ToResource();
- }
-
- private List GetAll()
- {
- return _qualityDefinitionService.All().ToResource();
- }
- }
-}
diff --git a/src/NzbDrone.Api/Qualities/QualityDefinitionResource.cs b/src/NzbDrone.Api/Qualities/QualityDefinitionResource.cs
deleted file mode 100644
index 684d5d29a..000000000
--- a/src/NzbDrone.Api/Qualities/QualityDefinitionResource.cs
+++ /dev/null
@@ -1,65 +0,0 @@
-using System.Collections.Generic;
-using System.Linq;
-using Lidarr.Http.REST;
-using NzbDrone.Core.Qualities;
-
-namespace NzbDrone.Api.Qualities
-{
- public class QualityDefinitionResource : RestResource
- {
- public Quality Quality { get; set; }
-
- public string Title { get; set; }
-
- public int Weight { get; set; }
-
- public double? MinSize { get; set; }
- public double? MaxSize { get; set; }
- }
-
- public static class QualityDefinitionResourceMapper
- {
- public static QualityDefinitionResource ToResource(this QualityDefinition model)
- {
- if (model == null) return null;
-
- return new QualityDefinitionResource
- {
- Id = model.Id,
-
- Quality = model.Quality,
-
- Title = model.Title,
-
- Weight = model.Weight,
-
- MinSize = model.MinSize,
- MaxSize = model.MaxSize
- };
- }
-
- public static QualityDefinition ToModel(this QualityDefinitionResource resource)
- {
- if (resource == null) return null;
-
- return new QualityDefinition
- {
- Id = resource.Id,
-
- Quality = resource.Quality,
-
- Title = resource.Title,
-
- Weight = resource.Weight,
-
- MinSize = resource.MinSize,
- MaxSize = resource.MaxSize
- };
- }
-
- public static List ToResource(this IEnumerable models)
- {
- return models.Select(ToResource).ToList();
- }
- }
-}
diff --git a/src/NzbDrone.Api/Queue/QueueActionModule.cs b/src/NzbDrone.Api/Queue/QueueActionModule.cs
deleted file mode 100644
index a7b0c7555..000000000
--- a/src/NzbDrone.Api/Queue/QueueActionModule.cs
+++ /dev/null
@@ -1,133 +0,0 @@
-using System;
-using Nancy;
-using Nancy.Responses;
-using Lidarr.Http.Extensions;
-using Lidarr.Http.REST;
-using NzbDrone.Core.Download;
-using NzbDrone.Core.Download.Pending;
-using NzbDrone.Core.Download.TrackedDownloads;
-using NzbDrone.Core.Queue;
-using Lidarr.Http;
-
-namespace NzbDrone.Api.Queue
-{
- public class QueueActionModule : LidarrRestModule
- {
- private readonly IQueueService _queueService;
- private readonly ITrackedDownloadService _trackedDownloadService;
- private readonly ICompletedDownloadService _completedDownloadService;
- private readonly IFailedDownloadService _failedDownloadService;
- private readonly IProvideDownloadClient _downloadClientProvider;
- private readonly IPendingReleaseService _pendingReleaseService;
- private readonly IDownloadService _downloadService;
-
- public QueueActionModule(IQueueService queueService,
- ITrackedDownloadService trackedDownloadService,
- ICompletedDownloadService completedDownloadService,
- IFailedDownloadService failedDownloadService,
- IProvideDownloadClient downloadClientProvider,
- IPendingReleaseService pendingReleaseService,
- IDownloadService downloadService)
- {
- _queueService = queueService;
- _trackedDownloadService = trackedDownloadService;
- _completedDownloadService = completedDownloadService;
- _failedDownloadService = failedDownloadService;
- _downloadClientProvider = downloadClientProvider;
- _pendingReleaseService = pendingReleaseService;
- _downloadService = downloadService;
-
- Delete[@"/(?[\d]{1,10})"] = x => Remove((int)x.Id);
- Post["/import"] = x => Import();
- Post["/grab"] = x => Grab();
- }
-
- private Response Remove(int id)
- {
- var blacklist = false;
- var blacklistQuery = Request.Query.blacklist;
-
- if (blacklistQuery.HasValue)
- {
- blacklist = Convert.ToBoolean(blacklistQuery.Value);
- }
-
- var pendingRelease = _pendingReleaseService.FindPendingQueueItem(id);
-
- if (pendingRelease != null)
- {
- _pendingReleaseService.RemovePendingQueueItems(pendingRelease.Id);
-
- return new object().AsResponse();
- }
-
- var trackedDownload = GetTrackedDownload(id);
-
- if (trackedDownload == null)
- {
- throw new NotFoundException();
- }
-
- var downloadClient = _downloadClientProvider.Get(trackedDownload.DownloadClient);
-
- if (downloadClient == null)
- {
- throw new BadRequestException();
- }
-
- downloadClient.RemoveItem(trackedDownload.DownloadItem.DownloadId, true);
-
- if (blacklist)
- {
- _failedDownloadService.MarkAsFailed(trackedDownload.DownloadItem.DownloadId);
- }
-
- return new object().AsResponse();
- }
-
- private JsonResponse Import()
- {
- var resource = Request.Body.FromJson();
- var trackedDownload = GetTrackedDownload(resource.Id);
-
- _completedDownloadService.Process(trackedDownload, true);
-
- return resource.AsResponse();
- }
-
- private JsonResponse Grab()
- {
- var resource = Request.Body.FromJson();
-
- var pendingRelease = _pendingReleaseService.FindPendingQueueItem(resource.Id);
-
- if (pendingRelease == null)
- {
- throw new NotFoundException();
- }
-
- _downloadService.DownloadReport(pendingRelease.RemoteAlbum);
-
- return resource.AsResponse();
- }
-
- private TrackedDownload GetTrackedDownload(int queueId)
- {
- var queueItem = _queueService.Find(queueId);
-
- if (queueItem == null)
- {
- throw new NotFoundException();
- }
-
- var trackedDownload = _trackedDownloadService.Find(queueItem.DownloadId);
-
- if (trackedDownload == null)
- {
- throw new NotFoundException();
- }
-
- return trackedDownload;
- }
- }
-}
diff --git a/src/NzbDrone.Api/Queue/QueueModule.cs b/src/NzbDrone.Api/Queue/QueueModule.cs
deleted file mode 100644
index aa0e062d2..000000000
--- a/src/NzbDrone.Api/Queue/QueueModule.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-using System.Collections.Generic;
-using System.Linq;
-using NzbDrone.Core.Datastore.Events;
-using NzbDrone.Core.Download.Pending;
-using NzbDrone.Core.Messaging.Events;
-using NzbDrone.Core.Queue;
-using NzbDrone.SignalR;
-using Lidarr.Http;
-
-namespace NzbDrone.Api.Queue
-{
- public class QueueModule : LidarrRestModuleWithSignalR,
- IHandle, IHandle
- {
- private readonly IQueueService _queueService;
- private readonly IPendingReleaseService _pendingReleaseService;
-
- public QueueModule(IBroadcastSignalRMessage broadcastSignalRMessage, IQueueService queueService, IPendingReleaseService pendingReleaseService)
- : base(broadcastSignalRMessage)
- {
- _queueService = queueService;
- _pendingReleaseService = pendingReleaseService;
- GetResourceAll = GetQueue;
- }
-
- private List GetQueue()
- {
- return GetQueueItems().ToResource();
- }
-
- private IEnumerable GetQueueItems()
- {
- var queue = _queueService.GetQueue();
- var pending = _pendingReleaseService.GetPendingQueue();
-
- return queue.Concat(pending);
- }
-
- public void Handle(QueueUpdatedEvent message)
- {
- BroadcastResourceChange(ModelAction.Sync);
- }
-
- public void Handle(PendingReleasesUpdatedEvent message)
- {
- BroadcastResourceChange(ModelAction.Sync);
- }
- }
-}
diff --git a/src/NzbDrone.Api/Queue/QueueResource.cs b/src/NzbDrone.Api/Queue/QueueResource.cs
deleted file mode 100644
index 51ce30ed1..000000000
--- a/src/NzbDrone.Api/Queue/QueueResource.cs
+++ /dev/null
@@ -1,63 +0,0 @@
-using System;
-using System.Collections.Generic;
-using Lidarr.Http.REST;
-using NzbDrone.Core.Qualities;
-using NzbDrone.Api.Series;
-using NzbDrone.Api.Episodes;
-using NzbDrone.Api.Music;
-using NzbDrone.Api.Albums;
-using NzbDrone.Core.Download.TrackedDownloads;
-using NzbDrone.Core.Indexers;
-using System.Linq;
-
-namespace NzbDrone.Api.Queue
-{
- public class QueueResource : RestResource
- {
- public ArtistResource Artist { get; set; }
- public AlbumResource Album { get; set; }
- public QualityModel Quality { get; set; }
- public decimal Size { get; set; }
- public string Title { get; set; }
- public decimal Sizeleft { get; set; }
- public TimeSpan? Timeleft { get; set; }
- public DateTime? EstimatedCompletionTime { get; set; }
- public string Status { get; set; }
- public string TrackedDownloadStatus { get; set; }
- public List StatusMessages { get; set; }
- public string DownloadId { get; set; }
- public DownloadProtocol Protocol { get; set; }
- }
-
- public static class QueueResourceMapper
- {
- public static QueueResource ToResource(this Core.Queue.Queue model)
- {
- if (model == null) return null;
-
- return new QueueResource
- {
- Id = model.Id,
-
- Artist = model.Artist.ToResource(),
- Album = model.Album.ToResource(),
- Quality = model.Quality,
- Size = model.Size,
- Title = model.Title,
- Sizeleft = model.Sizeleft,
- Timeleft = model.Timeleft,
- EstimatedCompletionTime = model.EstimatedCompletionTime,
- Status = model.Status,
- TrackedDownloadStatus = model.TrackedDownloadStatus,
- StatusMessages = model.StatusMessages,
- DownloadId = model.DownloadId,
- Protocol = model.Protocol
- };
- }
-
- public static List ToResource(this IEnumerable models)
- {
- return models.Select(ToResource).ToList();
- }
- }
-}
diff --git a/src/NzbDrone.Api/RemotePathMappings/RemotePathMappingModule.cs b/src/NzbDrone.Api/RemotePathMappings/RemotePathMappingModule.cs
deleted file mode 100644
index 1b3506611..000000000
--- a/src/NzbDrone.Api/RemotePathMappings/RemotePathMappingModule.cs
+++ /dev/null
@@ -1,68 +0,0 @@
-using System.Collections.Generic;
-using FluentValidation;
-using NzbDrone.Core.RemotePathMappings;
-using NzbDrone.Core.Validation.Paths;
-using Lidarr.Http;
-
-namespace NzbDrone.Api.RemotePathMappings
-{
- public class RemotePathMappingModule : LidarrRestModule
- {
- private readonly IRemotePathMappingService _remotePathMappingService;
-
- public RemotePathMappingModule(IRemotePathMappingService remotePathMappingService,
- PathExistsValidator pathExistsValidator,
- MappedNetworkDriveValidator mappedNetworkDriveValidator)
- {
- _remotePathMappingService = remotePathMappingService;
-
- GetResourceAll = GetMappings;
- GetResourceById = GetMappingById;
- CreateResource = CreateMapping;
- DeleteResource = DeleteMapping;
- UpdateResource = UpdateMapping;
-
- SharedValidator.RuleFor(c => c.Host)
- .NotEmpty();
-
- // We cannot use IsValidPath here, because it's a remote path, possibly other OS.
- SharedValidator.RuleFor(c => c.RemotePath)
- .NotEmpty();
-
- SharedValidator.RuleFor(c => c.LocalPath)
- .Cascade(CascadeMode.StopOnFirstFailure)
- .IsValidPath()
- .SetValidator(mappedNetworkDriveValidator)
- .SetValidator(pathExistsValidator);
- }
-
- private RemotePathMappingResource GetMappingById(int id)
- {
- return _remotePathMappingService.Get(id).ToResource();
- }
-
- private int CreateMapping(RemotePathMappingResource resource)
- {
- var model = resource.ToModel();
-
- return _remotePathMappingService.Add(model).Id;
- }
-
- private List GetMappings()
- {
- return _remotePathMappingService.All().ToResource();
- }
-
- private void DeleteMapping(int id)
- {
- _remotePathMappingService.Remove(id);
- }
-
- private void UpdateMapping(RemotePathMappingResource resource)
- {
- var mapping = resource.ToModel();
-
- _remotePathMappingService.Update(mapping);
- }
- }
-}
diff --git a/src/NzbDrone.Api/RemotePathMappings/RemotePathMappingResource.cs b/src/NzbDrone.Api/RemotePathMappings/RemotePathMappingResource.cs
deleted file mode 100644
index 779f929b0..000000000
--- a/src/NzbDrone.Api/RemotePathMappings/RemotePathMappingResource.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-using System.Collections.Generic;
-using System.Linq;
-using Lidarr.Http.REST;
-using NzbDrone.Core.RemotePathMappings;
-
-namespace NzbDrone.Api.RemotePathMappings
-{
- public class RemotePathMappingResource : RestResource
- {
- public string Host { get; set; }
- public string RemotePath { get; set; }
- public string LocalPath { get; set; }
- }
-
- public static class RemotePathMappingResourceMapper
- {
- public static RemotePathMappingResource ToResource(this RemotePathMapping model)
- {
- if (model == null) return null;
-
- return new RemotePathMappingResource
- {
- Id = model.Id,
-
- Host = model.Host,
- RemotePath = model.RemotePath,
- LocalPath = model.LocalPath
- };
- }
-
- public static RemotePathMapping ToModel(this RemotePathMappingResource resource)
- {
- if (resource == null) return null;
-
- return new RemotePathMapping
- {
- Id = resource.Id,
-
- Host = resource.Host,
- RemotePath = resource.RemotePath,
- LocalPath = resource.LocalPath
- };
- }
-
- public static List ToResource(this IEnumerable models)
- {
- return models.Select(ToResource).ToList();
- }
- }
-}
diff --git a/src/NzbDrone.Api/Restrictions/RestrictionModule.cs b/src/NzbDrone.Api/Restrictions/RestrictionModule.cs
deleted file mode 100644
index 032d9540a..000000000
--- a/src/NzbDrone.Api/Restrictions/RestrictionModule.cs
+++ /dev/null
@@ -1,60 +0,0 @@
-using System.Collections.Generic;
-using FluentValidation.Results;
-using NzbDrone.Common.Extensions;
-using NzbDrone.Core.Restrictions;
-using Lidarr.Http;
-
-namespace NzbDrone.Api.Restrictions
-{
- public class RestrictionModule : LidarrRestModule
- {
- private readonly IRestrictionService _restrictionService;
-
-
- public RestrictionModule(IRestrictionService restrictionService)
- {
- _restrictionService = restrictionService;
-
- GetResourceById = GetRestriction;
- GetResourceAll = GetAllRestrictions;
- CreateResource = CreateRestriction;
- UpdateResource = UpdateRestriction;
- DeleteResource = DeleteRestriction;
-
- SharedValidator.Custom(restriction =>
- {
- if (restriction.Ignored.IsNullOrWhiteSpace() && restriction.Required.IsNullOrWhiteSpace())
- {
- return new ValidationFailure("", "Either 'Must contain' or 'Must not contain' is required");
- }
-
- return null;
- });
- }
-
- private RestrictionResource GetRestriction(int id)
- {
- return _restrictionService.Get(id).ToResource();
- }
-
- private List GetAllRestrictions()
- {
- return _restrictionService.All().ToResource();
- }
-
- private int CreateRestriction(RestrictionResource resource)
- {
- return _restrictionService.Add(resource.ToModel()).Id;
- }
-
- private void UpdateRestriction(RestrictionResource resource)
- {
- _restrictionService.Update(resource.ToModel());
- }
-
- private void DeleteRestriction(int id)
- {
- _restrictionService.Delete(id);
- }
- }
-}
diff --git a/src/NzbDrone.Api/Restrictions/RestrictionResource.cs b/src/NzbDrone.Api/Restrictions/RestrictionResource.cs
deleted file mode 100644
index cd49cf623..000000000
--- a/src/NzbDrone.Api/Restrictions/RestrictionResource.cs
+++ /dev/null
@@ -1,58 +0,0 @@
-using System.Collections.Generic;
-using System.Linq;
-using Lidarr.Http.REST;
-using NzbDrone.Core.Restrictions;
-
-namespace NzbDrone.Api.Restrictions
-{
- public class RestrictionResource : RestResource
- {
- public string Required { get; set; }
- public string Preferred { get; set; }
- public string Ignored { get; set; }
- public HashSet Tags { get; set; }
-
- public RestrictionResource()
- {
- Tags = new HashSet();
- }
- }
-
- public static class RestrictionResourceMapper
- {
- public static RestrictionResource ToResource(this Restriction model)
- {
- if (model == null) return null;
-
- return new RestrictionResource
- {
- Id = model.Id,
-
- Required = model.Required,
- Preferred = model.Preferred,
- Ignored = model.Ignored,
- Tags = new HashSet(model.Tags)
- };
- }
-
- public static Restriction ToModel(this RestrictionResource resource)
- {
- if (resource == null) return null;
-
- return new Restriction
- {
- Id = resource.Id,
-
- Required = resource.Required,
- Preferred = resource.Preferred,
- Ignored = resource.Ignored,
- Tags = new HashSet(resource.Tags)
- };
- }
-
- public static List ToResource(this IEnumerable models)
- {
- return models.Select(ToResource).ToList();
- }
- }
-}
diff --git a/src/NzbDrone.Api/RootFolders/RootFolderModule.cs b/src/NzbDrone.Api/RootFolders/RootFolderModule.cs
deleted file mode 100644
index 93b781126..000000000
--- a/src/NzbDrone.Api/RootFolders/RootFolderModule.cs
+++ /dev/null
@@ -1,62 +0,0 @@
-using System.Collections.Generic;
-using FluentValidation;
-using NzbDrone.Core.RootFolders;
-using NzbDrone.Core.Validation.Paths;
-using NzbDrone.SignalR;
-using Lidarr.Http;
-
-namespace NzbDrone.Api.RootFolders
-{
- public class RootFolderModule : LidarrRestModuleWithSignalR
- {
- private readonly IRootFolderService _rootFolderService;
-
- public RootFolderModule(IRootFolderService rootFolderService,
- IBroadcastSignalRMessage signalRBroadcaster,
- RootFolderValidator rootFolderValidator,
- PathExistsValidator pathExistsValidator,
- MappedNetworkDriveValidator mappedNetworkDriveValidator,
- StartupFolderValidator startupFolderValidator,
- FolderWritableValidator folderWritableValidator)
- : base(signalRBroadcaster)
- {
- _rootFolderService = rootFolderService;
-
- GetResourceAll = GetRootFolders;
- GetResourceById = GetRootFolder;
- CreateResource = CreateRootFolder;
- DeleteResource = DeleteFolder;
-
- SharedValidator.RuleFor(c => c.Path)
- .Cascade(CascadeMode.StopOnFirstFailure)
- .IsValidPath()
- .SetValidator(rootFolderValidator)
- .SetValidator(mappedNetworkDriveValidator)
- .SetValidator(startupFolderValidator)
- .SetValidator(pathExistsValidator)
- .SetValidator(folderWritableValidator);
- }
-
- private RootFolderResource GetRootFolder(int id)
- {
- return _rootFolderService.Get(id).ToResource();
- }
-
- private int CreateRootFolder(RootFolderResource rootFolderResource)
- {
- var model = rootFolderResource.ToModel();
-
- return _rootFolderService.Add(model).Id;
- }
-
- private List GetRootFolders()
- {
- return _rootFolderService.AllWithUnmappedFolders().ToResource();
- }
-
- private void DeleteFolder(int id)
- {
- _rootFolderService.Remove(id);
- }
- }
-}
diff --git a/src/NzbDrone.Api/RootFolders/RootFolderResource.cs b/src/NzbDrone.Api/RootFolders/RootFolderResource.cs
deleted file mode 100644
index 2fefad440..000000000
--- a/src/NzbDrone.Api/RootFolders/RootFolderResource.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-using System.Collections.Generic;
-using System.Linq;
-using Lidarr.Http.REST;
-using NzbDrone.Core.RootFolders;
-
-namespace NzbDrone.Api.RootFolders
-{
- public class RootFolderResource : RestResource
- {
- public string Path { get; set; }
- public long? FreeSpace { get; set; }
-
- public List UnmappedFolders { get; set; }
- }
-
- public static class RootFolderResourceMapper
- {
- public static RootFolderResource ToResource(this RootFolder model)
- {
- if (model == null) return null;
-
- return new RootFolderResource
- {
- Id = model.Id,
-
- Path = model.Path,
- FreeSpace = model.FreeSpace,
- UnmappedFolders = model.UnmappedFolders
- };
- }
-
- public static RootFolder ToModel(this RootFolderResource resource)
- {
- if (resource == null) return null;
-
- return new RootFolder
- {
- Id = resource.Id,
-
- Path = resource.Path,
- //FreeSpace
- //UnmappedFolders
- };
- }
-
- public static List ToResource(this IEnumerable models)
- {
- return models.Select(ToResource).ToList();
- }
- }
-}
diff --git a/src/NzbDrone.Api/SeasonPass/SeasonPassModule.cs b/src/NzbDrone.Api/SeasonPass/SeasonPassModule.cs
deleted file mode 100644
index 20afcf722..000000000
--- a/src/NzbDrone.Api/SeasonPass/SeasonPassModule.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-using Nancy;
-using Lidarr.Http.Extensions;
-using NzbDrone.Core.Tv;
-
-namespace NzbDrone.Api.SeasonPass
-{
- public class SeasonPassModule : NzbDroneApiModule
- {
- private readonly IEpisodeMonitoredService _episodeMonitoredService;
-
- public SeasonPassModule(IEpisodeMonitoredService episodeMonitoredService)
- : base("/seasonpass")
- {
- _episodeMonitoredService = episodeMonitoredService;
- Post["/"] = series => UpdateAll();
- }
-
- private Response UpdateAll()
- {
- //Read from request
- var request = Request.Body.FromJson();
-
- foreach (var s in request.Series)
- {
- _episodeMonitoredService.SetEpisodeMonitoredStatus(s, request.MonitoringOptions);
- }
-
- return "ok".AsResponse(HttpStatusCode.Accepted);
- }
- }
-}
diff --git a/src/NzbDrone.Api/SeasonPass/SeasonPassResource.cs b/src/NzbDrone.Api/SeasonPass/SeasonPassResource.cs
deleted file mode 100644
index af537e7f9..000000000
--- a/src/NzbDrone.Api/SeasonPass/SeasonPassResource.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using System.Collections.Generic;
-using NzbDrone.Core.Tv;
-
-namespace NzbDrone.Api.SeasonPass
-{
- public class SeasonPassResource
- {
- public List Series { get; set; }
- public MonitoringOptions MonitoringOptions { get; set; }
- }
-}
diff --git a/src/NzbDrone.Api/Series/AlternateTitleResource.cs b/src/NzbDrone.Api/Series/AlternateTitleResource.cs
deleted file mode 100644
index b1d6cc22c..000000000
--- a/src/NzbDrone.Api/Series/AlternateTitleResource.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-namespace NzbDrone.Api.Series
-{
- public class AlternateTitleResource
- {
- public string Title { get; set; }
- public int? SeasonNumber { get; set; }
- public int? SceneSeasonNumber { get; set; }
- }
-}
diff --git a/src/NzbDrone.Api/Series/SeasonResource.cs b/src/NzbDrone.Api/Series/SeasonResource.cs
deleted file mode 100644
index 4c20d8865..000000000
--- a/src/NzbDrone.Api/Series/SeasonResource.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-using System.Collections.Generic;
-using System.Linq;
-using NzbDrone.Core.Tv;
-namespace NzbDrone.Api.Series
-{
- public class SeasonResource
- {
- public int SeasonNumber { get; set; }
- public bool Monitored { get; set; }
- public SeasonStatisticsResource Statistics { get; set; }
- }
-
- public static class SeasonResourceMapper
- {
- public static SeasonResource ToResource(this Season model)
- {
- if (model == null) return null;
-
- return new SeasonResource
- {
- SeasonNumber = model.SeasonNumber,
- Monitored = model.Monitored
- };
- }
-
- public static Season ToModel(this SeasonResource resource)
- {
- if (resource == null) return null;
-
- return new Season
- {
- SeasonNumber = resource.SeasonNumber,
- Monitored = resource.Monitored
- };
- }
-
- public static List ToResource(this IEnumerable models)
- {
- return models.Select(ToResource).ToList();
- }
-
- public static List ToModel(this IEnumerable resources)
- {
- return resources?.Select(ToModel).ToList() ?? new List();
- }
- }
-}
diff --git a/src/NzbDrone.Api/Series/SeasonStatisticsResource.cs b/src/NzbDrone.Api/Series/SeasonStatisticsResource.cs
deleted file mode 100644
index 34acc721e..000000000
--- a/src/NzbDrone.Api/Series/SeasonStatisticsResource.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-using System;
-using NzbDrone.Core.SeriesStats;
-
-namespace NzbDrone.Api.Series
-{
- public class SeasonStatisticsResource
- {
- public DateTime? NextAiring { get; set; }
- public DateTime? PreviousAiring { get; set; }
- public int EpisodeFileCount { get; set; }
- public int EpisodeCount { get; set; }
- public int TotalEpisodeCount { get; set; }
- public long SizeOnDisk { get; set; }
-
- public decimal PercentOfEpisodes
- {
- get
- {
- if (EpisodeCount == 0) return 0;
-
- return (decimal)EpisodeFileCount / (decimal)EpisodeCount * 100;
- }
- }
- }
-
- public static class SeasonStatisticsResourceMapper
- {
- public static SeasonStatisticsResource ToResource(this SeasonStatistics model)
- {
- if (model == null) return null;
-
- return new SeasonStatisticsResource
- {
- NextAiring = model.NextAiring,
- PreviousAiring = model.PreviousAiring,
- EpisodeFileCount = model.EpisodeFileCount,
- EpisodeCount = model.EpisodeFileCount,
- TotalEpisodeCount = model.TotalEpisodeCount,
- SizeOnDisk = model.SizeOnDisk
- };
- }
- }
-}
diff --git a/src/NzbDrone.Api/Series/SeriesEditorModule.cs b/src/NzbDrone.Api/Series/SeriesEditorModule.cs
deleted file mode 100644
index a54ceff7e..000000000
--- a/src/NzbDrone.Api/Series/SeriesEditorModule.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-using System.Collections.Generic;
-using System.Linq;
-using Nancy;
-using Lidarr.Http.Extensions;
-using Lidarr.Http.Mapping;
-using NzbDrone.Core.Tv;
-
-namespace NzbDrone.Api.Series
-{
- public class SeriesEditorModule : NzbDroneApiModule
- {
- private readonly ISeriesService _seriesService;
-
- public SeriesEditorModule(ISeriesService seriesService)
- : base("/series/editor")
- {
- _seriesService = seriesService;
- Put["/"] = series => SaveAll();
- }
-
- private Response SaveAll()
- {
- var resources = Request.Body.FromJson>();
-
- var series = resources.Select(seriesResource => seriesResource.ToModel(_seriesService.GetSeries(seriesResource.Id))).ToList();
-
- return _seriesService.UpdateSeries(series)
- .ToResource()
- .AsResponse(HttpStatusCode.Accepted);
- }
- }
-}
diff --git a/src/NzbDrone.Api/Series/SeriesModule.cs b/src/NzbDrone.Api/Series/SeriesModule.cs
deleted file mode 100644
index 9d9160732..000000000
--- a/src/NzbDrone.Api/Series/SeriesModule.cs
+++ /dev/null
@@ -1,247 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using FluentValidation;
-using NzbDrone.Common.Extensions;
-using NzbDrone.Core.Datastore.Events;
-using NzbDrone.Core.MediaCover;
-using NzbDrone.Core.MediaFiles;
-using NzbDrone.Core.MediaFiles.Events;
-using NzbDrone.Core.Messaging.Events;
-using NzbDrone.Core.SeriesStats;
-using NzbDrone.Core.Tv;
-using NzbDrone.Core.Tv.Events;
-using NzbDrone.Core.Validation.Paths;
-using NzbDrone.Core.DataAugmentation.Scene;
-using NzbDrone.Core.Validation;
-using NzbDrone.SignalR;
-using Lidarr.Http;
-using Lidarr.Http.Mapping;
-
-namespace NzbDrone.Api.Series
-{
- public class SeriesModule : LidarrRestModuleWithSignalR,
- IHandle,
- IHandle,
- IHandle,
- IHandle,
- IHandle,
- IHandle
- //IHandle
-
- {
- private readonly ISeriesService _seriesService;
- private readonly IAddSeriesService _addSeriesService;
- private readonly ISeriesStatisticsService _seriesStatisticsService;
- //private readonly ISceneMappingService _sceneMappingService;
- private readonly IMapCoversToLocal _coverMapper;
-
- public SeriesModule(IBroadcastSignalRMessage signalRBroadcaster,
- ISeriesService seriesService,
- IAddSeriesService addSeriesService,
- ISeriesStatisticsService seriesStatisticsService,
- //ISceneMappingService sceneMappingService,
- IMapCoversToLocal coverMapper,
- RootFolderValidator rootFolderValidator,
- SeriesPathValidator seriesPathValidator,
- SeriesExistsValidator seriesExistsValidator,
- SeriesAncestorValidator seriesAncestorValidator,
- ProfileExistsValidator profileExistsValidator,
- LanguageProfileExistsValidator languageProfileExistsValidator
- )
- : base(signalRBroadcaster)
- {
- _seriesService = seriesService;
- _addSeriesService = addSeriesService;
- _seriesStatisticsService = seriesStatisticsService;
- // _sceneMappingService = sceneMappingService;
-
- _coverMapper = coverMapper;
-
- GetResourceAll = AllSeries;
- GetResourceById = GetSeries;
- CreateResource = AddSeries;
- UpdateResource = UpdateSeries;
- DeleteResource = DeleteSeries;
-
- SharedValidator.RuleFor(s => s.ProfileId).ValidId();
- SharedValidator.RuleFor(s => s.LanguageProfileId);
-
- SharedValidator.RuleFor(s => s.Path)
- .Cascade(CascadeMode.StopOnFirstFailure)
- .IsValidPath()
- .SetValidator(rootFolderValidator)
- .SetValidator(seriesPathValidator)
- .SetValidator(seriesAncestorValidator)
- .When(s => !s.Path.IsNullOrWhiteSpace());
-
- SharedValidator.RuleFor(s => s.ProfileId).SetValidator(profileExistsValidator);
- SharedValidator.RuleFor(s => s.LanguageProfileId).SetValidator(languageProfileExistsValidator);
-
- PostValidator.RuleFor(s => s.Path).IsValidPath().When(s => s.RootFolderPath.IsNullOrWhiteSpace());
- PostValidator.RuleFor(s => s.RootFolderPath).IsValidPath().When(s => s.Path.IsNullOrWhiteSpace());
- PostValidator.RuleFor(s => s.TvdbId).GreaterThan(0).SetValidator(seriesExistsValidator);
-
- PutValidator.RuleFor(s => s.Path).IsValidPath();
- }
-
- private SeriesResource GetSeries(int id)
- {
- var series = _seriesService.GetSeries(id);
- return MapToResource(series);
- }
-
- private SeriesResource MapToResource(Core.Tv.Series series)
- {
- if (series == null) return null;
-
- var resource = series.ToResource();
- //MapCoversToLocal(resource);
- FetchAndLinkSeriesStatistics(resource);
- PopulateAlternateTitles(resource);
-
- return resource;
- }
-
- private List AllSeries()
- {
- var seriesStats = _seriesStatisticsService.SeriesStatistics();
- var seriesResources = _seriesService.GetAllSeries().ToResource();
-
- //MapCoversToLocal(seriesResources.ToArray());
- LinkSeriesStatistics(seriesResources, seriesStats);
- PopulateAlternateTitles(seriesResources);
-
- return seriesResources;
- }
-
- private int AddSeries(SeriesResource seriesResource)
- {
- var model = seriesResource.ToModel();
-
- return _addSeriesService.AddSeries(model).Id;
- }
-
- private void UpdateSeries(SeriesResource seriesResource)
- {
- var model = seriesResource.ToModel(_seriesService.GetSeries(seriesResource.Id));
-
- _seriesService.UpdateSeries(model);
-
- BroadcastResourceChange(ModelAction.Updated, seriesResource);
- }
-
- private void DeleteSeries(int id)
- {
- var deleteFiles = false;
- var deleteFilesQuery = Request.Query.deleteFiles;
-
- if (deleteFilesQuery.HasValue)
- {
- deleteFiles = Convert.ToBoolean(deleteFilesQuery.Value);
- }
-
- _seriesService.DeleteSeries(id, deleteFiles);
- }
-
- //private void MapCoversToLocal(params SeriesResource[] series)
- // {
- // foreach (var seriesResource in series)
- // {
- // _coverMapper.ConvertToLocalUrls(seriesResource.Id, seriesResource.Images);
- // }
- //}
-
- private void FetchAndLinkSeriesStatistics(SeriesResource resource)
- {
- LinkSeriesStatistics(resource, _seriesStatisticsService.SeriesStatistics(resource.Id));
- }
-
- private void LinkSeriesStatistics(List resources, List seriesStatistics)
- {
- var dictSeriesStats = seriesStatistics.ToDictionary(v => v.SeriesId);
-
- foreach (var series in resources)
- {
- var stats = dictSeriesStats.GetValueOrDefault(series.Id);
- if (stats == null) continue;
-
- LinkSeriesStatistics(series, stats);
- }
- }
-
- private void LinkSeriesStatistics(SeriesResource resource, SeriesStatistics seriesStatistics)
- {
- resource.TotalEpisodeCount = seriesStatistics.TotalEpisodeCount;
- resource.EpisodeCount = seriesStatistics.EpisodeCount;
- resource.EpisodeFileCount = seriesStatistics.EpisodeFileCount;
- resource.NextAiring = seriesStatistics.NextAiring;
- resource.PreviousAiring = seriesStatistics.PreviousAiring;
- resource.SizeOnDisk = seriesStatistics.SizeOnDisk;
-
- if (seriesStatistics.SeasonStatistics != null)
- {
- var dictSeasonStats = seriesStatistics.SeasonStatistics.ToDictionary(v => v.SeasonNumber);
-
- foreach (var season in resource.Seasons)
- {
- season.Statistics = dictSeasonStats.GetValueOrDefault(season.SeasonNumber).ToResource();
- }
- }
- }
-
- private void PopulateAlternateTitles(List resources)
- {
- foreach (var resource in resources)
- {
- PopulateAlternateTitles(resource);
- }
- }
-
- private void PopulateAlternateTitles(SeriesResource resource)
- {
- //var mappings = null //_sceneMappingService.FindByTvdbId(resource.TvdbId);
-
- //if (mappings == null) return;
- return;
- // resource.AlternateTitles = mappings.Select(v => new AlternateTitleResource { Title = v.Title, SeasonNumber = v.SeasonNumber, SceneSeasonNumber = v.SceneSeasonNumber }).ToList();
- }
-
- public void Handle(EpisodeImportedEvent message)
- {
- BroadcastResourceChange(ModelAction.Updated, message.ImportedEpisode.SeriesId);
- }
-
- public void Handle(EpisodeFileDeletedEvent message)
- {
- if (message.Reason == DeleteMediaFileReason.Upgrade) return;
-
- BroadcastResourceChange(ModelAction.Updated, message.EpisodeFile.SeriesId);
- }
-
- public void Handle(SeriesUpdatedEvent message)
- {
- BroadcastResourceChange(ModelAction.Updated, message.Series.Id);
- }
-
- public void Handle(SeriesEditedEvent message)
- {
- BroadcastResourceChange(ModelAction.Updated, message.Series.Id);
- }
-
- public void Handle(SeriesDeletedEvent message)
- {
- BroadcastResourceChange(ModelAction.Deleted, message.Series.ToResource());
- }
-
- public void Handle(SeriesRenamedEvent message)
- {
- BroadcastResourceChange(ModelAction.Updated, message.Series.Id);
- }
-
- //public void Handle(MediaCoversUpdatedEvent message)
- //{
- // BroadcastResourceChange(ModelAction.Updated, message.Series.Id);
- //}
- }
-}
diff --git a/src/NzbDrone.Api/Series/SeriesResource.cs b/src/NzbDrone.Api/Series/SeriesResource.cs
deleted file mode 100644
index f686538c7..000000000
--- a/src/NzbDrone.Api/Series/SeriesResource.cs
+++ /dev/null
@@ -1,225 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using Lidarr.Http.REST;
-using NzbDrone.Core.MediaCover;
-using NzbDrone.Core.Tv;
-
-namespace NzbDrone.Api.Series
-{
- public class SeriesResource : RestResource
- {
- public SeriesResource()
- {
- Monitored = true;
- }
-
- //Todo: Sorters should be done completely on the client
- //Todo: Is there an easy way to keep IgnoreArticlesWhenSorting in sync between, Series, History, Missing?
- //Todo: We should get the entire Profile instead of ID and Name separately
-
- //View Only
- public string Title { get; set; }
- public List AlternateTitles { get; set; }
- public string SortTitle { get; set; }
-
- public int SeasonCount
- {
- get
- {
- if (Seasons == null) return 0;
-
- return Seasons.Where(s => s.SeasonNumber > 0).Count();
- }
- }
-
- public int? TotalEpisodeCount { get; set; }
- public int? EpisodeCount { get; set; }
- public int? EpisodeFileCount { get; set; }
- public long? SizeOnDisk { get; set; }
- public SeriesStatusType Status { get; set; }
- public string Overview { get; set; }
- public DateTime? NextAiring { get; set; }
- public DateTime? PreviousAiring { get; set; }
- public string Network { get; set; }
- public string AirTime { get; set; }
- public List Images { get; set; }
-
- public string RemotePoster { get; set; }
- public List Seasons { get; set; }
- public int Year { get; set; }
-
- //View & Edit
- public string Path { get; set; }
- public int ProfileId { get; set; }
- public int LanguageProfileId { get; set; }
-
- //Editing Only
- public bool SeasonFolder { get; set; }
- public bool Monitored { get; set; }
-
- public bool UseSceneNumbering { get; set; }
- public int Runtime { get; set; }
- public int TvdbId { get; set; }
- public int TvRageId { get; set; }
- public int TvMazeId { get; set; }
- public DateTime? FirstAired { get; set; }
- public DateTime? LastInfoSync { get; set; }
- public SeriesTypes SeriesType { get; set; }
- public string CleanTitle { get; set; }
- public string ImdbId { get; set; }
- public string TitleSlug { get; set; }
- public string RootFolderPath { get; set; }
- public string Certification { get; set; }
- public List Genres { get; set; }
- public HashSet Tags { get; set; }
- public DateTime Added { get; set; }
- public AddSeriesOptions AddOptions { get; set; }
- public Ratings Ratings { get; set; }
-
- //TODO: Add series statistics as a property of the series (instead of individual properties)
-
- //Used to support legacy consumers
- public int QualityProfileId
- {
- get
- {
- return ProfileId;
- }
- set
- {
- if (value > 0 && ProfileId == 0)
- {
- ProfileId = value;
- }
- }
- }
- }
-
- public static class SeriesResourceMapper
- {
- public static SeriesResource ToResource(this Core.Tv.Series model)
- {
- if (model == null) return null;
-
- return new SeriesResource
- {
- Id = model.Id,
-
- Title = model.Title,
- //AlternateTitles
- SortTitle = model.SortTitle,
-
- //TotalEpisodeCount
- //EpisodeCount
- //EpisodeFileCount
- //SizeOnDisk
- Status = model.Status,
- Overview = model.Overview,
- //NextAiring
- //PreviousAiring
- Network = model.Network,
- AirTime = model.AirTime,
- Images = model.Images,
-
- Seasons = model.Seasons.ToResource(),
- Year = model.Year,
-
- Path = model.Path,
- ProfileId = model.ProfileId,
- LanguageProfileId = model.LanguageProfileId,
-
- SeasonFolder = model.SeasonFolder,
- Monitored = model.Monitored,
-
- UseSceneNumbering = model.UseSceneNumbering,
- Runtime = model.Runtime,
- TvdbId = model.TvdbId,
- TvRageId = model.TvRageId,
- TvMazeId = model.TvMazeId,
- FirstAired = model.FirstAired,
- LastInfoSync = model.LastInfoSync,
- SeriesType = model.SeriesType,
- CleanTitle = model.CleanTitle,
- ImdbId = model.ImdbId,
- TitleSlug = model.TitleSlug,
- RootFolderPath = model.RootFolderPath,
- Certification = model.Certification,
- Genres = model.Genres,
- Tags = model.Tags,
- Added = model.Added,
- AddOptions = model.AddOptions,
- Ratings = model.Ratings
- };
- }
-
- public static Core.Tv.Series ToModel(this SeriesResource resource)
- {
- if (resource == null) return null;
-
- return new Core.Tv.Series
- {
- Id = resource.Id,
-
- Title = resource.Title,
- //AlternateTitles
- SortTitle = resource.SortTitle,
-
- //TotalEpisodeCount
- //EpisodeCount
- //EpisodeFileCount
- //SizeOnDisk
- Status = resource.Status,
- Overview = resource.Overview,
- //NextAiring
- //PreviousAiring
- Network = resource.Network,
- AirTime = resource.AirTime,
- Images = resource.Images,
-
- Seasons = resource.Seasons.ToModel(),
- Year = resource.Year,
-
- Path = resource.Path,
- ProfileId = resource.ProfileId,
- LanguageProfileId = resource.LanguageProfileId,
-
- SeasonFolder = resource.SeasonFolder,
- Monitored = resource.Monitored,
-
- UseSceneNumbering = resource.UseSceneNumbering,
- Runtime = resource.Runtime,
- TvdbId = resource.TvdbId,
- TvRageId = resource.TvRageId,
- TvMazeId = resource.TvMazeId,
- FirstAired = resource.FirstAired,
- LastInfoSync = resource.LastInfoSync,
- SeriesType = resource.SeriesType,
- CleanTitle = resource.CleanTitle,
- ImdbId = resource.ImdbId,
- TitleSlug = resource.TitleSlug,
- RootFolderPath = resource.RootFolderPath,
- Certification = resource.Certification,
- Genres = resource.Genres,
- Tags = resource.Tags,
- Added = resource.Added,
- AddOptions = resource.AddOptions,
- Ratings = resource.Ratings
- };
- }
-
- public static Core.Tv.Series ToModel(this SeriesResource resource, Core.Tv.Series series)
- {
- var updatedSeries = resource.ToModel();
-
- series.ApplyChanges(updatedSeries);
-
- return series;
- }
-
- public static List ToResource(this IEnumerable series)
- {
- return series.Select(ToResource).ToList();
- }
- }
-}
diff --git a/src/NzbDrone.Api/System/Backup/BackupModule.cs b/src/NzbDrone.Api/System/Backup/BackupModule.cs
deleted file mode 100644
index 2260c191d..000000000
--- a/src/NzbDrone.Api/System/Backup/BackupModule.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using NzbDrone.Core.Backup;
-using Lidarr.Http;
-
-namespace NzbDrone.Api.System.Backup
-{
- public class BackupModule : LidarrRestModule
- {
- private readonly IBackupService _backupService;
-
- public BackupModule(IBackupService backupService) : base("system/backup")
- {
- _backupService = backupService;
- GetResourceAll = GetBackupFiles;
- }
-
- public List GetBackupFiles()
- {
- var backups = _backupService.GetBackups();
-
- return backups.Select(b => new BackupResource
- {
- Id = b.Name.GetHashCode(),
- Name = Path.GetFileName(b.Name),
- Path = b.Name,
- Type = b.Type,
- Time = b.Time
- }).ToList();
- }
- }
-}
diff --git a/src/NzbDrone.Api/System/Backup/BackupResource.cs b/src/NzbDrone.Api/System/Backup/BackupResource.cs
deleted file mode 100644
index b8252e66d..000000000
--- a/src/NzbDrone.Api/System/Backup/BackupResource.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System;
-using Lidarr.Http.REST;
-using NzbDrone.Core.Backup;
-
-namespace NzbDrone.Api.System.Backup
-{
- public class BackupResource : RestResource
- {
- public string Name { get; set; }
- public string Path { get; set; }
- public BackupType Type { get; set; }
- public DateTime Time { get; set; }
- }
-}
diff --git a/src/NzbDrone.Api/System/SystemModule.cs b/src/NzbDrone.Api/System/SystemModule.cs
deleted file mode 100644
index 1df7c495a..000000000
--- a/src/NzbDrone.Api/System/SystemModule.cs
+++ /dev/null
@@ -1,91 +0,0 @@
-using Nancy;
-using Nancy.Routing;
-using Lidarr.Http.Extensions;
-using NzbDrone.Common.EnvironmentInfo;
-using NzbDrone.Common.Extensions;
-using NzbDrone.Core.Configuration;
-using NzbDrone.Core.Datastore;
-using NzbDrone.Core.Lifecycle;
-
-namespace NzbDrone.Api.System
-{
- public class SystemModule : NzbDroneApiModule
- {
- private readonly IAppFolderInfo _appFolderInfo;
- private readonly IRuntimeInfo _runtimeInfo;
- private readonly IPlatformInfo _platformInfo;
- private readonly IOsInfo _osInfo;
- private readonly IRouteCacheProvider _routeCacheProvider;
- private readonly IConfigFileProvider _configFileProvider;
- private readonly IMainDatabase _database;
- private readonly ILifecycleService _lifecycleService;
-
- public SystemModule(IAppFolderInfo appFolderInfo,
- IRuntimeInfo runtimeInfo,
- IPlatformInfo platformInfo,
- IOsInfo osInfo,
- IRouteCacheProvider routeCacheProvider,
- IConfigFileProvider configFileProvider,
- IMainDatabase database,
- ILifecycleService lifecycleService) : base("system")
- {
- _appFolderInfo = appFolderInfo;
- _runtimeInfo = runtimeInfo;
- _platformInfo = platformInfo;
- _osInfo = osInfo;
- _routeCacheProvider = routeCacheProvider;
- _configFileProvider = configFileProvider;
- _database = database;
- _lifecycleService = lifecycleService;
- Get["/status"] = x => GetStatus();
- Get["/routes"] = x => GetRoutes();
- Post["/shutdown"] = x => Shutdown();
- Post["/restart"] = x => Restart();
- }
-
- private Response GetStatus()
- {
- return new
- {
- Version = BuildInfo.Version.ToString(),
- BuildTime = BuildInfo.BuildDateTime,
- IsDebug = BuildInfo.IsDebug,
- IsProduction = RuntimeInfo.IsProduction,
- IsAdmin = _runtimeInfo.IsAdmin,
- IsUserInteractive = RuntimeInfo.IsUserInteractive,
- StartupPath = _appFolderInfo.StartUpFolder,
- AppData = _appFolderInfo.GetAppDataPath(),
- OsName = _osInfo.Name,
- OsVersion = _osInfo.Version,
- IsMonoRuntime = PlatformInfo.IsMono,
- IsMono = PlatformInfo.IsMono,
- IsLinux = OsInfo.IsLinux,
- IsOsx = OsInfo.IsOsx,
- IsWindows = OsInfo.IsWindows,
- Branch = _configFileProvider.Branch,
- Authentication = _configFileProvider.AuthenticationMethod,
- SqliteVersion = _database.Version,
- UrlBase = _configFileProvider.UrlBase,
- RuntimeVersion = _platformInfo.Version,
- RuntimeName = PlatformInfo.Platform
- }.AsResponse();
- }
-
- private Response GetRoutes()
- {
- return _routeCacheProvider.GetCache().Values.AsResponse();
- }
-
- private Response Shutdown()
- {
- _lifecycleService.Shutdown();
- return "".AsResponse();
- }
-
- private Response Restart()
- {
- _lifecycleService.Restart();
- return "".AsResponse();
- }
- }
-}
diff --git a/src/NzbDrone.Api/System/Tasks/TaskModule.cs b/src/NzbDrone.Api/System/Tasks/TaskModule.cs
deleted file mode 100644
index fc196fd01..000000000
--- a/src/NzbDrone.Api/System/Tasks/TaskModule.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-using System.Collections.Generic;
-using System.Linq;
-using System.Text.RegularExpressions;
-using NzbDrone.Core.Datastore.Events;
-using NzbDrone.Core.Jobs;
-using NzbDrone.Core.Messaging.Events;
-using NzbDrone.SignalR;
-using Lidarr.Http;
-
-namespace NzbDrone.Api.System.Tasks
-{
- public class TaskModule : LidarrRestModuleWithSignalR, IHandle
- {
- private readonly ITaskManager _taskManager;
-
- private static readonly Regex NameRegex = new Regex("(? GetAll()
- {
- return _taskManager.GetAll().Select(ConvertToResource).ToList();
- }
-
- private static TaskResource ConvertToResource(ScheduledTask scheduledTask)
- {
- var taskName = scheduledTask.TypeName.Split('.').Last().Replace("Command", "");
-
- return new TaskResource
- {
- Id = scheduledTask.Id,
- Name = NameRegex.Replace(taskName, match => " " + match.Value),
- TaskName = taskName,
- Interval = scheduledTask.Interval,
- LastExecution = scheduledTask.LastExecution,
- NextExecution = scheduledTask.LastExecution.AddMinutes(scheduledTask.Interval)
- };
- }
-
- public void Handle(CommandExecutedEvent message)
- {
- BroadcastResourceChange(ModelAction.Sync);
- }
- }
-}
diff --git a/src/NzbDrone.Api/System/Tasks/TaskResource.cs b/src/NzbDrone.Api/System/Tasks/TaskResource.cs
deleted file mode 100644
index 05992d626..000000000
--- a/src/NzbDrone.Api/System/Tasks/TaskResource.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System;
-using Lidarr.Http.REST;
-
-namespace NzbDrone.Api.System.Tasks
-{
- public class TaskResource : RestResource
- {
- public string Name { get; set; }
- public string TaskName { get; set; }
- public int Interval { get; set; }
- public DateTime LastExecution { get; set; }
- public DateTime NextExecution { get; set; }
- }
-}
diff --git a/src/NzbDrone.Api/Tags/TagModule.cs b/src/NzbDrone.Api/Tags/TagModule.cs
deleted file mode 100644
index 1fdd5ae01..000000000
--- a/src/NzbDrone.Api/Tags/TagModule.cs
+++ /dev/null
@@ -1,62 +0,0 @@
-using System.Collections.Generic;
-using NzbDrone.Core.Datastore.Events;
-using NzbDrone.Core.Messaging.Events;
-using NzbDrone.Core.Tags;
-using NzbDrone.SignalR;
-using Lidarr.Http;
-using Lidarr.Http.Mapping;
-
-namespace NzbDrone.Api.Tags
-{
- public class TagModule : LidarrRestModuleWithSignalR, IHandle
- {
- private readonly ITagService _tagService;
-
- public TagModule(IBroadcastSignalRMessage signalRBroadcaster,
- ITagService tagService)
- : base(signalRBroadcaster)
- {
- _tagService = tagService;
-
- GetResourceById = GetTag;
- GetResourceAll = GetAllTags;
- CreateResource = CreateTag;
- UpdateResource = UpdateTag;
- DeleteResource = DeleteTag;
- }
-
- private TagResource GetTag(int id)
- {
- return _tagService.GetTag(id).ToResource();
- }
-
- private List GetAllTags()
- {
- return _tagService.All().ToResource();
- }
-
- private int CreateTag(TagResource resource)
- {
- var model = resource.ToModel();
-
- return _tagService.Add(model).Id;
- }
-
- private void UpdateTag(TagResource resource)
- {
- var model = resource.ToModel();
-
- _tagService.Update(model);
- }
-
- private void DeleteTag(int id)
- {
- _tagService.Delete(id);
- }
-
- public void Handle(TagsUpdatedEvent message)
- {
- BroadcastResourceChange(ModelAction.Sync);
- }
- }
-}
diff --git a/src/NzbDrone.Api/Tags/TagResource.cs b/src/NzbDrone.Api/Tags/TagResource.cs
deleted file mode 100644
index 3d2599f8e..000000000
--- a/src/NzbDrone.Api/Tags/TagResource.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-using System.Collections.Generic;
-using System.Linq;
-using Lidarr.Http.REST;
-using NzbDrone.Core.Tags;
-
-namespace NzbDrone.Api.Tags
-{
- public class TagResource : RestResource
- {
- public string Label { get; set; }
- }
-
- public static class TagResourceMapper
- {
- public static TagResource ToResource(this Tag model)
- {
- if (model == null) return null;
-
- return new TagResource
- {
- Id = model.Id,
-
- Label = model.Label
- };
- }
-
- public static Tag ToModel(this TagResource resource)
- {
- if (resource == null) return null;
-
- return new Tag
- {
- Id = resource.Id,
-
- Label = resource.Label
- };
- }
-
- public static List ToResource(this IEnumerable models)
- {
- return models.Select(ToResource).ToList();
- }
- }
-}
diff --git a/src/NzbDrone.Api/TrackFiles/TrackFileModule.cs b/src/NzbDrone.Api/TrackFiles/TrackFileModule.cs
deleted file mode 100644
index 577c15ea6..000000000
--- a/src/NzbDrone.Api/TrackFiles/TrackFileModule.cs
+++ /dev/null
@@ -1,102 +0,0 @@
-using System.Collections.Generic;
-using System.IO;
-using NLog;
-using Lidarr.Http.REST;
-using NzbDrone.Common.Disk;
-using NzbDrone.Common.Extensions;
-using NzbDrone.Core.Datastore.Events;
-using NzbDrone.Core.MediaFiles;
-using NzbDrone.Core.MediaFiles.Events;
-using NzbDrone.Core.Messaging.Events;
-using NzbDrone.Core.Tv;
-using NzbDrone.Core.Music;
-using NzbDrone.Core.DecisionEngine;
-using NzbDrone.SignalR;
-using System;
-using Lidarr.Http;
-using Lidarr.Http.Mapping;
-
-namespace NzbDrone.Api.TrackFiles
-{
- public class TrackFileModule : LidarrRestModuleWithSignalR,
- IHandle
- {
- private readonly IMediaFileService _mediaFileService;
- private readonly IDiskProvider _diskProvider;
- private readonly IRecycleBinProvider _recycleBinProvider;
- private readonly ISeriesService _seriesService;
- private readonly IArtistService _artistService;
- private readonly IUpgradableSpecification _upgradableSpecification;
- private readonly Logger _logger;
-
- public TrackFileModule(IBroadcastSignalRMessage signalRBroadcaster,
- IMediaFileService mediaFileService,
- IDiskProvider diskProvider,
- IRecycleBinProvider recycleBinProvider,
- ISeriesService seriesService,
- IArtistService artistService,
- IUpgradableSpecification upgradableSpecification,
- Logger logger)
- : base(signalRBroadcaster)
- {
- _mediaFileService = mediaFileService;
- _diskProvider = diskProvider;
- _recycleBinProvider = recycleBinProvider;
- _seriesService = seriesService;
- _artistService = artistService;
- _upgradableSpecification = upgradableSpecification;
- _logger = logger;
- GetResourceById = GetTrackFile;
- GetResourceAll = GetTrackFiles;
- UpdateResource = SetQuality;
- DeleteResource = DeleteTrackFile;
- }
-
- private TrackFileResource GetTrackFile(int id)
- {
- var trackFile = _mediaFileService.Get(id);
- var artist = _artistService.GetArtist(trackFile.ArtistId);
-
- return trackFile.ToResource(artist, _upgradableSpecification);
- }
-
- private List GetTrackFiles()
- {
- if (!Request.Query.ArtistId.HasValue)
- {
- throw new BadRequestException("artistId is missing");
- }
-
- var artistId = (int)Request.Query.ArtistId;
-
- var artist = _artistService.GetArtist(artistId);
-
- return _mediaFileService.GetFilesByArtist(artistId).ConvertAll(f => f.ToResource(artist, _upgradableSpecification));
- }
-
- private void SetQuality(TrackFileResource trackFileResource)
- {
- var trackFile = _mediaFileService.Get(trackFileResource.Id);
- trackFile.Quality = trackFileResource.Quality;
- _mediaFileService.Update(trackFile);
- }
-
- private void DeleteTrackFile(int id)
- {
- throw new NotImplementedException();
- //var episodeFile = _mediaFileService.Get(id);
- //var series = _seriesService.GetSeries(episodeFile.SeriesId);
- //var fullPath = Path.Combine(series.Path, episodeFile.RelativePath);
- //var subfolder = _diskProvider.GetParentFolder(series.Path).GetRelativePath(_diskProvider.GetParentFolder(fullPath));
-
- //_logger.Info("Deleting episode file: {0}", fullPath);
- //_recycleBinProvider.DeleteFile(fullPath, subfolder);
- //_mediaFileService.Delete(episodeFile, DeleteMediaFileReason.Manual);
- }
-
- public void Handle(TrackFileAddedEvent message)
- {
- BroadcastResourceChange(ModelAction.Updated, message.TrackFile.Id);
- }
- }
-}
diff --git a/src/NzbDrone.Api/TrackFiles/TrackFileResource.cs b/src/NzbDrone.Api/TrackFiles/TrackFileResource.cs
deleted file mode 100644
index 0a3aeb66b..000000000
--- a/src/NzbDrone.Api/TrackFiles/TrackFileResource.cs
+++ /dev/null
@@ -1,67 +0,0 @@
-using System;
-using System.IO;
-using Lidarr.Http.REST;
-using NzbDrone.Core.Qualities;
-using NzbDrone.Core.Languages;
-
-namespace NzbDrone.Api.TrackFiles
-{
- public class TrackFileResource : RestResource
- {
- public int ArtistId { get; set; }
- public int AlbumId { get; set; }
- public string RelativePath { get; set; }
- public string Path { get; set; }
- public long Size { get; set; }
- public Language Language { get; set; }
- public DateTime DateAdded { get; set; }
- //public string SceneName { get; set; }
- public QualityModel Quality { get; set; }
-
- public bool QualityCutoffNotMet { get; set; }
- }
-
- public static class TrackFileResourceMapper
- {
- private static TrackFileResource ToResource(this Core.MediaFiles.TrackFile model)
- {
- if (model == null) return null;
-
- return new TrackFileResource
- {
- Id = model.Id,
-
- ArtistId = model.ArtistId,
- AlbumId = model.AlbumId,
- RelativePath = model.RelativePath,
- //Path
- Size = model.Size,
- DateAdded = model.DateAdded,
- //SceneName = model.SceneName,
- Quality = model.Quality,
- //QualityCutoffNotMet
- };
- }
-
- public static TrackFileResource ToResource(this Core.MediaFiles.TrackFile model, Core.Music.Artist artist, Core.DecisionEngine.IUpgradableSpecification upgradableSpecification)
- {
- if (model == null) return null;
-
- return new TrackFileResource
- {
- Id = model.Id,
-
- ArtistId = model.ArtistId,
- AlbumId = model.AlbumId,
- RelativePath = model.RelativePath,
- Path = Path.Combine(artist.Path, model.RelativePath),
- Size = model.Size,
- DateAdded = model.DateAdded,
- //SceneName = model.SceneName,
- Quality = model.Quality,
- Language = model.Language,
- QualityCutoffNotMet = upgradableSpecification.CutoffNotMet(artist.Profile.Value, artist.LanguageProfile.Value, model.Quality, model.Language)
- };
- }
- }
-}
diff --git a/src/NzbDrone.Api/Tracks/RenameTrackModule.cs b/src/NzbDrone.Api/Tracks/RenameTrackModule.cs
deleted file mode 100644
index 871b19ddb..000000000
--- a/src/NzbDrone.Api/Tracks/RenameTrackModule.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-using System.Collections.Generic;
-using Lidarr.Http.REST;
-using NzbDrone.Core.MediaFiles;
-using Lidarr.Http;
-using Lidarr.Http.Mapping;
-
-namespace NzbDrone.Api.Tracks
-{
- public class RenameTrackModule : LidarrRestModule
- {
- private readonly IRenameTrackFileService _renameTrackFileService;
-
- public RenameTrackModule(IRenameTrackFileService renameTrackFileService)
- : base("rename")
- {
- _renameTrackFileService = renameTrackFileService;
-
- GetResourceAll = GetTracks;
- }
-
- private List GetTracks()
- {
- if (!Request.Query.ArtistId.HasValue)
- {
- throw new BadRequestException("artistId is missing");
- }
-
- var artistId = (int)Request.Query.ArtistId;
-
- if (Request.Query.AlbumId.HasValue)
- {
- var albumId = (int)Request.Query.AlbumId;
- return _renameTrackFileService.GetRenamePreviews(artistId, albumId).ToResource();
- }
-
- return _renameTrackFileService.GetRenamePreviews(artistId).ToResource();
- }
- }
-}
diff --git a/src/NzbDrone.Api/Tracks/RenameTrackResource.cs b/src/NzbDrone.Api/Tracks/RenameTrackResource.cs
deleted file mode 100644
index 26d3466de..000000000
--- a/src/NzbDrone.Api/Tracks/RenameTrackResource.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-using System.Collections.Generic;
-using System.Linq;
-using Lidarr.Http.REST;
-
-namespace NzbDrone.Api.Tracks
-{
- public class RenameTrackResource : RestResource
- {
- public int ArtistId { get; set; }
- public int AlbumId { get; set; }
- public List TrackNumbers { get; set; }
- public int TrackFileId { get; set; }
- public string ExistingPath { get; set; }
- public string NewPath { get; set; }
- }
-
- public static class RenameTrackResourceMapper
- {
- public static RenameTrackResource ToResource(this Core.MediaFiles.RenameTrackFilePreview model)
- {
- if (model == null) return null;
-
- return new RenameTrackResource
- {
- ArtistId = model.ArtistId,
- AlbumId = model.AlbumId,
- TrackNumbers = model.TrackNumbers.ToList(),
- TrackFileId = model.TrackFileId,
- ExistingPath = model.ExistingPath,
- NewPath = model.NewPath
- };
- }
-
- public static List ToResource(this IEnumerable models)
- {
- return models.Select(ToResource).ToList();
- }
- }
-}
diff --git a/src/NzbDrone.Api/Tracks/TrackModule.cs b/src/NzbDrone.Api/Tracks/TrackModule.cs
deleted file mode 100644
index acb8b3bc3..000000000
--- a/src/NzbDrone.Api/Tracks/TrackModule.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-using System.Collections.Generic;
-using Lidarr.Http.REST;
-using NzbDrone.Core.Music;
-using NzbDrone.Core.DecisionEngine;
-using NzbDrone.SignalR;
-
-namespace NzbDrone.Api.Tracks
-{
- public class TrackModule : TrackModuleWithSignalR
- {
- public TrackModule(IArtistService artistService,
- ITrackService trackService,
- IUpgradableSpecification upgradableSpecification,
- IBroadcastSignalRMessage signalRBroadcaster)
- : base(trackService, artistService, upgradableSpecification, signalRBroadcaster)
- {
- GetResourceAll = GetTracks;
- UpdateResource = SetMonitored;
- }
-
- private List GetTracks()
- {
- if (!Request.Query.ArtistId.HasValue)
- {
- throw new BadRequestException("artistId is missing");
- }
-
- var artistId = (int)Request.Query.ArtistId;
-
- var resources = MapToResource(_trackService.GetTracksByArtist(artistId), false, true);
-
- return resources;
- }
-
- private void SetMonitored(TrackResource trackResource)
- {
- _trackService.SetTrackMonitored(trackResource.Id, trackResource.Monitored);
- }
- }
-}
diff --git a/src/NzbDrone.Api/Tracks/TrackModuleWithSignalR.cs b/src/NzbDrone.Api/Tracks/TrackModuleWithSignalR.cs
deleted file mode 100644
index 81f71056d..000000000
--- a/src/NzbDrone.Api/Tracks/TrackModuleWithSignalR.cs
+++ /dev/null
@@ -1,128 +0,0 @@
-using System.Collections.Generic;
-using NzbDrone.Common.Extensions;
-using NzbDrone.Api.TrackFiles;
-using NzbDrone.Api.Music;
-using NzbDrone.Core.Datastore.Events;
-using NzbDrone.Core.DecisionEngine;
-using NzbDrone.Core.Download;
-using NzbDrone.Core.MediaFiles.Events;
-using NzbDrone.Core.Messaging.Events;
-using NzbDrone.Core.Tv;
-using NzbDrone.Core.Music;
-using NzbDrone.SignalR;
-using Lidarr.Http;
-using Lidarr.Http.Mapping;
-
-namespace NzbDrone.Api.Tracks
-{
- public abstract class TrackModuleWithSignalR : LidarrRestModuleWithSignalR,
- IHandle
- {
- protected readonly ITrackService _trackService;
- protected readonly IArtistService _artistService;
- protected readonly IUpgradableSpecification _upgradableSpecification;
-
- protected TrackModuleWithSignalR(ITrackService trackService,
- IArtistService artistService,
- IUpgradableSpecification upgradableSpecification,
- IBroadcastSignalRMessage signalRBroadcaster)
- : base(signalRBroadcaster)
- {
- _trackService = trackService;
- _artistService = artistService;
- _upgradableSpecification = upgradableSpecification;
-
- GetResourceById = GetTrack;
- }
-
- protected TrackModuleWithSignalR(ITrackService trackService,
- IArtistService artistService,
- IUpgradableSpecification upgradableSpecification,
- IBroadcastSignalRMessage signalRBroadcaster,
- string resource)
- : base(signalRBroadcaster, resource)
- {
- _trackService = trackService;
- _artistService = artistService;
- _upgradableSpecification = upgradableSpecification;
-
- GetResourceById = GetTrack;
- }
-
- protected TrackResource GetTrack(int id)
- {
- var track = _trackService.GetTrack(id);
- var resource = MapToResource(track, true, true);
- return resource;
- }
-
- protected TrackResource MapToResource(Track track, bool includeArtist, bool includeTrackFile)
- {
- var resource = track.ToResource();
-
- if (includeArtist || includeTrackFile)
- {
- var artist = track.Artist ?? _artistService.GetArtist(track.ArtistId);
-
- if (includeArtist)
- {
- resource.Artist = artist.ToResource();
- }
- if (includeTrackFile && track.TrackFileId != 0)
- {
- resource.TrackFile = track.TrackFile.Value.ToResource(artist, _upgradableSpecification);
- }
- }
-
- return resource;
- }
-
- protected List MapToResource(List