2013-03-21 04:02:57 +01:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using AutoMapper;
|
|
|
|
|
using Nancy;
|
2013-05-01 02:25:33 +02:00
|
|
|
|
using NzbDrone.Api.Episodes;
|
2013-03-21 04:02:57 +01:00
|
|
|
|
using NzbDrone.Api.Extensions;
|
|
|
|
|
using NzbDrone.Core.Tv;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Api.Missing
|
|
|
|
|
{
|
|
|
|
|
public class MissingModule : NzbDroneApiModule
|
|
|
|
|
{
|
2013-04-01 08:22:16 +02:00
|
|
|
|
private readonly IEpisodeService _episodeService;
|
2013-03-21 04:02:57 +01:00
|
|
|
|
|
2013-04-01 08:22:16 +02:00
|
|
|
|
public MissingModule(IEpisodeService episodeService)
|
2013-03-21 04:02:57 +01:00
|
|
|
|
: base("/missing")
|
|
|
|
|
{
|
|
|
|
|
_episodeService = episodeService;
|
|
|
|
|
Get["/"] = x => GetMissingEpisodes();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Response GetMissingEpisodes()
|
|
|
|
|
{
|
|
|
|
|
bool includeSpecials;
|
|
|
|
|
Boolean.TryParse(PrimitiveExtensions.ToNullSafeString(Request.Query.IncludeSpecials), out includeSpecials);
|
|
|
|
|
|
|
|
|
|
var episodes = _episodeService.EpisodesWithoutFiles(includeSpecials);
|
2013-05-01 02:25:33 +02:00
|
|
|
|
|
|
|
|
|
//TODO: Include the Series Title
|
2013-05-01 05:04:06 +02:00
|
|
|
|
//TODO: Remove Take(20)
|
|
|
|
|
return Mapper.Map<List<Episode>, List<EpisodeResource>>(episodes).Take(20).AsResponse();
|
2013-03-21 04:02:57 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|