public JsonResult LookupSeries(string term)
        {
            try
            {
                var tvDbResults = _tvDbProvider.SearchSeries(term).Select(r => new TvDbSearchResultModel
                {
                    Id             = r.Id,
                    Title          = r.SeriesName,
                    DisplayedTitle = r.FirstAired.Year > 1900 && !r.SeriesName.EndsWith("(" + r.FirstAired.Year + ")")
                                                    ? string.Format("{0} ({1})", r.SeriesName, r.FirstAired.Year)
                                                    : r.SeriesName,
                    Banner = r.Banner.BannerPath,
                    Url    = String.Format("http://www.thetvdb.com/?tab=series&id={0}", r.Id)
                }).ToList();

                return(Json(tvDbResults, JsonRequestBehavior.AllowGet));
            }

            catch (TvdbNotAvailableException ex)
            {
                logger.WarnException("Unable to lookup series on TheTVDB", ex);
                return(JsonNotificationResult.Info("Lookup Failed", "TheTVDB is not available at this time."));
            }

            catch (Exception ex)
            {
                logger.WarnException("Unknown Error when looking up series on TheTVDB", ex);
                return(JsonNotificationResult.Info("Lookup Failed", "Unknown error while connecting to TheTVDB"));
            }
        }
Exemplo n.º 2
0
        public JsonResult SaveDownloadClient(DownloadClientSettingsModel data)
        {
            if (ModelState.IsValid)
            {
                _configProvider.SabHost                    = data.SabHost;
                _configProvider.SabPort                    = data.SabPort;
                _configProvider.SabApiKey                  = data.SabApiKey;
                _configProvider.SabPassword                = data.SabPassword;
                _configProvider.SabTvCategory              = data.SabTvCategory;
                _configProvider.SabUsername                = data.SabUsername;
                _configProvider.SabBacklogTvPriority       = data.SabBacklogTvPriority;
                _configProvider.SabRecentTvPriority        = data.SabRecentTvPriority;
                _configProvider.DownloadClientTvDirectory  = data.DownloadClientDropDirectory;
                _configProvider.BlackholeDirectory         = data.BlackholeDirectory;
                _configProvider.DownloadClient             = (DownloadClientType)data.DownloadClient;
                _configProvider.PneumaticDirectory         = data.PneumaticDirectory;
                _configProvider.DownloadClientUseSceneName = data.UseSceneName;
                _configProvider.NzbgetHost                 = data.NzbgetHost;
                _configProvider.NzbgetPort                 = data.NzbgetPort;
                _configProvider.NzbgetUsername             = data.NzbgetUsername;
                _configProvider.NzbgetPassword             = data.NzbgetPassword;
                _configProvider.NzbgetTvCategory           = data.NzbgetTvCategory;
                _configProvider.NzbgetBacklogTvPriority    = (PriorityType)data.NzbgetBacklogTvPriority;
                _configProvider.NzbgetRecentTvPriority     = (PriorityType)data.NzbgetRecentTvPriority;

                return(GetSuccessResult());
            }

            return(JsonNotificationResult.Oops("Invalid Data"));
        }
Exemplo n.º 3
0
        public JsonResult Delete(int historyId)
        {
            //Delete the existing item from history
            _historyProvider.Delete(historyId);

            return(JsonNotificationResult.Info("History Item Deleted"));
        }
        public JsonResult ForceRefreshAll()
        {
            _jobProvider.QueueJob(typeof(UpdateInfoJob));
            _jobProvider.QueueJob(typeof(DiskScanJob));
            _jobProvider.QueueJob(typeof(RefreshEpisodeMetadata));

            return(JsonNotificationResult.Queued("Episode update/Disk scan"));
        }
        public JsonResult ForceRefresh(int seriesId)
        {
            _jobProvider.QueueJob(typeof(UpdateInfoJob), new { SeriesId = seriesId });
            _jobProvider.QueueJob(typeof(DiskScanJob), new { SeriesId = seriesId });
            _jobProvider.QueueJob(typeof(RefreshEpisodeMetadata), new { SeriesId = seriesId });

            return(JsonNotificationResult.Queued("Episode update/Disk scan"));
        }
        public JsonResult TestEmail(string server, int port, bool ssl, string username, string password, string fromAddress, string toAddresses)
        {
            if (_smtpProvider.SendTestEmail(server, port, ssl, username, password, fromAddress, toAddresses))
            {
                return(JsonNotificationResult.Info("Successful", "Test email sent."));
            }

            return(JsonNotificationResult.Oops("Couldn't send Email, please check your settings"));
        }
