Merge branch 'master' into searching

This commit is contained in:
Mark McDowall 2012-11-21 08:16:22 -08:00
commit d073a0b2fb
15 changed files with 45 additions and 13 deletions

View File

@ -596,7 +596,6 @@ namespace NzbDrone.Core.Test
WithConfiguredIndexers(); WithConfiguredIndexers();
const string fileName = "wombles.xml"; const string fileName = "wombles.xml";
const string expectedString = "nzbdetails";
Mocker.GetMock<HttpProvider>() Mocker.GetMock<HttpProvider>()
.Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>())) .Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
@ -635,7 +634,6 @@ namespace NzbDrone.Core.Test
{ {
WithConfiguredIndexers(); WithConfiguredIndexers();
const string fileName = "nzbindex.xml";
const string expectedString = "release"; const string expectedString = "release";
Mocker.GetMock<HttpProvider>() Mocker.GetMock<HttpProvider>()

View File

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using System.Text; using System.Text;
@ -67,6 +68,15 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests
ExceptionVerification.ExpectedWarns(1); ExceptionVerification.ExpectedWarns(1);
} }
[Test]
public void should_replace_illegal_characters_in_title()
{
var illegalTitle = "Saturday Night Live - S38E08 - Jeremy Renner/Maroon 5 [SDTV]";
var expectedFilename = Path.Combine(blackHoleFolder, "Saturday Night Live - S38E08 - Jeremy Renner+Maroon 5 [SDTV].nzb");
Mocker.Resolve<BlackholeProvider>().DownloadNzb(nzbUrl, illegalTitle).Should().BeTrue();
Mocker.GetMock<HttpProvider>().Verify(c => c.DownloadFile(It.IsAny<string>(), expectedFilename), Times.Once());
}
} }
} }

View File

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using System.Text; using System.Text;
@ -75,5 +76,16 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests
{ {
Mocker.Resolve<PneumaticProvider>().DownloadNzb(nzbUrl, "30 Rock - Season 1").Should().BeFalse(); Mocker.Resolve<PneumaticProvider>().DownloadNzb(nzbUrl, "30 Rock - Season 1").Should().BeFalse();
} }
[Test]
public void should_replace_illegal_characters_in_title()
{
var illegalTitle = "Saturday Night Live - S38E08 - Jeremy Renner/Maroon 5 [SDTV]";
var expectedFilename = Path.Combine(pneumaticFolder, "Saturday Night Live - S38E08 - Jeremy Renner+Maroon 5 [SDTV].nzb");
Mocker.Resolve<PneumaticProvider>().DownloadNzb(nzbUrl, illegalTitle).Should().BeTrue();
Mocker.GetMock<HttpProvider>().Verify(c => c.DownloadFile(It.IsAny<string>(), expectedFilename), Times.Once());
}
} }
} }

View File

@ -220,8 +220,7 @@ namespace NzbDrone.Core
} }
parsedEpisode = new EpisodeParseResult parsedEpisode = new EpisodeParseResult
{ {
AirDate = new DateTime(airyear, airmonth, airday).Date, AirDate = new DateTime(airyear, airmonth, airday).Date,
}; };
} }

View File

@ -206,6 +206,7 @@ namespace NzbDrone.Core.Providers
catch (UnauthorizedAccessException ex) catch (UnauthorizedAccessException ex)
{ {
Logger.Debug("Unable to apply folder permissions to: ", newFile.FullName); Logger.Debug("Unable to apply folder permissions to: ", newFile.FullName);
Logger.TraceException(ex.Message, ex);
} }
episodeFile.Path = newFile.FullName; episodeFile.Path = newFile.FullName;

View File

@ -38,6 +38,8 @@ namespace NzbDrone.Core.Providers.DownloadClients
{ {
try try
{ {
title = MediaFileProvider.CleanFilename(title);
var filename = Path.Combine(_configProvider.BlackholeDirectory, title + ".nzb"); var filename = Path.Combine(_configProvider.BlackholeDirectory, title + ".nzb");
if (_diskProvider.FileExists(filename)) if (_diskProvider.FileExists(filename))
@ -64,7 +66,5 @@ namespace NzbDrone.Core.Providers.DownloadClients
{ {
return !_upgradeHistorySpecification.IsSatisfiedBy(newParseResult); return !_upgradeHistorySpecification.IsSatisfiedBy(newParseResult);
} }
} }
} }

View File

@ -44,6 +44,8 @@ namespace NzbDrone.Core.Providers.DownloadClients
return false; return false;
} }
title = MediaFileProvider.CleanFilename(title);
//Save to the Pneumatic directory (The user will need to ensure its accessible by XBMC) //Save to the Pneumatic directory (The user will need to ensure its accessible by XBMC)
var filename = Path.Combine(_configProvider.PneumaticDirectory, title + ".nzb"); var filename = Path.Combine(_configProvider.PneumaticDirectory, title + ".nzb");

View File

@ -140,6 +140,7 @@ namespace NzbDrone.Core.Providers
catch (Exception ex) catch (Exception ex)
{ {
Logger.Error("Invalid address {0}, please correct the site URL.", url); Logger.Error("Invalid address {0}, please correct the site URL.", url);
Logger.TraceException(ex.Message, ex);
throw; throw;
} }

View File

@ -28,11 +28,10 @@ namespace NzbDrone.Core.Providers
EpisodeStatus = episodeStatus.ToString(), EpisodeStatus = episodeStatus.ToString(),
Quality = (quality == null ? String.Empty : quality.Quality.ToString()) Quality = (quality == null ? String.Empty : quality.Quality.ToString())
}); });
var test = 0;
} }
catch (Exception ex) catch (Exception ex)
{ {
logger.Trace("Error"); logger.TraceException("Error", ex);
throw; throw;
} }
} }

