Fixed REGEX for episode parsing so it would correctly parse shows with a year in the title.

Fixed a config saving issue in the SettingsController.
Added bindings in Central dispatch for SabProvider and HttpProvider
This commit is contained in:
markus101 2011-01-30 17:30:59 -08:00
parent ea77428b1c
commit c40f18e66f
8 changed files with 118 additions and 20 deletions

View File

@ -56,6 +56,8 @@ namespace NzbDrone.Core
_kernel.Bind<IEpisodeProvider>().To<EpisodeProvider>(); _kernel.Bind<IEpisodeProvider>().To<EpisodeProvider>();
_kernel.Bind<IDiskProvider>().To<DiskProvider>(); _kernel.Bind<IDiskProvider>().To<DiskProvider>();
_kernel.Bind<ITvDbProvider>().To<TvDbProvider>(); _kernel.Bind<ITvDbProvider>().To<TvDbProvider>();
_kernel.Bind<IDownloadProvider>().To<SabProvider>();
_kernel.Bind<IHttpProvider>().To<HttpProvider>();
_kernel.Bind<IHistoryProvider>().To<HistoryProvider>(); _kernel.Bind<IHistoryProvider>().To<HistoryProvider>();
_kernel.Bind<IConfigProvider>().To<ConfigProvider>().InSingletonScope(); _kernel.Bind<IConfigProvider>().To<ConfigProvider>().InSingletonScope();
_kernel.Bind<ISyncProvider>().To<SyncProvider>().InSingletonScope(); _kernel.Bind<ISyncProvider>().To<SyncProvider>().InSingletonScope();
@ -155,9 +157,9 @@ namespace NzbDrone.Core
{ {
//Setup the default providers in the Providers table //Setup the default providers in the Providers table
string nzbMatrixRss = "http://rss.nzbmatrix.com/rss.php?page=download&username=USERNAME&apikey=APIKEY&subcat=6&english=1"; string nzbMatrixRss = "http://rss.nzbmatrix.com/rss.php?page=download&username={USERNAME}&apikey={APIKEY}&subcat=6&english=1";
string nzbsOrgRss = "http://nzbs.org/rss.php?type=1&dl=1&num=100&i=UID&h=HASH"; string nzbsOrgRss = "http://nzbs.org/rss.php?type=1&dl=1&num=100&i={UID}&h={HASH}";
string nzbsrusRss = "http://www.nzbsrus.com/rssfeed.php?cat=91,75&i=UID&h=HASH"; string nzbsrusRss = "http://www.nzbsrus.com/rssfeed.php?cat=91,75&i={UID}&h={HASH}";
var nzbMatrixIndexer = new Indexer var nzbMatrixIndexer = new Indexer
{ {

View File

@ -173,8 +173,10 @@
<Compile Include="Providers\IndexerProvider.cs" /> <Compile Include="Providers\IndexerProvider.cs" />
<Compile Include="Providers\IRssSyncProvider.cs" /> <Compile Include="Providers\IRssSyncProvider.cs" />
<Compile Include="Providers\IRssProvider.cs" /> <Compile Include="Providers\IRssProvider.cs" />
<Compile Include="Providers\ITimerProvider.cs" />
<Compile Include="Providers\RssSyncProvider.cs" /> <Compile Include="Providers\RssSyncProvider.cs" />
<Compile Include="Providers\RssProvider.cs" /> <Compile Include="Providers\RssProvider.cs" />
<Compile Include="Providers\TimerProvider.cs" />
<Compile Include="Repository\EpisodeFile.cs" /> <Compile Include="Repository\EpisodeFile.cs" />
<Compile Include="Model\Notification\BasicNotification.cs" /> <Compile Include="Model\Notification\BasicNotification.cs" />
<Compile Include="Model\Notification\ProgressNotificationStatus.cs" /> <Compile Include="Model\Notification\ProgressNotificationStatus.cs" />

View File

@ -18,7 +18,7 @@ namespace NzbDrone.Core
private static readonly Regex[] ReportTitleRegex = new[] private static readonly Regex[] ReportTitleRegex = new[]
{ {
new Regex(@"(?<title>.+?)?\W(S)?(?<season>\d+)\w(?<episode>\d+)\W(?!\\)", RegexOptions.IgnoreCase | RegexOptions.Compiled) new Regex(@"(?<title>.+?)?\W(S)?(?<season>\d+)[EeXx](?<episode>\d+)\W(?!\\)", RegexOptions.IgnoreCase | RegexOptions.Compiled)
}; };
private static readonly Regex NormalizeRegex = new Regex(@"((\s|^)the(\s|$))|((\s|^)and(\s|$))|[^a-z]", RegexOptions.IgnoreCase | RegexOptions.Compiled); private static readonly Regex NormalizeRegex = new Regex(@"((\s|^)the(\s|$))|((\s|^)and(\s|$))|[^a-z]", RegexOptions.IgnoreCase | RegexOptions.Compiled);

View File

@ -5,6 +5,8 @@ using System.Text;
using System.Threading; using System.Threading;
using NLog; using NLog;
using NzbDrone.Core.Model; using NzbDrone.Core.Model;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality; using NzbDrone.Core.Repository.Quality;
using Rss; using Rss;
@ -22,11 +24,15 @@ namespace NzbDrone.Core.Providers
private IEpisodeProvider _episode; private IEpisodeProvider _episode;
private IHistoryProvider _history; private IHistoryProvider _history;
private IDownloadProvider _sab; private IDownloadProvider _sab;
private IConfigProvider _configProvider;
private readonly INotificationProvider _notificationProvider;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private ProgressNotification _rssSyncNotification;
public RssSyncProvider(IIndexerProvider indexerProvider, IRssProvider rss, ISeriesProvider series, public RssSyncProvider(IIndexerProvider indexerProvider, IRssProvider rss, ISeriesProvider series,
ISeasonProvider season, IEpisodeProvider episode, IHistoryProvider history, IDownloadProvider sab) ISeasonProvider season, IEpisodeProvider episode, IHistoryProvider history, IDownloadProvider sab, INotificationProvider notificationProvider, IConfigProvider configProvider)
{ {
_indexerProvider = indexerProvider; _indexerProvider = indexerProvider;
_rss = rss; _rss = rss;
@ -35,6 +41,8 @@ namespace NzbDrone.Core.Providers
_episode = episode; _episode = episode;
_history = history; _history = history;
_sab = sab; _sab = sab;
_notificationProvider = notificationProvider;
_configProvider = configProvider;
} }
#region IRssSyncProvider Members #region IRssSyncProvider Members
@ -69,22 +77,44 @@ namespace NzbDrone.Core.Providers
var indexers = _indexerProvider.EnabledIndexers(); var indexers = _indexerProvider.EnabledIndexers();
foreach (var i in indexers) using (_rssSyncNotification = new ProgressNotification("RSS Sync"))
{ {
var indexer = new FeedInfoModel(i.IndexerName, i.RssUrl); _notificationProvider.Register(_rssSyncNotification);
_rssSyncNotification.CurrentStatus = "Starting Scan";
_rssSyncNotification.ProgressMax = indexers.Count();
foreach(RssItem item in _rss.GetFeed(indexer)) foreach (var i in indexers)
{ {
NzbInfoModel nzb = Parser.ParseNzbInfo(indexer, item); Logger.Info("Starting RSS Sync for: {0}", i.IndexerName);
QueueIfWanted(nzb); //Need to insert the users information in the the URL before trying to use it
i.RssUrl = GetUsersUrl(i); //Get the new users specific url (with their information) to use for the Sync
if (i.RssUrl == null)
{
Logger.Debug("Unable to Sync {0}. User Information has not been configured.", i.IndexerName);
continue; //Skip this indexer
}
_rssSyncNotification.CurrentStatus = String.Format("Syncing with RSS Feed: {0}", i.IndexerName);
var indexer = new FeedInfoModel(i.IndexerName, i.RssUrl);
foreach (RssItem item in _rss.GetFeed(indexer))
{
NzbInfoModel nzb = Parser.ParseNzbInfo(indexer, item);
QueueIfWanted(nzb);
}
} }
_rssSyncNotification.CurrentStatus = "RSS Sync Completed";
Logger.Info("RSS Sync has successfully completed.");
Thread.Sleep(3000);
_rssSyncNotification.Status = ProgressNotificationStatus.Completed;
} }
} }
private void QueueIfWanted(NzbInfoModel nzb) private void QueueIfWanted(NzbInfoModel nzb)
{ {
//Do we want this item? //Do we want this item?
try try
{ {
if (nzb.IsPassworded()) if (nzb.IsPassworded())
@ -162,5 +192,46 @@ namespace NzbDrone.Core.Providers
return String.Format("{0} - {1}{2} - {3}", series.Title, seasonNumber, episodeNumbers, episodeTitles); return String.Format("{0} - {1}{2} - {3}", series.Title, seasonNumber, episodeNumbers, episodeTitles);
} }
private string GetUsersUrl(Indexer indexer)
{
if (indexer.IndexerName == "NzbMatrix")
{
var nzbMatrixUsername = _configProvider.GetValue("NzbMatrixUsername", String.Empty, false);
var nzbMatrixApiKey = _configProvider.GetValue("NzbMatrixApiKey", String.Empty, false);
if (!String.IsNullOrEmpty(nzbMatrixUsername) && !String.IsNullOrEmpty(nzbMatrixApiKey))
return indexer.RssUrl.Replace("{USERNAME}", nzbMatrixUsername).Replace("{APIKEY}", nzbMatrixApiKey);
//Todo: Perform validation at the config level so a user is unable to enable a provider until user details are provided
return null; //Return Null if Provider is enabled, but user information is not supplied.
}
if (indexer.IndexerName == "NzbsOrg")
{
var nzbsOrgUId = _configProvider.GetValue("NzbsOrgUId", String.Empty, false);
var nzbsOrgHash = _configProvider.GetValue("NzbsOrgHash", String.Empty, false);
if (!String.IsNullOrEmpty(nzbsOrgUId) && !String.IsNullOrEmpty(nzbsOrgHash))
return indexer.RssUrl.Replace("{UID}", nzbsOrgUId).Replace("{HASH}", nzbsOrgHash);
//Todo: Perform validation at the config level so a user is unable to enable a provider until user details are provided
return null; //Return Null if Provider is enabled, but user information is not supplied.
}
if (indexer.IndexerName == "NzbsOrg")
{
var nzbsrusUId = _configProvider.GetValue("NzbsrusUId", String.Empty, false);
var nzbsrusHash = _configProvider.GetValue("NzbsrusHash", String.Empty, false);
if (!String.IsNullOrEmpty(nzbsrusUId) && !String.IsNullOrEmpty(nzbsrusHash))
return indexer.RssUrl.Replace("{UID}", nzbsrusUId).Replace("{HASH}", nzbsrusHash);
//Todo: Perform validation at the config level so a user is unable to enable a provider until user details are provided
return null; //Return Null if Provider is enabled, but user information is not supplied.
}
return indexer.RssUrl; //Currently other providers do not require user information to be substituted, simply return the RssUrl
}
} }
} }