Exemplo n.º 7
0
        public JsonResult RunJob(string typeName)
        {
            if (!_jobProvider.QueueJob(typeName))
            {
                return(JsonNotificationResult.Oops("Invalid Job Name"));
            }

            return(JsonNotificationResult.Info("Job Queued"));
        }
Exemplo n.º 8
0
        public JsonResult Redownload(int historyId, int episodeId)
        {
            //Delete the existing item from history
            _historyProvider.Delete(historyId);

            //Queue a job to download the replacement episode
            _jobProvider.QueueJob(typeof(EpisodeSearchJob), new { EpisodeId = episodeId });

            return(JsonNotificationResult.Queued("Episode search"));
        }
        public JsonResult VerifyTwitterAuthorization(string token, string verifier)
        {
            var result = _twitterProvider.GetAndSaveAccessToken(token, verifier);

            if (!result)
            {
                JsonNotificationResult.Oops("Couldn't verify Twitter Authorization");
            }

            return(JsonNotificationResult.Info("Good News!", "Successfully verified Twitter Authorization."));
        }
Exemplo n.º 10
0
        public JsonResult DeleteQualityProfile(int profileId)
        {
            if (_seriesProvider.GetAllSeries().Where(s => s.QualityProfileId == profileId).Count() != 0)
            {
                return(JsonNotificationResult.Oops("Profile is still in use."));
            }

            _qualityProvider.Delete(profileId);

            return(Json("ok"));
        }
Exemplo n.º 11
0
        public JsonResult TestNzbget(string host, int port, string username, string password)
        {
            //_prowlProvider.TestNotification(apiKeys);
            var version = _nzbgetProvider.Test(host, port, username, password);

            if (String.IsNullOrWhiteSpace(version))
            {
                return(JsonNotificationResult.Oops("Failed to connect to Nzbget, please check your settings"));
            }

            return(JsonNotificationResult.Info("Success!", "Nzbget settings have been verified successfully! Version: " + version));
        }
Exemplo n.º 12
0
        public JsonResult TestPlexServer(string host)
        {
            try
            {
                _plexProvider.GetSectionKeys(host);
                return(JsonNotificationResult.Info("Success!", "Successfully tested Server settings"));
            }
            catch (Exception)
            {
            }

            return(JsonNotificationResult.Oops("Failed to connect to server, please review your settings."));
        }
Exemplo n.º 13
0
        public JsonResult TestXbmcJsonApi(string hosts, string username, string password)
        {
            try
            {
                _xbmcProvider.TestJsonApi(hosts, username, password);
                return(JsonNotificationResult.Info("Success!", "Successfully tested JSON API"));
            }
            catch (Exception)
            {
            }

            return(JsonNotificationResult.Oops("Failed to test JSON API, please review your settings."));
        }
Exemplo n.º 14
0
        public JsonResult TestXbmcNotification(string hosts)
        {
            try
            {
                _xbmcProvider.TestNotification(hosts);
                return(JsonNotificationResult.Info("Success!", "Test Notification sent successfully"));
            }
            catch (Exception)
            {
            }

            return(JsonNotificationResult.Oops("Failed to send test notification, please review your settings."));
        }
