mirror of
https://github.com/Sonarr/Sonarr.git
synced 2025-01-17 10:45:49 +02:00
Tweaks to XML and thumbs #ND-21
This commit is contained in:
parent
b122f1135e
commit
2e9cf66b57
@ -75,6 +75,34 @@ private void WithUseBanners()
|
||||
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]
|
||||
public void should_not_blowup()
|
||||
{
|
||||
@ -124,5 +152,14 @@ public void should_download_season_banner_when_useBanners_is_true()
|
||||
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));
|
||||
}
|
||||
|
||||
[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.Core;
|
||||
using NzbDrone.Core.Providers.ExternalNotification;
|
||||
using NzbDrone.Core.Providers.Indexer;
|
||||
using NzbDrone.Core.Providers.Metadata;
|
||||
using NzbDrone.Core.Repository;
|
||||
using PetaPoco;
|
||||
using SignalR;
|
||||
@ -20,6 +21,7 @@
|
||||
using SignalR.Infrastructure;
|
||||
using SignalR.Ninject;
|
||||
using Connection = NzbDrone.Core.Datastore.Connection;
|
||||
using Xbmc = NzbDrone.Core.Providers.ExternalNotification.Xbmc;
|
||||
|
||||
namespace NzbDrone.Core
|
||||
{
|
||||
@ -45,8 +47,9 @@ public CentralDispatch()
|
||||
|
||||
InitQuality();
|
||||
InitExternalNotifications();
|
||||
InitMetadataProviders();
|
||||
InitIndexers();
|
||||
InitJobs();
|
||||
InitJobs();
|
||||
}
|
||||
|
||||
private void InitDatabase()
|
||||
@ -160,6 +163,16 @@ private void InitExternalNotifications()
|
||||
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()
|
||||
{
|
||||
try
|
||||
|
@ -36,7 +36,7 @@ public override void CreateForSeries(Series series, TvdbSeries tvDbSeries)
|
||||
_logger.Debug("Generating tvshow.nfo for: {0}", series.Title);
|
||||
var sb = new StringBuilder();
|
||||
var xws = new XmlWriterSettings();
|
||||
xws.OmitXmlDeclaration = false;
|
||||
xws.OmitXmlDeclaration = true;
|
||||
xws.Indent = false;
|
||||
|
||||
using (var xw = XmlWriter.Create(sb, xws))
|
||||
@ -63,11 +63,11 @@ public override void CreateForSeries(Series series, TvdbSeries tvDbSeries)
|
||||
|
||||
var doc = new XDocument(tvShow);
|
||||
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);
|
||||
_bannerProvider.Download(tvDbSeries.FanartPath, Path.Combine(series.Path, "fanart.jpg"));
|
||||
|
||||
@ -122,7 +122,7 @@ public override void CreateForEpisodeFile(EpisodeFile episodeFile, TvdbSeries tv
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
var xws = new XmlWriterSettings();
|
||||
xws.OmitXmlDeclaration = false;
|
||||
xws.OmitXmlDeclaration = true;
|
||||
xws.Indent = false;
|
||||
|
||||
using (var xw = XmlWriter.Create(sb, xws))
|
||||
@ -182,8 +182,9 @@ public override void CreateForEpisodeFile(EpisodeFile episodeFile, TvdbSeries tv
|
||||
|
||||
doc.Add(details);
|
||||
doc.Save(xw);
|
||||
}
|
||||
xmlResult += sb.ToString();
|
||||
|
||||
xmlResult += doc.ToString();
|
||||
}
|
||||
}
|
||||
var filename = episodeFile.Path.Replace(Path.GetExtension(episodeFile.Path), ".nfo");
|
||||
_logger.Debug("Saving episodedetails to: {0}", filename);
|
||||
@ -229,8 +230,18 @@ private void DownloadSeasonThumbnails(Series series, TvdbSeries tvDbSeries, Tvdb
|
||||
{
|
||||
var banner = tvDbSeries.SeasonBanners.FirstOrDefault(b => b.BannerType == bannerType && b.Season == season);
|
||||
_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)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user