View File

@ -17,14 +17,16 @@ namespace NzbDrone.Web.Controllers
private readonly ISeriesProvider _seriesProvider; private readonly ISeriesProvider _seriesProvider;
private readonly IEpisodeProvider _episodeProvider; private readonly IEpisodeProvider _episodeProvider;
private readonly ISyncProvider _syncProvider; private readonly ISyncProvider _syncProvider;
private readonly IRssSyncProvider _rssSyncProvider;
// //
// GET: /Series/ // GET: /Series/
public SeriesController(ISyncProvider syncProvider, ISeriesProvider seriesProvider, IEpisodeProvider episodeProvider) public SeriesController(ISyncProvider syncProvider, ISeriesProvider seriesProvider, IEpisodeProvider episodeProvider, IRssSyncProvider rssSyncProvider)
{ {
_seriesProvider = seriesProvider; _seriesProvider = seriesProvider;
_episodeProvider = episodeProvider; _episodeProvider = episodeProvider;
_syncProvider = syncProvider; _syncProvider = syncProvider;
_rssSyncProvider = rssSyncProvider;
} }
public ActionResult Index() public ActionResult Index()
@ -40,6 +42,12 @@ namespace NzbDrone.Web.Controllers
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
public ActionResult RssSync()
{
_rssSyncProvider.Begin();
return RedirectToAction("Index");
}
public ActionResult UnMapped() public ActionResult UnMapped()
{ {

View File

@ -149,17 +149,31 @@ namespace NzbDrone.Web.Controllers
{ {
try try
{ {
//Todo: Only allow indexers to be enabled if user information has been provided
foreach (var indexer in data.Indexers) foreach (var indexer in data.Indexers)
{ {
indexer.ApiUrl = String.Empty; //TODO: Remove this and use a Real API URL
_indexerProvider.Update(indexer); _indexerProvider.Update(indexer);
} }
_configProvider.SetValue("NzbMatrixUsername", data.NzbMatrixUsername); if (data.NzbMatrixUsername != null)
_configProvider.SetValue("NzbMatrixApiKey", data.NzbMatrixApiKey); _configProvider.SetValue("NzbMatrixUsername", data.NzbMatrixUsername);
_configProvider.SetValue("NzbsOrgUId", data.NzbsOrgUId);
_configProvider.SetValue("NzbsOrgHash", data.NzbsOrgHash); if (data.NzbMatrixApiKey != null)
_configProvider.SetValue("NzbsrusUId", data.NzbsrusUId); _configProvider.SetValue("NzbMatrixApiKey", data.NzbMatrixApiKey);
_configProvider.SetValue("NzbsrusHash", data.NzbsrusHash);
if (data.NzbsOrgUId != null)
_configProvider.SetValue("NzbsOrgUId", data.NzbsOrgUId);
if (data.NzbsOrgHash != null)
_configProvider.SetValue("NzbsOrgHash", data.NzbsOrgHash);
if (data.NzbsrusUId != null)
_configProvider.SetValue("NzbsrusUId", data.NzbsrusUId);
if (data.NzbsrusHash != null)
_configProvider.SetValue("NzbsrusHash", data.NzbsrusHash);
} }
catch (Exception e) catch (Exception e)
{ {

View File

@ -112,7 +112,7 @@ namespace NzbDrone.Web.Models
} }
[DataType(DataType.Text)] [DataType(DataType.Text)]
[DisplayName("Retentions")] [DisplayName("Retention")]
public int Rentention public int Rentention
{ {
get; get;

View File

@ -9,6 +9,7 @@
<% <%
Html.Telerik().Menu().Name("telerikGrid").Items(items => { items.Add().Text("View Unmapped Folders").Action("Unmapped", "Series"); }) Html.Telerik().Menu().Name("telerikGrid").Items(items => { items.Add().Text("View Unmapped Folders").Action("Unmapped", "Series"); })
.Items(items => items.Add().Text("Sync With Disk").Action("Sync", "Series")) .Items(items => items.Add().Text("Sync With Disk").Action("Sync", "Series"))
.Items(items => items.Add().Text("Start RSS Sync").Action("RssSync", "Series"))
.Render(); .Render();
%> %>
</asp:Content> </asp:Content>