mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-09 20:42:37 +01:00
4188946395
file name sample uses HTTP GET instead of post
45 lines
1.4 KiB
C#
45 lines
1.4 KiB
C#
using System.Collections.Generic;
|
|
using NzbDrone.Api.REST;
|
|
using NzbDrone.Core.MediaFiles;
|
|
using NzbDrone.Api.Mapping;
|
|
|
|
namespace NzbDrone.Api.EpisodeFiles
|
|
{
|
|
public class EpisodeModule : NzbDroneRestModule<EpisodeFileResource>
|
|
{
|
|
private readonly IMediaFileService _mediaFileService;
|
|
|
|
public EpisodeModule(IMediaFileService mediaFileService)
|
|
: base("/episodefile")
|
|
{
|
|
_mediaFileService = mediaFileService;
|
|
GetResourceById = GetEpisodeFile;
|
|
GetResourceAll = GetEpisodeFiles;
|
|
UpdateResource = SetQuality;
|
|
}
|
|
|
|
private EpisodeFileResource GetEpisodeFile(int id)
|
|
{
|
|
return _mediaFileService.Get(id).InjectTo<EpisodeFileResource>();
|
|
}
|
|
|
|
private List<EpisodeFileResource> GetEpisodeFiles()
|
|
{
|
|
var seriesId = (int?)Request.Query.SeriesId;
|
|
|
|
if (seriesId == null)
|
|
{
|
|
throw new BadRequestException("seriesId is missing");
|
|
}
|
|
|
|
return ToListResource(() => _mediaFileService.GetFilesBySeries(seriesId.Value));
|
|
}
|
|
|
|
private void SetQuality(EpisodeFileResource episodeFileResource)
|
|
{
|
|
var episodeFile = _mediaFileService.Get(episodeFileResource.Id);
|
|
episodeFile.Quality = episodeFileResource.Quality;
|
|
_mediaFileService.Update(episodeFile);
|
|
}
|
|
}
|
|
} |