Resharper code cleanup

pull/3113/head
Keivan 14 years ago
parent c7286863b0
commit d00744aafa

@ -11,7 +11,6 @@ namespace NzbDrone.Core
{
public static class Main
{
public static void BindKernel(IKernel kernel)
{
string connectionString = String.Format("Data Source={0};Version=3;", Path.Combine(AppPath, "nzbdrone.db"));
@ -30,4 +29,4 @@ namespace NzbDrone.Core
get { return new DirectoryInfo(HttpContext.Current.Server.MapPath("\\")).Parent.FullName; }
}
}
}
}

@ -11,7 +11,6 @@ namespace NzbDrone.Core.Providers
private readonly ILog _logger;
private readonly IRepository _sonicRepo;
public ConfigProvider(ILog logger, IRepository dataRepository)
{
_logger = logger;
@ -19,7 +18,6 @@ namespace NzbDrone.Core.Providers
_sonicRepo = dataRepository;
}
private string GetValue(string key)
{
return GetValue(key, String.Empty, false);
@ -27,39 +25,23 @@ namespace NzbDrone.Core.Providers
public String SeriesRoot
{
get
{
return GetValue(SERIES_ROOTS);
}
set
{
SetValue(SERIES_ROOTS, value);
}
get { return GetValue(SERIES_ROOTS); }
set { SetValue(SERIES_ROOTS, value); }
}
public string GetValue(string key, object defaultValue, bool makePermanent)
{
string value;
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;
}
@ -72,10 +54,7 @@ namespace NzbDrone.Core.Providers
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;

@ -6,9 +6,7 @@ namespace NzbDrone.Core.Providers
{
public class EpisodeProvider
{
private static 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,24 +21,13 @@ namespace NzbDrone.Core.Providers
| (?<episodeName>.*)
)", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.IgnorePatternWhitespace);
public static Episode Parse(string 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)
@ -59,10 +46,8 @@ namespace NzbDrone.Core.Providers
private static DateTime ParseAirDate(string s)
{
DateTime d;
if (DateTime.TryParse(ReplaceSeparatorChars(s).Replace(' ', '-'), out d))
return d;
if (DateTime.TryParse(ReplaceSeparatorChars(s).Replace(' ', '-'), out d)) return d;
return DateTime.MinValue;
}
}
}

@ -1,13 +1,12 @@
using System;
using System.Net;
using System.Net;
namespace NzbDrone.Core.Providers
{
class HttpProvider : IHttpProvider
internal class HttpProvider : IHttpProvider
{
public string DownloadString(string request)
{
return new WebClient().DownloadString(request);
}
}
}
}

@ -1,10 +1,8 @@
using NzbDrone.Core.Repository;
namespace NzbDrone.Core.Providers
namespace NzbDrone.Core.Providers
{
public interface IDownloadProvider
{
bool AddByUrl(string url, string title); //Should accept something other than string (NzbInfo?) returns success or failure
bool IsInQueue(string title);//Should accept something other than string (Episode?) returns bool
bool IsInQueue(string title); //Should accept something other than string (Episode?) returns bool
}
}
}

@ -4,4 +4,4 @@
{
string DownloadString(string request);
}
}
}

@ -1,9 +1,8 @@
using System;
using System.Linq;
using System.Web;
using log4net;
using System.Xml.Linq;
using NzbDrone.Core.Repository;
using log4net;
namespace NzbDrone.Core.Providers
{
@ -38,8 +37,7 @@ 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;
}
@ -53,14 +51,14 @@ namespace NzbDrone.Core.Providers
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 ((from s in xDoc.Descendants("slot")
where s.Element("filename").Value.Equals(title, StringComparison.InvariantCultureIgnoreCase)
select s).Count() != 0)
{
_logger.DebugFormat("Episode in queue - '{0}'", title);
@ -79,9 +77,7 @@ namespace NzbDrone.Core.Providers
string password = _config.GetValue("Password", String.Empty, false);
string apiKey = _config.GetValue("ApiKey", String.Empty, false);
return string.Format(
@"http://{0}/sabnzbd/api?$Action&apikey={1}&ma_username={2}&ma_password={3}",
sabnzbdInfo, apiKey, username, password).Replace("$Action", action);
return string.Format(@"http://{0}/sabnzbd/api?$Action&apikey={1}&ma_username={2}&ma_password={3}", sabnzbdInfo, apiKey, username, password).Replace("$Action", action);
}
}
}
}

@ -36,11 +36,8 @@ namespace NzbDrone.Core.Providers
return _sonioRepo.Single<Series>(s => s.TvdbId == tvdbId.ToString());
}
public void SyncSeriesWithDisk()
{
foreach (string seriesFolder in _diskProvider.GetDirectories(_config.SeriesRoot))
{
var cleanPath = DiskProvider.CleanPath(new DirectoryInfo(seriesFolder).FullName);
@ -50,7 +47,6 @@ namespace NzbDrone.Core.Providers
AddShow(cleanPath);
}
}
}
#endregion
@ -58,10 +54,7 @@ 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,6 +8,7 @@ namespace NzbDrone.Core.Repository
{
[SubSonicPrimaryKey]
public string EpisodeId { get; set; }
public string SeriesId { get; set; }
public string Title { get; set; }
public string Title2 { get; set; }
@ -19,6 +20,6 @@ namespace NzbDrone.Core.Repository
public int Quality { get; set; }
public bool Proper { get; set; }
public String FileName { get; set; }
public SyndicationItem Feed { get; set; }
public SyndicationItem Feed { get; set; }
}
}
}

@ -2,34 +2,33 @@ namespace NzbDrone.Core.Repository
{
// ReSharper disable InconsistentNaming
/// <summary>
/// Represents Video Quality
/// Represents Video Quality
/// </summary>
public enum Quality
{
/// <summary>
/// Quality is unknown
/// Quality is unknown
/// </summary>
Unknown = 0,
/// <summary>
/// SD File (Source could be HD)
/// SD File (Source could be HD)
/// </summary>
SDTV = 1,
/// <summary>
/// SD File (DVD Source)
/// SD File (DVD Source)
/// </summary>
DVD = 2,
/// <summary>
/// HD File (HDTV Source)
/// HD File (HDTV Source)
/// </summary>
HDTV = 3,
/// <summary>
/// HD File (Online Source)
/// HD File (Online Source)
/// </summary>
WEBDL = 4,
/// <summary>
/// HD File (Blu-ray Source)
/// HD File (Blu-ray Source)
/// </summary>
Bluray = 5
}
}

@ -6,54 +6,21 @@ namespace NzbDrone.Core.Repository
public class Series
{
[SubSonicPrimaryKey]
public string TvdbId
{
get;
set;
}
public string SeriesName
{
get;
set;
}
public string Status
{
get;
set;
}
public string TvdbId { get; set; }
public string SeriesName { get; set; }
public string Status { get; set; }
[SubSonicLongString]
public string Overview
{
get;
set;
}
public DayOfWeek? AirsDayOfWeek
{
get;
set;
}
public String AirTimes
{
get;
set;
}
public string Language
{
get;
set;
}
public string Path
{
get;
set;
}
public string Overview { get; set; }
public DayOfWeek? AirsDayOfWeek { get; set; }
public String AirTimes { get; set; }
public string Language { get; set; }
public string Path { get; set; }
}
}
}
Loading…
Cancel
Save