Prevent TvRage issues from breaking InfoUpdate
This commit is contained in:
parent
23019ebda6
commit
7fb8f05421
|
@ -14,7 +14,7 @@ namespace NzbDrone.Core.Providers
|
||||||
{
|
{
|
||||||
public class SeriesProvider
|
public class SeriesProvider
|
||||||
{
|
{
|
||||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
|
||||||
private readonly ConfigProvider _configProvider;
|
private readonly ConfigProvider _configProvider;
|
||||||
private readonly TvDbProvider _tvDbProvider;
|
private readonly TvDbProvider _tvDbProvider;
|
||||||
private readonly IDatabase _database;
|
private readonly IDatabase _database;
|
||||||
|
@ -22,6 +22,9 @@ namespace NzbDrone.Core.Providers
|
||||||
private readonly BannerProvider _bannerProvider;
|
private readonly BannerProvider _bannerProvider;
|
||||||
private readonly MetadataProvider _metadataProvider;
|
private readonly MetadataProvider _metadataProvider;
|
||||||
private readonly TvRageMappingProvider _tvRageMappingProvider;
|
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);
|
private static readonly Regex TimeRegex = new Regex(@"^(?<time>\d+:?\d*)\W*(?<meridiem>am|pm)?", RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
||||||
|
|
||||||
public SeriesProvider(IDatabase database, ConfigProvider configProviderProvider,
|
public SeriesProvider(IDatabase database, ConfigProvider configProviderProvider,
|
||||||
|
@ -107,8 +110,16 @@ namespace NzbDrone.Core.Providers
|
||||||
series.BannerUrl = tvDbSeries.BannerPath;
|
series.BannerUrl = tvDbSeries.BannerPath;
|
||||||
series.Network = tvDbSeries.Network;
|
series.Network = tvDbSeries.Network;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
if(series.TvRageId == 0)
|
if(series.TvRageId == 0)
|
||||||
series = _tvRageMappingProvider.FindMatchingTvRageSeries(series);
|
series = _tvRageMappingProvider.FindMatchingTvRageSeries(series);
|
||||||
|
}
|
||||||
|
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
logger.ErrorException("Error getting TvRage information for series: " + series.Title, ex);
|
||||||
|
}
|
||||||
|
|
||||||
UpdateSeries(series);
|
UpdateSeries(series);
|
||||||
_metadataProvider.CreateForSeries(series, tvDbSeries);
|
_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)
|
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)
|
if (tvDbSeriesId <=0)
|
||||||
{
|
{
|
||||||
|
@ -179,33 +190,33 @@ namespace NzbDrone.Core.Providers
|
||||||
public virtual void DeleteSeries(int seriesId)
|
public virtual void DeleteSeries(int seriesId)
|
||||||
{
|
{
|
||||||
var series = GetSeries(seriesId);
|
var series = GetSeries(seriesId);
|
||||||
Logger.Warn("Deleting Series [{0}]", series.Title);
|
logger.Warn("Deleting Series [{0}]", series.Title);
|
||||||
|
|
||||||
using (var tran = _database.GetTransaction())
|
using (var tran = _database.GetTransaction())
|
||||||
{
|
{
|
||||||
//Delete History, Files, Episodes, Seasons then the Series
|
//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);
|
_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);
|
_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);
|
_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);
|
_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);
|
_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();
|
tran.Complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.Trace("Beginning deletion of banner for SeriesID: ", seriesId);
|
logger.Trace("Beginning deletion of banner for SeriesID: ", seriesId);
|
||||||
_bannerProvider.Delete(seriesId);
|
_bannerProvider.Delete(seriesId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue