1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-12 11:15:43 +02:00

Issue with overwriting user settings for Indexers resolved.

Reworked RssSyncProvider to make it cleaner.

SeasonProvider was returning the reveresed boolean result

Indexer changed to not store empty strings as null when saving config (ApiUrl).
This commit is contained in:
markus101 2011-02-15 23:58:39 -08:00
parent d83ae9895c
commit a7780fab67
4 changed files with 40 additions and 31 deletions

View File

@ -66,7 +66,7 @@ public static void BindKernel()
_kernel.Bind<ISyncProvider>().To<SyncProvider>().InSingletonScope();
_kernel.Bind<IRssProvider>().To<RssProvider>().InSingletonScope();
_kernel.Bind<IRssSyncProvider>().To<RssSyncProvider>().InSingletonScope();
_kernel.Bind<IIndexerProvider>().To<IndexerProvider>().InSingletonScope();;
_kernel.Bind<IIndexerProvider>().To<IndexerProvider>().InSingletonScope(); ;
_kernel.Bind<INotificationProvider>().To<NotificationProvider>().InSingletonScope();
_kernel.Bind<ILogProvider>().To<LogProvider>().InSingletonScope();
_kernel.Bind<IMediaFileProvider>().To<MediaFileProvider>().InSingletonScope();
@ -176,7 +176,6 @@ private static void SetupIndexers(IRepository repository)
IndexerName = "NzbMatrix",
RssUrl = nzbMatrixRss,
ApiUrl = String.Empty,
Enabled = false,
Order = 1
};
@ -185,7 +184,6 @@ private static void SetupIndexers(IRepository repository)
IndexerName = "NzbsOrg",
RssUrl = nzbsOrgRss,
ApiUrl = String.Empty,
Enabled = false,
Order = 2
};
@ -194,13 +192,13 @@ private static void SetupIndexers(IRepository repository)
IndexerName = "Nzbsrus",
RssUrl = nzbsrusRss,
ApiUrl = String.Empty,
Enabled = false,
Order = 3
};
//NzbMatrix
Logger.Debug("Checking for NzbMatrix Indexer");
if (!repository.Exists<Indexer>(i => i.IndexerName == "NzbMatrix"))
var nzbMatix = repository.Single<Indexer>("NzbMatrix");
if (nzbMatix == null)
{
Logger.Debug("Adding new Indexer: NzbMatrix");
repository.Add(nzbMatrixIndexer);
@ -209,12 +207,15 @@ private static void SetupIndexers(IRepository repository)
else
{
Logger.Debug("Updating Indexer: NzbMatrix");
repository.Update(nzbMatrixIndexer);
nzbMatix.RssUrl = nzbMatrixIndexer.RssUrl;
nzbMatix.ApiUrl = nzbMatrixIndexer.ApiUrl;
repository.Update(nzbMatix);
}
//Nzbs.org
Logger.Debug("Checking for Nzbs.org");
if (!repository.Exists<Indexer>(i => i.IndexerName == "NzbsOrg"))
var nzbsOrg = repository.Single<Indexer>("NzbsOrg");
if (nzbsOrg == null)
{
Logger.Debug("Adding new Indexer: Nzbs.org");
repository.Add(nzbsOrgIndexer);
@ -223,12 +224,15 @@ private static void SetupIndexers(IRepository repository)
else
{
Logger.Debug("Updating Indexer: Nzbs.org");
repository.Update(nzbsOrgIndexer);
nzbsOrg.RssUrl = nzbsOrgIndexer.RssUrl;
nzbsOrg.ApiUrl = nzbsOrgIndexer.ApiUrl;
repository.Update(nzbsOrg);
}
//Nzbsrus
Logger.Debug("Checking for Nzbsrus");
if (!repository.Exists<Indexer>(i => i.IndexerName == "Nzbsrus"))
var nzbsrus = repository.Single<Indexer>("Nzbsrus");
if (nzbsrus == null)
{
Logger.Debug("Adding new Indexer: Nzbsrus");
repository.Add(nzbsrusIndexer);
@ -237,7 +241,9 @@ private static void SetupIndexers(IRepository repository)
else
{
Logger.Debug("Updating Indexer: Nzbsrus");
repository.Update(nzbsrusIndexer);
nzbsrus.RssUrl = nzbsOrgIndexer.RssUrl;
nzbsrus.ApiUrl = nzbsOrgIndexer.ApiUrl;
repository.Update(nzbsrus);
}
}
@ -246,42 +252,42 @@ private static void SetupDefaultQualityProfiles(IRepository repository)
var sdtv = new QualityProfile
{
Name = "SDTV",
Allowed = new List<QualityTypes> {QualityTypes.TV},
Allowed = new List<QualityTypes> { QualityTypes.TV },
Cutoff = QualityTypes.TV
};
var dvd = new QualityProfile
{
Name = "DVD SD",
Allowed = new List<QualityTypes> {QualityTypes.DVD},
Allowed = new List<QualityTypes> { QualityTypes.DVD },
Cutoff = QualityTypes.DVD
};
var bdrip = new QualityProfile
{
Name = "BDRip",
Allowed = new List<QualityTypes> {QualityTypes.BDRip},
Allowed = new List<QualityTypes> { QualityTypes.BDRip },
Cutoff = QualityTypes.BDRip
};
var hdtv = new QualityProfile
{
Name = "HDTV",
Allowed = new List<QualityTypes> {QualityTypes.HDTV},
Allowed = new List<QualityTypes> { QualityTypes.HDTV },
Cutoff = QualityTypes.HDTV
};
var webdl = new QualityProfile
{
Name = "WEBDL",
Allowed = new List<QualityTypes> {QualityTypes.WEBDL},
Allowed = new List<QualityTypes> { QualityTypes.WEBDL },
Cutoff = QualityTypes.WEBDL
};
var bluray = new QualityProfile
{
Name = "Bluray",
Allowed = new List<QualityTypes> {QualityTypes.Bluray},
Allowed = new List<QualityTypes> { QualityTypes.Bluray },
Cutoff = QualityTypes.Bluray
};

View File

@ -87,9 +87,10 @@ private void SyncWithRss()
{
Logger.Info("Starting RSS Sync for: {0}", i.IndexerName);
//Need to insert the users information in the the URL before trying to use it
i.RssUrl = GetUsersUrl(i); //Get the new users specific url (with their information) to use for the Sync
GetUsersUrl(i); //Get the new users specific url (with their information) to use for the Sync
if (i.RssUrl == null)
//If the url still contains '{' & '}' the user probably hasn't configured the indexer settings
if (i.RssUrl.Contains("{") && i.RssUrl.Contains("}"))
{
Logger.Debug("Unable to Sync {0}. User Information has not been configured.", i.IndexerName);
continue; //Skip this indexer
@ -200,7 +201,7 @@ private string GetTitleFix(List<EpisodeParseResult> episodes, int seriesId)
return String.Format("{0} - {1}{2} - {3}", series.Title, seasonNumber, episodeNumbers, episodeTitles);
}
private string GetUsersUrl(Indexer indexer)
private void GetUsersUrl(Indexer indexer)
{
if (indexer.IndexerName == "NzbMatrix")
{
@ -208,10 +209,10 @@ private string GetUsersUrl(Indexer indexer)
var nzbMatrixApiKey = _configProvider.GetValue("NzbMatrixApiKey", String.Empty, false);
if (!String.IsNullOrEmpty(nzbMatrixUsername) && !String.IsNullOrEmpty(nzbMatrixApiKey))
return indexer.RssUrl.Replace("{USERNAME}", nzbMatrixUsername).Replace("{APIKEY}", nzbMatrixApiKey);
indexer.RssUrl = indexer.RssUrl.Replace("{USERNAME}", nzbMatrixUsername).Replace("{APIKEY}", nzbMatrixApiKey);
//Todo: Perform validation at the config level so a user is unable to enable a provider until user details are provided
return null; //Return Null if Provider is enabled, but user information is not supplied.
return;
}
if (indexer.IndexerName == "NzbsOrg")
@ -220,10 +221,10 @@ private string GetUsersUrl(Indexer indexer)
var nzbsOrgHash = _configProvider.GetValue("NzbsOrgHash", String.Empty, false);
if (!String.IsNullOrEmpty(nzbsOrgUId) && !String.IsNullOrEmpty(nzbsOrgHash))
return indexer.RssUrl.Replace("{UID}", nzbsOrgUId).Replace("{HASH}", nzbsOrgHash);
indexer.RssUrl = indexer.RssUrl.Replace("{UID}", nzbsOrgUId).Replace("{HASH}", nzbsOrgHash);
//Todo: Perform validation at the config level so a user is unable to enable a provider until user details are provided
return null; //Return Null if Provider is enabled, but user information is not supplied.
return;
}
if (indexer.IndexerName == "NzbsOrg")
@ -232,13 +233,13 @@ private string GetUsersUrl(Indexer indexer)
var nzbsrusHash = _configProvider.GetValue("NzbsrusHash", String.Empty, false);
if (!String.IsNullOrEmpty(nzbsrusUId) && !String.IsNullOrEmpty(nzbsrusHash))
return indexer.RssUrl.Replace("{UID}", nzbsrusUId).Replace("{HASH}", nzbsrusHash);
indexer.RssUrl = indexer.RssUrl.Replace("{UID}", nzbsrusUId).Replace("{HASH}", nzbsrusHash);
//Todo: Perform validation at the config level so a user is unable to enable a provider until user details are provided
return null; //Return Null if Provider is enabled, but user information is not supplied.
return;
}
return indexer.RssUrl; //Currently other providers do not require user information to be substituted, simply return the RssUrl
return; //Currently other providers do not require user information to be substituted, simply return
}
}
}

View File

@ -57,19 +57,19 @@ public int SaveSeason(Season season)
public bool IsIgnored(int seasonId)
{
if (_sonicRepo.Single<Season>(seasonId).Monitored)
return true;
return false;
Logger.Debug("Season {0} is not wanted.");
return false;
return true;
}
public bool IsIgnored(int seriesId, int seasonNumber)
{
if (_sonicRepo.Single<Season>(s => s.SeriesId == seriesId && s.SeasonNumber == seasonNumber).Monitored)
return true;
return false;
Logger.Debug("Season: {0} is not wanted for Series: {1}", seasonNumber, seriesId);
return false;
return true;
}
}
}

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using SubSonic.SqlGeneration.Schema;
@ -9,11 +10,12 @@ namespace NzbDrone.Core.Repository
{
public class Indexer
{
[SubSonicPrimaryKey (true)]
[SubSonicPrimaryKey(true)]
public string IndexerName { get; set; }
public string RssUrl { get; set; }
[SubSonicNullStringAttribute]
[DisplayFormat(ConvertEmptyStringToNull = false)]
public string ApiUrl { get; set; }
public bool Enabled { get; set; }
public int Order { get; set; }