View File

@ -61,6 +61,7 @@ namespace NzbDrone.Core.Providers
catch(Exception ex) catch(Exception ex)
{ {
Logger.Error("Error sending email. Subject: {0}", email.Subject); Logger.Error("Error sending email. Subject: {0}", email.Subject);
Logger.TraceException(ex.Message, ex);
} }
} }

View File

@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Web; using System.Web;
using NLog;
using NzbDrone.Services.Service.Repository; using NzbDrone.Services.Service.Repository;
using Services.PetaPoco; using Services.PetaPoco;
@ -11,6 +12,8 @@ namespace NzbDrone.Services.Service.Providers
{ {
private readonly IDatabase _database; private readonly IDatabase _database;
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
public SceneMappingProvider(IDatabase database) public SceneMappingProvider(IDatabase database)
{ {
_database = database; _database = database;
@ -74,6 +77,7 @@ namespace NzbDrone.Services.Service.Providers
} }
catch (Exception ex) catch (Exception ex)
{ {
logger.WarnException("Unable to promote scene mapping", ex);
return false; return false;
} }
@ -93,6 +97,7 @@ namespace NzbDrone.Services.Service.Providers
} }
catch (Exception ex) catch (Exception ex)
{ {
logger.WarnException("Unable to promote all scene mappings", ex);
return false; return false;
} }

View File

@ -80,11 +80,11 @@
<Name>NzbDrone.Common</Name> <Name>NzbDrone.Common</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\NzbDrone.Test.Common\NzbDrone.Test.Common.csproj"> <ProjectReference Include="..\NzbDrone.Test.Common\NzbDrone.Test.Common.csproj">
<Project>{CADDFCE0-7509-4430-8364-2074E1EEFCA2}</Project> <Project>{caddfce0-7509-4430-8364-2074e1eefca2}</Project>
<Name>NzbDrone.Test.Common</Name> <Name>NzbDrone.Test.Common</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\NzbDrone.Update\NzbDrone.Update.csproj"> <ProjectReference Include="..\NzbDrone.Update\NzbDrone.Update.csproj">
<Project>{4CCC53CD-8D5E-4CC4-97D2-5C9312AC2BD7}</Project> <Project>{4ccc53cd-8d5e-4cc4-97d2-5c9312ac2bd7}</Project>
<Name>NzbDrone.Update</Name> <Name>NzbDrone.Update</Name>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>

View File

@ -1,4 +1,5 @@
using System.Web.Mvc; using System.Web.Mvc;
using NLog;
using NzbDrone.Core.Jobs; using NzbDrone.Core.Jobs;
using NzbDrone.Core.Providers; using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.DownloadClients; using NzbDrone.Core.Providers.DownloadClients;
@ -21,6 +22,8 @@ namespace NzbDrone.Web.Controllers
private readonly XbmcProvider _xbmcProvider; private readonly XbmcProvider _xbmcProvider;
private readonly PlexProvider _plexProvider; private readonly PlexProvider _plexProvider;
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
public CommandController(JobProvider jobProvider, SabProvider sabProvider, public CommandController(JobProvider jobProvider, SabProvider sabProvider,
SmtpProvider smtpProvider, TwitterProvider twitterProvider, SmtpProvider smtpProvider, TwitterProvider twitterProvider,
EpisodeProvider episodeProvider, GrowlProvider growlProvider, EpisodeProvider episodeProvider, GrowlProvider growlProvider,
@ -133,6 +136,7 @@ namespace NzbDrone.Web.Controllers
} }
catch(Exception ex) catch(Exception ex)
{ {
logger.TraceException(ex.Message, ex);
return JsonNotificationResult.Oops("Couldn't register and test Growl"); return JsonNotificationResult.Oops("Couldn't register and test Growl");
} }
} }

View File

@ -53,7 +53,7 @@ namespace NzbDrone.Web.Controllers
Success = s.Success, Success = s.Success,
SearchError = s.SearchError.AddSpacesToEnum().Replace("None", "Grabbed"), SearchError = s.SearchError.AddSpacesToEnum().Replace("None", "Grabbed"),
Quality = s.Quality.ToString(), Quality = s.Quality.ToString(),
QualityInt = (int)s.Quality, QualityInt = s.Quality.Weight,
Proper = s.Proper, Proper = s.Proper,
Age = s.Age, Age = s.Age,
Size = s.Size.ToBestFileSize(1), Size = s.Size.ToBestFileSize(1),
@ -68,7 +68,7 @@ namespace NzbDrone.Web.Controllers
{ {
_searchHistoryProvider.ForceDownload(id); _searchHistoryProvider.ForceDownload(id);
return new JsonResult { Data = "ok", JsonRequestBehavior = JsonRequestBehavior.AllowGet }; return JsonNotificationResult.Info("Success", "Requested episode has been sent to download client");
} }
public string GetDisplayName(SearchHistory searchResult) public string GetDisplayName(SearchHistory searchResult)

View File

@ -38,7 +38,7 @@
function actionColumn(source, type, val) { function actionColumn(source, type, val) {
if (type === 'display' || type === 'filter') { if (type === 'display' || type === 'filter') {
return '<a href="/SearchHistory/ForceDownload/' + source["Id"] + '" data-ajax="true" data-ajax-confirm="Are you sure?"><i class="icon-plus gridAction"></i></a>'; return '<a href="/SearchHistory/ForceDownload?id=' + source["Id"] + '" data-ajax="true" data-ajax-confirm="Are you sure?"><i class="icon-plus gridAction"></i></a>';
} }
// 'sort' and 'type' both just use the raw data // 'sort' and 'type' both just use the raw data
return ''; return '';