|
|
|
|
using RadarrSharp.Services.Interface;
|
|
|
|
|
using RadarrSharp.Models;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using RadarrSharp.Helpers;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Web;
|
|
|
|
|
|
|
|
|
|
namespace RadarrSharp.Services.Implementation
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public class MovieService : BaseRadarrService, IMovieService
|
|
|
|
|
{
|
|
|
|
|
public MovieService(string ip, string port, string apiKey) : base(ip, port, apiKey)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<IEnumerable<Movie>> GetMovies(string tmdbId = null)
|
|
|
|
|
{
|
|
|
|
|
var movies = await base.GetAsync<IEnumerable<Movie>>("movie", tmdbId.ToTuple("tmdbId").ToList());
|
|
|
|
|
return movies;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<Movie> AddMovie(Movie movie)
|
|
|
|
|
{
|
|
|
|
|
var resp = await base.PostAsync<Movie, Movie>("movie", movie);
|
|
|
|
|
return resp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<Movie> PutMovie(Movie movie, bool moveFiles)
|
|
|
|
|
{
|
|
|
|
|
var resp = await base.PutAsync<Movie, Movie>("movie", movie, moveFiles.ToTuple("moveFiles").ToList());
|
|
|
|
|
return resp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<IEnumerable<Movie>> GetMovie(int id)
|
|
|
|
|
{
|
|
|
|
|
var movies = await base.GetAsync<IEnumerable<Movie>>($"movie/{id}");
|
|
|
|
|
return movies;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<bool> DeleteMovie(int id, bool addImportExclusion, bool deleteFiles)
|
|
|
|
|
{
|
|
|
|
|
var responseMessage = await base.DeleteAsync($"movie/{id}",
|
|
|
|
|
RadarrExtensions.ParamList(
|
|
|
|
|
addImportExclusion.ToTuple("addImportExclusion"),
|
|
|
|
|
deleteFiles.ToTuple("deleteFiles")));
|
|
|
|
|
return responseMessage.IsSuccessStatusCode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<IEnumerable<Movie>> MovieLookup(string searchTerm)
|
|
|
|
|
{
|
|
|
|
|
searchTerm = HttpUtility.UrlEncode(searchTerm);
|
|
|
|
|
var movies = await base.GetAsync<IEnumerable<Movie>>("movie/lookup", searchTerm.ToTuple("term").ToList());
|
|
|
|
|
return movies;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|