Prevent TvRage issues from breaking InfoUpdate

This commit is contained in:
Mark McDowall 2012-12-19 22:17:18 -08:00
parent 23019ebda6
commit 7fb8f05421
1 changed files with 23 additions and 12 deletions

View File

@ -14,7 +14,7 @@ namespace NzbDrone.Core.Providers
{
public class SeriesProvider
{
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly ConfigProvider _configProvider;
private readonly TvDbProvider _tvDbProvider;
private readonly IDatabase _database;
@ -22,6 +22,9 @@ namespace NzbDrone.Core.Providers
private readonly BannerProvider _bannerProvider;
private readonly MetadataProvider _metadataProvider;
private readonly TvRageMappingProvider _tvRageMappingProvider;
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
private static readonly Regex TimeRegex = new Regex(@"^(?<time>\d+:?\d*)\W*(?<meridiem>am|pm)?", RegexOptions.IgnoreCase | RegexOptions.Compiled);
public SeriesProvider(IDatabase database, ConfigProvider configProviderProvider,
@ -107,8 +110,16 @@ namespace NzbDrone.Core.Providers
series.BannerUrl = tvDbSeries.BannerPath;
series.Network = tvDbSeries.Network;
if (series.TvRageId == 0)
series = _tvRageMappingProvider.FindMatchingTvRageSeries(series);
try
{
if(series.TvRageId == 0)
series = _tvRageMappingProvider.FindMatchingTvRageSeries(series);
}
catch(Exception ex)
{
logger.ErrorException("Error getting TvRage information for series: " + series.Title, ex);
}
UpdateSeries(series);
_metadataProvider.CreateForSeries(series, tvDbSeries);
@ -118,7 +129,7 @@ namespace NzbDrone.Core.Providers
public virtual void AddSeries(string title, string path, int tvDbSeriesId, int qualityProfileId, DateTime? airedAfter)
{
Logger.Info("Adding Series [{0}] Path: [{1}]", tvDbSeriesId, path);
logger.Info("Adding Series [{0}] Path: [{1}]", tvDbSeriesId, path);
if (tvDbSeriesId <=0)
{
@ -179,33 +190,33 @@ namespace NzbDrone.Core.Providers
public virtual void DeleteSeries(int seriesId)
{
var series = GetSeries(seriesId);
Logger.Warn("Deleting Series [{0}]", series.Title);
logger.Warn("Deleting Series [{0}]", series.Title);
using (var tran = _database.GetTransaction())
{
//Delete History, Files, Episodes, Seasons then the Series
Logger.Debug("Deleting History Items from DB for Series: {0}", series.Title);
logger.Debug("Deleting History Items from DB for Series: {0}", series.Title);
_database.Delete<History>("WHERE SeriesId=@0", seriesId);
Logger.Debug("Deleting EpisodeFiles from DB for Series: {0}", series.Title);
logger.Debug("Deleting EpisodeFiles from DB for Series: {0}", series.Title);
_database.Delete<EpisodeFile>("WHERE SeriesId=@0", seriesId);
Logger.Debug("Deleting Seasons from DB for Series: {0}", series.Title);
logger.Debug("Deleting Seasons from DB for Series: {0}", series.Title);
_database.Delete<Season>("WHERE SeriesId=@0", seriesId);
Logger.Debug("Deleting Episodes from DB for Series: {0}", series.Title);
logger.Debug("Deleting Episodes from DB for Series: {0}", series.Title);
_database.Delete<Episode>("WHERE SeriesId=@0", seriesId);
Logger.Debug("Deleting Series from DB {0}", series.Title);
logger.Debug("Deleting Series from DB {0}", series.Title);
_database.Delete<Series>("WHERE SeriesId=@0", seriesId);
Logger.Info("Successfully deleted Series [{0}]", series.Title);
logger.Info("Successfully deleted Series [{0}]", series.Title);
tran.Complete();
}
Logger.Trace("Beginning deletion of banner for SeriesID: ", seriesId);
logger.Trace("Beginning deletion of banner for SeriesID: ", seriesId);
_bannerProvider.Delete(seriesId);
}