mirror of
https://github.com/Sonarr/Sonarr
synced 2025-03-03 18:26:42 +00:00
Tweaks to XML and thumbs #ND-21
This commit is contained in:
parent
b122f1135e
commit
2e9cf66b57
3 changed files with 70 additions and 9 deletions
|
@ -75,6 +75,34 @@ namespace NzbDrone.Core.Test.ProviderTests.Metadata
|
||||||
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.MetadataUseBanners).Returns(true);
|
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.MetadataUseBanners).Returns(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void WithSpecials()
|
||||||
|
{
|
||||||
|
var seasonBanners = Builder<TvdbSeasonBanner>
|
||||||
|
.CreateListOfSize(2)
|
||||||
|
.All()
|
||||||
|
.With(b => b.Season = 0)
|
||||||
|
.TheFirst(1)
|
||||||
|
.With(b => b.BannerType = TvdbSeasonBanner.Type.season)
|
||||||
|
.With(b => b.BannerPath = "seasons/79488-0-1.jpg")
|
||||||
|
.TheLast(1)
|
||||||
|
.With(b => b.BannerType = TvdbSeasonBanner.Type.seasonwide)
|
||||||
|
.With(b => b.BannerPath = "banners/seasons/79488-0-1.jpg")
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
var seriesActors = Builder<TvdbActor>
|
||||||
|
.CreateListOfSize(5)
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
tvdbSeries = Builder<TvdbSeries>
|
||||||
|
.CreateNew()
|
||||||
|
.With(s => s.Id = 79488)
|
||||||
|
.With(s => s.SeriesName = "30 Rock")
|
||||||
|
.With(s => s.TvdbActors = seriesActors.ToList())
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
tvdbSeries.Banners.AddRange(seasonBanners);
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_not_blowup()
|
public void should_not_blowup()
|
||||||
{
|
{
|
||||||
|
@ -124,5 +152,14 @@ namespace NzbDrone.Core.Test.ProviderTests.Metadata
|
||||||
Mocker.Resolve<Xbmc>().CreateForSeries(series, tvdbSeries);
|
Mocker.Resolve<Xbmc>().CreateForSeries(series, tvdbSeries);
|
||||||
Mocker.GetMock<BannerProvider>().Verify(v => v.Download(It.Is<string>(s => s.Contains("banners")), It.IsRegex(@"season\d{2}\.tbn")), Times.Exactly(2));
|
Mocker.GetMock<BannerProvider>().Verify(v => v.Download(It.Is<string>(s => s.Contains("banners")), It.IsRegex(@"season\d{2}\.tbn")), Times.Exactly(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_download_special_thumb_with_proper_name()
|
||||||
|
{
|
||||||
|
WithUseBanners();
|
||||||
|
WithSpecials();
|
||||||
|
Mocker.Resolve<Xbmc>().CreateForSeries(series, tvdbSeries);
|
||||||
|
Mocker.GetMock<BannerProvider>().Verify(v => v.Download(It.Is<string>(s => s.Contains("banners")), It.IsRegex(@"season-specials.tbn")), Times.Exactly(1));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -13,6 +13,7 @@ using NzbDrone.Core.Providers;
|
||||||
using NzbDrone.Core.Providers.Core;
|
using NzbDrone.Core.Providers.Core;
|
||||||
using NzbDrone.Core.Providers.ExternalNotification;
|
using NzbDrone.Core.Providers.ExternalNotification;
|
||||||
using NzbDrone.Core.Providers.Indexer;
|
using NzbDrone.Core.Providers.Indexer;
|
||||||
|
using NzbDrone.Core.Providers.Metadata;
|
||||||
using NzbDrone.Core.Repository;
|
using NzbDrone.Core.Repository;
|
||||||
using PetaPoco;
|
using PetaPoco;
|
||||||
using SignalR;
|
using SignalR;
|
||||||
|
@ -20,6 +21,7 @@ using SignalR.Hosting.AspNet;
|
||||||
using SignalR.Infrastructure;
|
using SignalR.Infrastructure;
|
||||||
using SignalR.Ninject;
|
using SignalR.Ninject;
|
||||||
using Connection = NzbDrone.Core.Datastore.Connection;
|
using Connection = NzbDrone.Core.Datastore.Connection;
|
||||||
|
using Xbmc = NzbDrone.Core.Providers.ExternalNotification.Xbmc;
|
||||||
|
|
||||||
namespace NzbDrone.Core
|
namespace NzbDrone.Core
|
||||||
{
|
{
|
||||||
|
@ -45,8 +47,9 @@ namespace NzbDrone.Core
|
||||||
|
|
||||||
InitQuality();
|
InitQuality();
|
||||||
InitExternalNotifications();
|
InitExternalNotifications();
|
||||||
|
InitMetadataProviders();
|
||||||
InitIndexers();
|
InitIndexers();
|
||||||
InitJobs();
|
InitJobs();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitDatabase()
|
private void InitDatabase()
|
||||||
|
@ -160,6 +163,16 @@ namespace NzbDrone.Core
|
||||||
Kernel.Get<ExternalNotificationProvider>().InitializeNotifiers(notifiers.ToList());
|
Kernel.Get<ExternalNotificationProvider>().InitializeNotifiers(notifiers.ToList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void InitMetadataProviders()
|
||||||
|
{
|
||||||
|
logger.Debug("Initializing Metadata Providers...");
|
||||||
|
|
||||||
|
Kernel.Bind<MetadataBase>().To<Providers.Metadata.Xbmc>().InSingletonScope();
|
||||||
|
|
||||||
|
var providers = Kernel.GetAll<MetadataBase>();
|
||||||
|
Kernel.Get<MetadataProvider>().Initialize(providers.ToList());
|
||||||
|
}
|
||||||
|
|
||||||
public void DedicateToHost()
|
public void DedicateToHost()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
|
@ -36,7 +36,7 @@ namespace NzbDrone.Core.Providers.Metadata
|
||||||
_logger.Debug("Generating tvshow.nfo for: {0}", series.Title);
|
_logger.Debug("Generating tvshow.nfo for: {0}", series.Title);
|
||||||
var sb = new StringBuilder();
|
var sb = new StringBuilder();
|
||||||
var xws = new XmlWriterSettings();
|
var xws = new XmlWriterSettings();
|
||||||
xws.OmitXmlDeclaration = false;
|
xws.OmitXmlDeclaration = true;
|
||||||
xws.Indent = false;
|
xws.Indent = false;
|
||||||
|
|
||||||
using (var xw = XmlWriter.Create(sb, xws))
|
using (var xw = XmlWriter.Create(sb, xws))
|
||||||
|
@ -63,11 +63,11 @@ namespace NzbDrone.Core.Providers.Metadata
|
||||||
|
|
||||||
var doc = new XDocument(tvShow);
|
var doc = new XDocument(tvShow);
|
||||||
doc.Save(xw);
|
doc.Save(xw);
|
||||||
|
|
||||||
|
_logger.Debug("Saving tvshow.nfo for {0}", series.Title);
|
||||||
|
_diskProvider.WriteAllText(Path.Combine(series.Path, "tvshow.nfo"), doc.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.Debug("Saving tvshow.nfo for {0}", series.Title);
|
|
||||||
_diskProvider.WriteAllText(Path.Combine(series.Path, "tvshow.nfo"), sb.ToString());
|
|
||||||
|
|
||||||
_logger.Debug("Downloading fanart for: {0}", series.Title);
|
_logger.Debug("Downloading fanart for: {0}", series.Title);
|
||||||
_bannerProvider.Download(tvDbSeries.FanartPath, Path.Combine(series.Path, "fanart.jpg"));
|
_bannerProvider.Download(tvDbSeries.FanartPath, Path.Combine(series.Path, "fanart.jpg"));
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ namespace NzbDrone.Core.Providers.Metadata
|
||||||
{
|
{
|
||||||
var sb = new StringBuilder();
|
var sb = new StringBuilder();
|
||||||
var xws = new XmlWriterSettings();
|
var xws = new XmlWriterSettings();
|
||||||
xws.OmitXmlDeclaration = false;
|
xws.OmitXmlDeclaration = true;
|
||||||
xws.Indent = false;
|
xws.Indent = false;
|
||||||
|
|
||||||
using (var xw = XmlWriter.Create(sb, xws))
|
using (var xw = XmlWriter.Create(sb, xws))
|
||||||
|
@ -182,8 +182,9 @@ namespace NzbDrone.Core.Providers.Metadata
|
||||||
|
|
||||||
doc.Add(details);
|
doc.Add(details);
|
||||||
doc.Save(xw);
|
doc.Save(xw);
|
||||||
}
|
|
||||||
xmlResult += sb.ToString();
|
xmlResult += doc.ToString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
var filename = episodeFile.Path.Replace(Path.GetExtension(episodeFile.Path), ".nfo");
|
var filename = episodeFile.Path.Replace(Path.GetExtension(episodeFile.Path), ".nfo");
|
||||||
_logger.Debug("Saving episodedetails to: {0}", filename);
|
_logger.Debug("Saving episodedetails to: {0}", filename);
|
||||||
|
@ -229,8 +230,18 @@ namespace NzbDrone.Core.Providers.Metadata
|
||||||
{
|
{
|
||||||
var banner = tvDbSeries.SeasonBanners.FirstOrDefault(b => b.BannerType == bannerType && b.Season == season);
|
var banner = tvDbSeries.SeasonBanners.FirstOrDefault(b => b.BannerType == bannerType && b.Season == season);
|
||||||
_logger.Debug("Downloading banner for Season: {0} Series: {1}", season, series.Title);
|
_logger.Debug("Downloading banner for Season: {0} Series: {1}", season, series.Title);
|
||||||
_bannerProvider.Download(banner.BannerPath,
|
|
||||||
|
if (season == 0)
|
||||||
|
{
|
||||||
|
_bannerProvider.Download(banner.BannerPath,
|
||||||
|
Path.Combine(series.Path, "season-specials.tbn"));
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_bannerProvider.Download(banner.BannerPath,
|
||||||
Path.Combine(series.Path, String.Format("season{0:00}.tbn", season)));
|
Path.Combine(series.Path, String.Format("season{0:00}.tbn", season)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue