2012-02-25 03:01:53 +01:00
|
|
|
|
using System;
|
|
|
|
|
using System.Web.Mvc;
|
2011-12-02 02:33:17 +01:00
|
|
|
|
using NzbDrone.Core.Jobs;
|
2012-09-04 01:26:52 +02:00
|
|
|
|
using NzbDrone.Core.Providers;
|
|
|
|
|
using NzbDrone.Core.Repository.Quality;
|
2011-05-27 08:03:57 +02:00
|
|
|
|
using NzbDrone.Web.Models;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Web.Controllers
|
|
|
|
|
{
|
|
|
|
|
public class EpisodeController : Controller
|
|
|
|
|
{
|
|
|
|
|
private readonly JobProvider _jobProvider;
|
2012-09-04 01:26:52 +02:00
|
|
|
|
private readonly MediaFileProvider _mediaFileProvider;
|
2011-05-27 08:03:57 +02:00
|
|
|
|
|
2012-09-04 01:26:52 +02:00
|
|
|
|
public EpisodeController(JobProvider jobProvider, MediaFileProvider mediaFileProvider)
|
2011-05-27 08:03:57 +02:00
|
|
|
|
{
|
|
|
|
|
_jobProvider = jobProvider;
|
2012-09-04 01:26:52 +02:00
|
|
|
|
_mediaFileProvider = mediaFileProvider;
|
2011-05-27 08:03:57 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public JsonResult Search(int episodeId)
|
|
|
|
|
{
|
2012-10-20 06:36:47 +02:00
|
|
|
|
_jobProvider.QueueJob(typeof(EpisodeSearchJob), new { EpisodeId = episodeId });
|
2012-02-26 22:47:04 +01:00
|
|
|
|
return JsonNotificationResult.Queued("Episode search");
|
2011-05-27 08:03:57 +02:00
|
|
|
|
}
|
|
|
|
|
|
2011-08-22 02:48:37 +02:00
|
|
|
|
public JsonResult SearchSeason(int seriesId, int seasonNumber)
|
|
|
|
|
{
|
2012-09-10 21:04:17 +02:00
|
|
|
|
_jobProvider.QueueJob(typeof(SeasonSearchJob), new { SeriesId = seriesId, SeasonNumber = seasonNumber });
|
2012-02-26 22:47:04 +01:00
|
|
|
|
return JsonNotificationResult.Queued("Season search");
|
|
|
|
|
|
2011-08-22 02:48:37 +02:00
|
|
|
|
}
|
|
|
|
|
|
2011-11-26 08:53:16 +01:00
|
|
|
|
public JsonResult BacklogSeries(int seriesId)
|
2011-08-23 07:29:12 +02:00
|
|
|
|
{
|
2012-10-20 06:36:47 +02:00
|
|
|
|
_jobProvider.QueueJob(typeof(SeriesSearchJob), new { SeriesId = seriesId });
|
2012-02-26 22:47:04 +01:00
|
|
|
|
return JsonNotificationResult.Queued("Series Backlog");
|
|
|
|
|
|
2011-08-23 07:29:12 +02:00
|
|
|
|
}
|
|
|
|
|
|
2011-08-22 02:48:37 +02:00
|
|
|
|
public JsonResult RenameSeason(int seriesId, int seasonNumber)
|
|
|
|
|
{
|
2012-09-10 21:04:17 +02:00
|
|
|
|
_jobProvider.QueueJob(typeof(RenameSeasonJob), new { SeriesId = seriesId, SeasonNumber = seasonNumber });
|
2012-02-26 22:47:04 +01:00
|
|
|
|
return JsonNotificationResult.Queued("Season rename");
|
|
|
|
|
|
2011-08-22 02:48:37 +02:00
|
|
|
|
}
|
2011-08-23 07:29:12 +02:00
|
|
|
|
|
2012-07-21 06:46:16 +02:00
|
|
|
|
public JsonResult RenameSeries(int seriesId)
|
2011-08-23 07:29:12 +02:00
|
|
|
|
{
|
2012-10-20 06:36:47 +02:00
|
|
|
|
_jobProvider.QueueJob(typeof(RenameSeriesJob), new { SeriesId = seriesId });
|
2012-02-26 22:47:04 +01:00
|
|
|
|
return JsonNotificationResult.Queued("Series rename");
|
2011-08-23 07:29:12 +02:00
|
|
|
|
}
|
2012-07-21 06:46:16 +02:00
|
|
|
|
|
|
|
|
|
public JsonResult RenameAllSeries()
|
|
|
|
|
{
|
|
|
|
|
_jobProvider.QueueJob(typeof(RenameSeriesJob));
|
|
|
|
|
return JsonNotificationResult.Queued("Series rename");
|
|
|
|
|
}
|
2012-09-04 01:26:52 +02:00
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public JsonResult ChangeEpisodeQuality(int episodeFileId, QualityTypes quality)
|
|
|
|
|
{
|
|
|
|
|
_mediaFileProvider.ChangeQuality(episodeFileId, quality);
|
|
|
|
|
return Json("ok");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public JsonResult ChangeSeasonQuality(int seriesId, int seasonNumber, QualityTypes quality)
|
|
|
|
|
{
|
|
|
|
|
_mediaFileProvider.ChangeQuality(seriesId, seasonNumber, quality);
|
|
|
|
|
return Json("ok");
|
|
|
|
|
}
|
2011-05-27 08:03:57 +02:00
|
|
|
|
}
|
|
|
|
|
}
|