Exemplo n.º 15
0
        public JsonResult GetTwitterAuthorization()
        {
            var result = _twitterProvider.GetAuthorization();

            if (result == null)
            {
                JsonNotificationResult.Oops("Couldn't get Twitter Authorization");
            }

            return(new JsonResult {
                Data = result, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
        public JsonResult SaveRootDir(string path)
        {
            if (String.IsNullOrWhiteSpace(path))
            {
                JsonNotificationResult.Error("Can't add root folder", "Path can not be empty");
            }

            _rootFolderProvider.Add(new RootDir {
                Path = path
            });

            return(JsonNotificationResult.Info("Root Folder saved", "Root folder saved successfully."));
        }
Exemplo n.º 17
0
        public JsonResult TestPlexNotification(string hosts, string username, string password)
        {
            try
            {
                _plexProvider.TestNotification(hosts, username, password);
                return(JsonNotificationResult.Info("Success!", "Test Notification sent successfully"));
            }
            catch (Exception)
            {
            }

            return(JsonNotificationResult.Oops("Failed to send test notification, please review your settings."));
        }
        public JsonResult AddNewSeries(string path, string seriesName, int seriesId, int qualityProfileId, string startDate)
        {
            if (string.IsNullOrWhiteSpace(path) || String.Equals(path, "null", StringComparison.InvariantCultureIgnoreCase))
            {
                return(JsonNotificationResult.Error("Couldn't add " + seriesName, "You need a valid root folder"));
            }

            path = Path.Combine(path, MediaFileProvider.CleanFilename(seriesName));

            //Create the folder for the new series
            //Use the created folder name when adding the series
            path = _diskProvider.CreateDirectory(path);

            return(AddExistingSeries(path, seriesName, seriesId, qualityProfileId, startDate));
        }
Exemplo n.º 19
0
        public JsonResult AutoConfigureSab()
        {
            try
            {
                var info = _autoConfigureProvider.AutoConfigureSab();

                if (info != null)
                {
                    return(Json(info, JsonRequestBehavior.AllowGet));
                }
            }

            catch (Exception)
            {
            }

            return(JsonNotificationResult.Error("Auto-Configure Failed", "Please enter your SAB Settings Manually"));
        }
Exemplo n.º 20
0
        public JsonResult RegisterGrowl(string host, string password)
        {
            try
            {
                var split    = host.Split(':');
                var hostname = split[0];
                var port     = Convert.ToInt32(split[1]);

                _growlProvider.Register(hostname, port, password);
                _growlProvider.TestNotification(hostname, port, password);

                return(JsonNotificationResult.Info("Good News!", "Registered and tested growl successfully"));
            }
            catch (Exception ex)
            {
                logger.TraceException(ex.Message, ex);
                return(JsonNotificationResult.Oops("Couldn't register and test Growl"));
            }
        }
        public JsonResult AddExistingSeries(string path, string seriesName, int seriesId, int qualityProfileId, string startDate)
        {
            if (seriesId == 0 || String.IsNullOrWhiteSpace(seriesName))
            {
                return(JsonNotificationResult.Error("Add Existing series failed.", "Invalid Series information"));
            }

            DateTime?date = null;

            if (!String.IsNullOrWhiteSpace(startDate))
            {
                date = DateTime.Parse(startDate, null, DateTimeStyles.RoundtripKind);
            }

            _seriesProvider.AddSeries(seriesName, path, seriesId, qualityProfileId, date);
            _jobProvider.QueueJob(typeof(ImportNewSeriesJob));

            return(JsonNotificationResult.Info(seriesName, "Was added successfully"));
        }
Exemplo n.º 22
0
        public JsonResult Editor(List <SeriesModel> series)
        {
            //Save edits
            if (series == null || series.Count == 0)
            {
                return(JsonNotificationResult.Oops("Invalid post data"));
            }

            _seriesProvider.UpdateFromSeriesEditor(series.Select(s => new Series
            {
                SeriesId         = s.SeriesId,
                QualityProfileId = s.QualityProfileId,
                Monitored        = s.Monitored,
                SeasonFolder     = s.SeasonFolder,
                BacklogSetting   = (BacklogSettingType)s.BacklogSetting,
                Path             = s.Path,
                CustomStartDate  = String.IsNullOrWhiteSpace(s.CustomStartDate) ? (DateTime?)null
                                                                                : DateTime.Parse(s.CustomStartDate, null, DateTimeStyles.RoundtripKind)
            }
                                                                 ).ToList());
            return(JsonNotificationResult.Info("Series Mass Edit Saved"));
        }
Exemplo n.º 23
0
 private JsonResult GetInvalidModelResult()
 {
     return(JsonNotificationResult.Oops("Invalid post data"));
 }
Exemplo n.º 24
0
 public JsonResult RenameSeries(int seriesId)
 {
     _jobProvider.QueueJob(typeof(RenameSeriesJob), new { SeriesId = seriesId });
     return(JsonNotificationResult.Queued("Series rename"));
 }
Exemplo n.º 25
0
 private JsonResult GetSuccessResult()
 {
     return(JsonNotificationResult.Info("Settings Saved"));
 }
Exemplo n.º 26
0
        public JsonResult SaveIndexers(IndexerSettingsModel data)
        {
            if (ModelState.IsValid)
            {
                _configProvider.Retention = data.Retention;

                var nzbsRUsSettings = _indexerProvider.GetSettings(typeof(NzbsRUs));
                nzbsRUsSettings.Enable = data.NzbsRUsEnabled;
                _indexerProvider.SaveSettings(nzbsRUsSettings);

                var newznabSettings = _indexerProvider.GetSettings(typeof(Newznab));
                newznabSettings.Enable = data.NewznabEnabled;
                _indexerProvider.SaveSettings(newznabSettings);

                var womblesSettings = _indexerProvider.GetSettings(typeof(Wombles));
                womblesSettings.Enable = data.WomblesEnabled;
                _indexerProvider.SaveSettings(womblesSettings);

                var fileSharingTalkSettings = _indexerProvider.GetSettings(typeof(FileSharingTalk));
                fileSharingTalkSettings.Enable = data.FileSharingTalkEnabled;
                _indexerProvider.SaveSettings(fileSharingTalkSettings);

                var nzbIndexSettings = _indexerProvider.GetSettings(typeof(NzbIndex));
                nzbIndexSettings.Enable = data.NzbIndexEnabled;
                _indexerProvider.SaveSettings(nzbIndexSettings);

                var nzbClubSettings = _indexerProvider.GetSettings(typeof(NzbClub));
                nzbClubSettings.Enable = data.NzbClubEnabled;
                _indexerProvider.SaveSettings(nzbClubSettings);

                var omgwtfnzbsSettings = _indexerProvider.GetSettings(typeof(Omgwtfnzbs));
                omgwtfnzbsSettings.Enable = data.OmgwtfnzbsEnabled;
                _indexerProvider.SaveSettings(omgwtfnzbsSettings);

                var nzbxSettings = _indexerProvider.GetSettings(typeof(Nzbx));
                nzbxSettings.Enable = data.NzbxEnabled;
                _indexerProvider.SaveSettings(nzbxSettings);

                _configProvider.NzbsrusUId  = data.NzbsrusUId;
                _configProvider.NzbsrusHash = data.NzbsrusHash;

                _configProvider.FileSharingTalkUid    = data.FileSharingTalkUid;
                _configProvider.FileSharingTalkSecret = data.FileSharingTalkSecret;

                _configProvider.OmgwtfnzbsUsername = data.OmgwtfnzbsUsername;
                _configProvider.OmgwtfnzbsApiKey   = data.OmgwtfnzbsApiKey;

                //Save the interval to config and immediately apply it the the job (to avoid a restart)
                _configProvider.RssSyncInterval = data.RssSyncInterval;

                var rssSyncJob = _jobProvider.GetDefinition(typeof(RssSyncJob));
                rssSyncJob.Interval = data.RssSyncInterval;
                _jobProvider.SaveDefinition(rssSyncJob);

                try
                {
                    if (data.NewznabDefinitions != null)
                    {
                        _newznabProvider.SaveAll(data.NewznabDefinitions);
                    }
                }
                catch (Exception)
                {
                    return(JsonNotificationResult.Oops("Invalid Nzbnab Indexer found, please check your settings"));
                }

                return(GetSuccessResult());
            }

            return(GetInvalidModelResult());
        }
Exemplo n.º 27
0
 public JsonResult RenameAllSeries()
 {
     _jobProvider.QueueJob(typeof(RenameSeriesJob));
     return(JsonNotificationResult.Queued("Series rename"));
 }
        public JsonResult ForceDownload(int id)
        {
            _searchHistoryProvider.ForceDownload(id);

            return(JsonNotificationResult.Info("Success", "Requested episode has been sent to download client"));
        }
Exemplo n.º 29
0
 public JsonResult Shutdown()
 {
     _jobProvider.QueueJob(typeof(AppShutdownJob));
     return(JsonNotificationResult.Info("NzbDrone will shutdown shortly"));
 }
Exemplo n.º 30
0
 public JsonResult Restart()
 {
     _jobProvider.QueueJob(typeof(AppRestartJob));
     return(JsonNotificationResult.Info("NzbDrone will restart shortly"));
 }