Fixed some resharper line breaks

pull/4/head
Keivan 14 years ago
parent d00744aafa
commit de212f8b98

@ -36,10 +36,12 @@ namespace NzbDrone.Core.Providers
var dbValue = _sonicRepo.Single<Config>(key);
if (dbValue != null && !String.IsNullOrEmpty(dbValue.Value)) return dbValue.Value;
if (dbValue != null && !String.IsNullOrEmpty(dbValue.Value))
return dbValue.Value;
_logger.WarnFormat("Unable to find config key '{0}' defaultValue:'{1}'", key, defaultValue);
if (makePermanent) SetValue(key, defaultValue.ToString());
if (makePermanent)
SetValue(key, defaultValue.ToString());
value = defaultValue.ToString();
return value;
@ -47,14 +49,22 @@ namespace NzbDrone.Core.Providers
public void SetValue(string key, string value)
{
if (String.IsNullOrEmpty(key)) throw new ArgumentOutOfRangeException("key");
if (value == null) throw new ArgumentNullException("key");
if (String.IsNullOrEmpty(key))
throw new ArgumentOutOfRangeException("key");
if (value == null)
throw new ArgumentNullException("key");
_logger.DebugFormat("Writing Setting to file. Key:'{0}' Value:'{1}'", key, value);
var dbValue = _sonicRepo.Single<Config>(key);
if (dbValue == null) _sonicRepo.Add(new Config {Key = key, Value = value});
if (dbValue == null)
{
_sonicRepo.Add(new Config {
Key = key,
Value = value
});
}
else
{
dbValue.Value = value;

@ -26,7 +26,8 @@ namespace NzbDrone.Core.Providers
public static string CleanPath(string path)
{
if (string.IsNullOrEmpty(path)) throw new ArgumentException("Path can not be null or empty");
if (string.IsNullOrEmpty(path))
throw new ArgumentException("Path can not be null or empty");
return path.ToLower().Trim('/', '\\', ' ');
}
}

@ -1,4 +1,3 @@
using System;
using System.Text.RegularExpressions;
using NzbDrone.Core.Repository;
@ -6,7 +5,7 @@ namespace NzbDrone.Core.Providers
{
public class EpisodeProvider
{
private static readonly Regex _parseRegex = new Regex(@"(?<showName>.*)
private static readonly Regex ParseRegex = new Regex(@"(?<showName>.*)
(?:
s(?<seasonNumber>\d+)e(?<episodeNumber>\d+)-?e(?<episodeNumber2>\d+)
| s(?<seasonNumber>\d+)e(?<episodeNumber>\d+)
@ -23,16 +22,26 @@ namespace NzbDrone.Core.Providers
public static Episode Parse(string title)
{
Match match = _parseRegex.Match(title);
Match match = ParseRegex.Match(title);
if (!match.Success) return null;
if (!match.Success)
return null;
return new Episode {Season = ParseInt(match.Groups["seasonNumber"].Value), EpisodeNumber = ParseInt(match.Groups["episodeNumber"].Value), EpisodeNumber2 = ParseInt(match.Groups["episodeNumber2"].Value), Title = ReplaceSeparatorChars(match.Groups["episodeName"].Value), Release = ReplaceSeparatorChars(match.Groups["release"].Value), Proper = title.Contains("PROPER")};
return new Episode {
Season = ParseInt(match.Groups["seasonNumber"].Value),
EpisodeNumber = ParseInt(match.Groups["episodeNumber"].Value),
EpisodeNumber2 = ParseInt(match.Groups["episodeNumber2"].Value),
Title = ReplaceSeparatorChars(match.Groups["episodeName"].Value),
Release = ReplaceSeparatorChars(match.Groups["release"].Value),
Proper = title.Contains("PROPER")
};
}
private static string ReplaceSeparatorChars(string s)
{
if (s == null) return string.Empty;
if (s == null)
return string.Empty;
return s.Replace('.', ' ').Replace('-', ' ').Replace('_', ' ').Trim();
}
@ -42,12 +51,5 @@ namespace NzbDrone.Core.Providers
int.TryParse(s, out i);
return i;
}
private static DateTime ParseAirDate(string s)
{
DateTime d;
if (DateTime.TryParse(ReplaceSeparatorChars(s).Replace(' ', '-'), out d)) return d;
return DateTime.MinValue;
}
}
}

@ -37,28 +37,29 @@ namespace NzbDrone.Core.Providers
string response = _http.DownloadString(request).Replace("\n", String.Empty);
_logger.DebugFormat("Queue Repsonse: [{0}]", response);
if (response == "ok") return true;
if (response == "ok")
return true;
return false;
}
public bool IsInQueue(string title)
{
string action = "mode=queue&output=xml";
const string action = "mode=queue&output=xml";
string request = GetSabRequest(action);
string response = _http.DownloadString(request);
XDocument xDoc = XDocument.Parse(response);
//If an Error Occurred, retuyrn)
if (xDoc.Descendants("error").Count() != 0) return false;
if (xDoc.Descendants("error").Count() != 0)
return false;
if (xDoc.Descendants("queue").Count() == 0) return false;
if (xDoc.Descendants("queue").Count() == 0)
return false;
//Get the Count of Items in Queue where 'filename' is Equal to goodName, if not zero, return true (isInQueue)))
if ((from s in xDoc.Descendants("slot")
where s.Element("filename").Value.Equals(title, StringComparison.InvariantCultureIgnoreCase)
select s).Count() != 0)
if ((xDoc.Descendants("slot").Where(s => s.Element("filename").Value.Equals(title, StringComparison.InvariantCultureIgnoreCase))).Count() != 0)
{
_logger.DebugFormat("Episode in queue - '{0}'", title);

@ -54,7 +54,8 @@ namespace NzbDrone.Core.Providers
private void AddShow(string path)
{
var searchResults = _tvDb.SearchSeries(new DirectoryInfo(path).Name);
if (searchResults.Count != 0 && !_sonioRepo.Exists<Series>(s => s.TvdbId == searchResults[0].Id.ToString())) AddShow(path, _tvDb.GetSeries(searchResults[0].Id, searchResults[0].Language));
if (searchResults.Count != 0 && !_sonioRepo.Exists<Series>(s => s.TvdbId == searchResults[0].Id.ToString()))
AddShow(path, _tvDb.GetSeries(searchResults[0].Id, searchResults[0].Language));
}
private void AddShow(string path, TvdbSeries series)

@ -8,12 +8,12 @@ namespace NzbDrone.Core.Providers
{
public class TvDbProvider : ITvDbProvider
{
private const string TvDbApiKey = "5D2D188E86E07F4F";
private const string TVDB_APIKEY = "5D2D188E86E07F4F";
private readonly TvdbHandler _handler;
public TvDbProvider()
{
_handler = new TvdbHandler(new XmlCacheProvider(Path.Combine(Main.AppPath, @"cache\tvdbcache.xml")), TvDbApiKey);
_handler = new TvdbHandler(new XmlCacheProvider(Path.Combine(Main.AppPath, @"cache\tvdbcache.xml")), TVDB_APIKEY);
}
#region ITvDbProvider Members

Loading…
Cancel
Save