public async Task <MovieSenderResult> Send(RequestedModel model, string qualityId = "") { var cpSettings = await CouchPotatoSettings.GetSettingsAsync(); var watcherSettings = await WatcherSettings.GetSettingsAsync(); var radarrSettings = await RadarrSettings.GetSettingsAsync(); if (cpSettings.Enabled) { return(SendToCp(model, cpSettings, string.IsNullOrEmpty(qualityId) ? cpSettings.ProfileId : qualityId)); } if (watcherSettings.Enabled) { return(SendToWatcher(model, watcherSettings)); } if (radarrSettings.Enabled) { return(SendToRadarr(model, radarrSettings)); } return(new MovieSenderResult { Result = false, MovieSendingEnabled = false }); }
public bool SaveSettings(CouchPotatoSettingsDto model) { var entity = Repo.Get(model.Id); if (entity == null) { var newEntity = new CouchPotatoSettings(); newEntity.InjectFrom(model); var insertResult = Repo.Insert(newEntity); return(insertResult != long.MinValue); } entity.Enabled = model.Enabled; entity.IpAddress = model.IpAddress; entity.Port = model.Port; entity.ApiKey = model.ApiKey; entity.Id = model.Id; entity.ShowOnDashboard = model.ShowOnDashboard; entity.Username = model.Username; entity.Password = model.Password; var result = Repo.Update(entity); return(result); }
public void SetUp() { var mockRepo = new Mock <ISqlRepository <CouchPotatoSettings> >(); ExpectedGetLinks = new List <CouchPotatoSettings> { new CouchPotatoSettings { Id = 1, Enabled = true, ApiKey = "abc", IpAddress = "192", Password = "******", Port = 25, Username = "******", ShowOnDashboard = true } }; ExpectedLink = new CouchPotatoSettings { Id = 1, Enabled = true, ApiKey = "abc", IpAddress = "192", Password = "******", Port = 25, Username = "******", ShowOnDashboard = true }; mockRepo.Setup(x => x.GetAll()).Returns(ExpectedGetLinks).Verifiable(); mockRepo.Setup(x => x.Get(1)).Returns(ExpectedLink).Verifiable(); mockRepo.Setup(x => x.Update(It.IsAny <CouchPotatoSettings>())).Returns(true).Verifiable(); mockRepo.Setup(x => x.Insert(It.IsAny <CouchPotatoSettings>())).Returns(1).Verifiable(); MockRepo = mockRepo; Service = new CouchPotatoSettingsService(mockRepo.Object); }
private bool ProcessMovies(RequestedModel model, CouchPotatoSettings cp) { try { if (cp.Enabled) { var result = CpApi.AddMovie(model.ImdbId, cp.ApiKey, model.Title, cp.FullUri, cp.ProfileId); if (result) { // Approve it now model.Approved = true; RequestService.UpdateRequest(model); } ; return(result); } return(false); } catch (Exception e) { Log.Error(e); return(false); // It fails so it will get added back into the queue } }
public static void ResetDatabase() { var defaultSettings = new PlexRequestSettings { RequireTvShowApproval = true, RequireMovieApproval = true, SearchForMovies = true, SearchForTvShows = true, BaseUrl = string.Empty, CollectAnalyticData = true, }; UpdateSettings(defaultSettings); LandingPageSettings lp = null; PlexSettings plexSettings = null; SonarrSettings sonarr = null; CouchPotatoSettings cp = null; SickRageSettings sr = null; UpdateSettings(lp); UpdateSettings(plexSettings); UpdateSettings(sonarr); UpdateSettings(cp); UpdateSettings(sr); }
private async Task <SenderResult> SendToCp(FullBaseRequest model, CouchPotatoSettings cpSettings, string cpSettingsDefaultProfileId) { var result = await CouchPotatoApi.AddMovie(model.ImdbId, cpSettings.ApiKey, model.Title, cpSettings.FullUri, cpSettingsDefaultProfileId); return(new SenderResult { Success = result, Sent = true }); }
private bool SendMovie(CouchPotatoSettings settings, RequestedModel r, ICouchPotatoApi cp) { Log.Info("Adding movie to CP : {0}", r.Title); var result = cp.AddMovie(r.ImdbId, settings.ApiKey, r.Title, settings.FullUri, settings.ProfileId); Log.Trace("Adding movie to CP result {0}", result); return(result); }
private MovieSenderResult SendToCp(RequestedModel model, CouchPotatoSettings settings, string qualityId) { var result = CpApi.AddMovie(model.ImdbId, settings.ApiKey, model.Title, settings.FullUri, qualityId); return(new MovieSenderResult { Result = result, MovieSendingEnabled = true }); }
public async Task <bool> CouchPotato([FromBody] CouchPotatoSettings settings) { try { var result = await CouchPotatoApi.Status(settings.FullUri, settings.ApiKey); return(result?.success ?? false); } catch (Exception e) { Log.LogError(LoggingEvents.Api, e, "Could not test CP"); return(false); } }
public async Task <SenderResult> Send(MovieRequests model) { var cpSettings = await CouchPotatoSettings.GetSettingsAsync(); //var watcherSettings = await WatcherSettings.GetSettingsAsync(); var radarrSettings = await RadarrSettings.GetSettingsAsync(); if (radarrSettings.Enabled) { return(await SendToRadarr(model, radarrSettings)); } var dogSettings = await DogNzbSettings.GetSettingsAsync(); if (dogSettings.Enabled) { await SendToDogNzb(model, dogSettings); return(new SenderResult { Success = true, Sent = true, }); } if (cpSettings.Enabled) { return(await SendToCp(model, cpSettings, cpSettings.DefaultProfileId)); } //if (watcherSettings.Enabled) //{ // return SendToWatcher(model, watcherSettings); //} return(new SenderResult { Success = true, Sent = false, }); }
public void SaveBadCpSettings() { var model = new CouchPotatoSettings { Ip = "q", Ssl = true, }; var browser = new Browser(Bootstrapper); var result = browser.Post("/api/settings/couchpotato", with => { with.HttpRequest(); with.Header("Accept", "application/json"); with.Query("apikey", "api"); with.JsonBody(model); }); var body = JsonConvert.DeserializeObject <ApiModel <bool> >(result.Body.AsString()); Assert.That(body.Data, Is.EqualTo(false)); Assert.That(body.Error, Is.True); Assert.That(body.ErrorMessage, Is.EqualTo("Could not update the settings")); }
public async Task <SenderResult> Send(MovieRequests model) { try { var cpSettings = await CouchPotatoSettings.GetSettingsAsync(); //var watcherSettings = await WatcherSettings.GetSettingsAsync(); var radarrSettings = await RadarrSettings.GetSettingsAsync(); if (radarrSettings.Enabled) { return(await SendToRadarr(model, radarrSettings)); } var dogSettings = await DogNzbSettings.GetSettingsAsync(); if (dogSettings.Enabled) { await SendToDogNzb(model, dogSettings); return(new SenderResult { Success = true, Sent = true, }); } if (cpSettings.Enabled) { return(await SendToCp(model, cpSettings, cpSettings.DefaultProfileId)); } } catch (Exception e) { Log.LogError(e, "Error when seing movie to DVR app, added to the request queue"); // Check if already in request quee var existingQueue = await _requestQueuRepository.FirstOrDefaultAsync(x => x.RequestId == model.Id); if (existingQueue != null) { existingQueue.RetryCount++; existingQueue.Error = e.Message; await _requestQueuRepository.SaveChangesAsync(); } else { await _requestQueuRepository.Add(new RequestQueue { Dts = DateTime.UtcNow, Error = e.Message, RequestId = model.Id, Type = RequestType.Movie, RetryCount = 0 }); _notificationHelper.Notify(model, NotificationType.ItemAddedToFaultQueue); } } return(new SenderResult { Success = true, Sent = false, }); }
public async Task <bool> CouchPotatoSettings([FromBody] CouchPotatoSettings settings) { return(await Save(settings)); }
public async Task <CouchPotatoApiKey> GetApiKey([FromBody] CouchPotatoSettings settings) { var apiKey = await _api.GetApiKey(settings.FullUri, settings.Username, settings.Password); return(apiKey); }
public async Task <CouchPotatoProfiles> GetQualityProfiles([FromBody] CouchPotatoSettings settings) { var profiles = await _api.GetProfiles(settings.FullUri, settings.ApiKey); return(profiles); }