mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-10-30 07:22:35 +01:00
Add to History when SAB receives the NZB and set episode.status to grabbed.
This commit is contained in:
parent
88ad555e75
commit
c448c17605
14
NzbDrone.Core/Model/EpisodeStatusType.cs
Normal file
14
NzbDrone.Core/Model/EpisodeStatusType.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace NzbDrone.Core.Model
|
||||
{
|
||||
public enum EpisodeStatusType
|
||||
{
|
||||
Missing = 0,
|
||||
Grabbed = 1,
|
||||
Downloaded = 2
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Repository.Quality;
|
||||
|
||||
namespace NzbDrone.Core.Model
|
||||
{
|
||||
@ -15,6 +16,7 @@ namespace NzbDrone.Core.Model
|
||||
public Uri Link { get; set; }
|
||||
public string Description { get; set; }
|
||||
public bool Proper { get; set; }
|
||||
public QualityTypes Quality { get; set; }
|
||||
|
||||
public bool IsPassworded()
|
||||
{
|
||||
|
@ -103,7 +103,7 @@ namespace NzbDrone.Core.Providers
|
||||
foreach (RssItem item in _rss.GetFeed(indexer))
|
||||
{
|
||||
NzbInfoModel nzb = Parser.ParseNzbInfo(indexer, item);
|
||||
QueueIfWanted(nzb);
|
||||
QueueIfWanted(nzb, i);
|
||||
}
|
||||
}
|
||||
_rssSyncNotification.CurrentStatus = "RSS Sync Completed";
|
||||
@ -113,7 +113,7 @@ namespace NzbDrone.Core.Providers
|
||||
}
|
||||
}
|
||||
|
||||
private void QueueIfWanted(NzbInfoModel nzb)
|
||||
private void QueueIfWanted(NzbInfoModel nzb, Indexer indexer)
|
||||
{
|
||||
//Do we want this item?
|
||||
try
|
||||
@ -145,6 +145,7 @@ namespace NzbDrone.Core.Providers
|
||||
|
||||
nzb.TitleFix = GetTitleFix(episodeParseResults, series.SeriesId); //Get the TitleFix so we can use it later
|
||||
nzb.Proper = Parser.ParseProper(nzb.Title);
|
||||
nzb.Quality = Parser.ParseQuality(nzb.Title);
|
||||
|
||||
//Loop through the list of the episodeParseResults to ensure that all the episodes are needed)
|
||||
foreach (var episode in episodeParseResults)
|
||||
@ -154,7 +155,7 @@ namespace NzbDrone.Core.Providers
|
||||
episodeModel.Proper = nzb.Proper;
|
||||
episodeModel.SeriesId = series.SeriesId;
|
||||
episodeModel.SeriesTitle = series.Title;
|
||||
episodeModel.Quality = Parser.ParseQuality(nzb.Title);
|
||||
episodeModel.Quality = nzb.Quality;
|
||||
episodeModel.SeasonNumber = episode.SeasonNumber;
|
||||
episodeModel.EpisodeNumber = episode.EpisodeNumber;
|
||||
|
||||
@ -174,7 +175,34 @@ namespace NzbDrone.Core.Providers
|
||||
return;
|
||||
}
|
||||
|
||||
var sabResult = _sab.AddByUrl(nzb.Link.ToString(), nzb.TitleFix);
|
||||
//Only add to history if it was added to properly sent to SABnzbd
|
||||
if (_sab.AddByUrl(nzb.Link.ToString(), nzb.TitleFix))
|
||||
{
|
||||
//We need to loop through the episodeParseResults so each episode in the NZB is properly handled
|
||||
foreach (var epr in episodeParseResults)
|
||||
{
|
||||
var episode = _episode.GetEpisode(series.SeriesId, epr.SeasonNumber, epr.EpisodeNumber);
|
||||
|
||||
if (episode == null)
|
||||
{
|
||||
//Not sure how we got this far, so lets throw an exception
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
//Set episode status to grabbed
|
||||
episode.Status = EpisodeStatusType.Grabbed;
|
||||
|
||||
//Add to History
|
||||
var history = new History();
|
||||
history.Date = DateTime.Now;
|
||||
history.EpisodeId = episode.EpisodeId;
|
||||
history.IndexerName = indexer.IndexerName;
|
||||
history.IsProper = nzb.Proper;
|
||||
history.Quality = nzb.Quality;
|
||||
|
||||
_history.Insert(history);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Web.Script.Serialization;
|
||||
using NzbDrone.Core.Model;
|
||||
using SubSonic.SqlGeneration.Schema;
|
||||
|
||||
namespace NzbDrone.Core.Repository
|
||||
@ -18,6 +19,7 @@ namespace NzbDrone.Core.Repository
|
||||
[SubSonicLongString]
|
||||
public string Overview { get; set; }
|
||||
public string Language { get; set; }
|
||||
public EpisodeStatusType Status { get; set; }
|
||||
|
||||
[SubSonicToOneRelation(ThisClassContainsJoinKey = true)]
|
||||
public virtual Season Season { get; set; }
|
||||
|
@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using NzbDrone.Core.Repository.Quality;
|
||||
using SubSonic.SqlGeneration.Schema;
|
||||
|
||||
namespace NzbDrone.Core.Repository
|
||||
@ -11,14 +12,14 @@ namespace NzbDrone.Core.Repository
|
||||
public int HistoryId { get; set; }
|
||||
public virtual int EpisodeId { get; set; }
|
||||
public virtual string IndexerName { get; set; }
|
||||
public int Quality { get; set; }
|
||||
public QualityTypes Quality { get; set; }
|
||||
public DateTime Date { get; set; }
|
||||
public bool IsProper { get; set; }
|
||||
|
||||
[SubSonicToOneRelation(ThisClassContainsJoinKey = true)]
|
||||
public virtual Episode Episode { get; set; }
|
||||
public virtual Episode Episode { get; private set; }
|
||||
|
||||
[SubSonicToOneRelation(ThisClassContainsJoinKey = true)]
|
||||
public virtual Indexer Indexer { get; set; }
|
||||
public virtual Indexer Indexer { get; private set; }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user