support more xbmc image conventions

This commit is contained in:
Luke Pulverenti 2013-10-15 21:44:23 -04:00
parent d176da1ba9
commit 28bb5c7903
3 changed files with 264 additions and 97 deletions

View File

@ -173,73 +173,16 @@ namespace MediaBrowser.Providers
/// <param name="args">The args.</param> /// <param name="args">The args.</param>
private void PopulateBaseItemImages(BaseItem item, ItemResolveArgs args) private void PopulateBaseItemImages(BaseItem item, ItemResolveArgs args)
{ {
// Primary Image PopulatePrimaryImage(item, args);
var image = GetImage(item, args, "folder") ??
GetImage(item, args, "poster") ??
GetImage(item, args, "cover") ??
GetImage(item, args, "default");
// Support plex/xbmc convention
if (image == null && item is Series)
{
image = GetImage(item, args, "show");
}
// Support plex/xbmc convention
if (image == null && item is Season && item.IndexNumber.HasValue)
{
var num = item.IndexNumber.Value.ToString(_usCulture);
image = GetImage(item, args, string.Format("season-{0}", num));
}
// Support plex/xbmc convention
if (image == null && (item is Movie || item is MusicVideo || item is AdultVideo))
{
image = GetImage(item, args, "movie");
}
// Look for a file with the same name as the item
if (image == null)
{
var name = Path.GetFileNameWithoutExtension(item.Path);
if (!string.IsNullOrEmpty(name))
{
image = GetImage(item, args, name) ??
GetImage(item, args, name + "-poster");
}
}
if (image != null)
{
item.SetImage(ImageType.Primary, image.FullName);
}
// Logo Image // Logo Image
image = GetImage(item, args, "logo"); var image = GetImage(item, args, "logo");
if (image != null) if (image != null)
{ {
item.SetImage(ImageType.Logo, image.FullName); item.SetImage(ImageType.Logo, image.FullName);
} }
// Banner Image
image = GetImage(item, args, "banner");
// Support plex/xbmc convention
if (image == null && item is Season && item.IndexNumber.HasValue)
{
var num = item.IndexNumber.Value.ToString(_usCulture);
image = GetImage(item, args, string.Format("season-{0}-banner", num));
}
if (image != null)
{
item.SetImage(ImageType.Banner, image.FullName);
}
// Clearart // Clearart
image = GetImage(item, args, "clearart"); image = GetImage(item, args, "clearart");
@ -257,14 +200,6 @@ namespace MediaBrowser.Providers
item.SetImage(ImageType.Disc, image.FullName); item.SetImage(ImageType.Disc, image.FullName);
} }
// Thumbnail Image
image = GetImage(item, args, "thumb");
if (image != null)
{
item.SetImage(ImageType.Thumb, image.FullName);
}
// Box Image // Box Image
image = GetImage(item, args, "box"); image = GetImage(item, args, "box");
@ -289,46 +224,166 @@ namespace MediaBrowser.Providers
item.SetImage(ImageType.Menu, image.FullName); item.SetImage(ImageType.Menu, image.FullName);
} }
PopulateBanner(item, args);
PopulateThumb(item, args);
// Backdrop Image // Backdrop Image
PopulateBackdrops(item, args); PopulateBackdrops(item, args);
PopulateScreenshots(item, args);
}
// Screenshot Image private void PopulatePrimaryImage(BaseItem item, ItemResolveArgs args)
image = GetImage(item, args, "screenshot"); {
// Primary Image
var image = GetImage(item, args, "folder") ??
GetImage(item, args, "poster") ??
GetImage(item, args, "cover") ??
GetImage(item, args, "default");
var screenshotFiles = new List<string>(); // Support plex/xbmc convention
if (image == null && item is Series)
{
image = GetImage(item, args, "show") ??
GetImage(item, args, "season-all-poster");
}
// Support plex/xbmc convention
if (image == null && item is Season && item.IndexNumber.HasValue)
{
var seasonMarker = item.IndexNumber.Value == 0
? "-specials"
: item.IndexNumber.Value.ToString("00", _usCulture);
// Get this one directly from the file system since we have to go up a level
var filename = "season" + seasonMarker + "-poster";
var path = Path.GetDirectoryName(item.Path);
path = Path.Combine(path, filename);
image = new FileInfo(path);
if (!image.Exists)
{
image = null;
}
}
// Support plex/xbmc convention
if (image == null && (item is Movie || item is MusicVideo || item is AdultVideo))
{
image = GetImage(item, args, "movie");
}
// Look for a file with the same name as the item
if (image == null)
{
var name = Path.GetFileNameWithoutExtension(item.Path);
if (!string.IsNullOrEmpty(name))
{
image = GetImage(item, args, name) ??
GetImage(item, args, name + "-poster");
}
}
if (image != null) if (image != null)
{ {
screenshotFiles.Add(image.FullName); item.SetImage(ImageType.Primary, image.FullName);
} }
}
var unfound = 0; /// <summary>
for (var i = 1; i <= 20; i++) /// Populates the banner.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="args">The args.</param>
private void PopulateBanner(BaseItem item, ItemResolveArgs args)
{
// Banner Image
var image = GetImage(item, args, "banner");
if (image == null)
{ {
// Screenshot Image // Supprt xbmc conventions
image = GetImage(item, args, "screenshot" + i); if (item is Series)
if (image != null)
{ {
screenshotFiles.Add(image.FullName); image = GetImage(item, args, "season-all-banner");
} }
else else if (item is Season && item.IndexNumber.HasValue)
{ {
unfound++; var seasonMarker = item.IndexNumber.Value == 0
? "-specials"
: item.IndexNumber.Value.ToString("00", _usCulture);
if (unfound >= 3) // Get this one directly from the file system since we have to go up a level
var filename = "season" + seasonMarker + "-banner";
var path = Path.GetDirectoryName(item.Path);
path = Path.Combine(path, filename);
image = new FileInfo(path);
if (!image.Exists)
{ {
break; image = null;
} }
} }
} }
if (screenshotFiles.Count > 0) if (image != null)
{ {
item.ScreenshotImagePaths = screenshotFiles; item.SetImage(ImageType.Banner, image.FullName);
} }
} }
/// <summary>
/// Populates the thumb.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="args">The args.</param>
private void PopulateThumb(BaseItem item, ItemResolveArgs args)
{
// Thumbnail Image
var image = GetImage(item, args, "thumb");
if (image == null)
{
// Supprt xbmc conventions
if (item is Series)
{
image = GetImage(item, args, "season-all-landscape");
}
else if (item is Season && item.IndexNumber.HasValue)
{
var seasonMarker = item.IndexNumber.Value == 0
? "-specials"
: item.IndexNumber.Value.ToString("00", _usCulture);
// Get this one directly from the file system since we have to go up a level
var filename = "season" + seasonMarker + "-landscape";
var path = Path.GetDirectoryName(item.Path);
path = Path.Combine(path, filename);
image = new FileInfo(path);
if (!image.Exists)
{
image = null;
}
}
}
if (image != null)
{
item.SetImage(ImageType.Thumb, image.FullName);
}
}
/// <summary> /// <summary>
/// Populates the backdrops. /// Populates the backdrops.
/// </summary> /// </summary>
@ -345,6 +400,37 @@ namespace MediaBrowser.Providers
PopulateBackdrops(item, args, backdropFiles, "background", "background-"); PopulateBackdrops(item, args, backdropFiles, "background", "background-");
PopulateBackdrops(item, args, backdropFiles, "art", "art-"); PopulateBackdrops(item, args, backdropFiles, "art", "art-");
if (item is Series)
{
var image = GetImage(item, args, "season-all-fanart");
if (image != null)
{
backdropFiles.Add(image.FullName);
}
}
if (item is Season && item.IndexNumber.HasValue)
{
var seasonMarker = item.IndexNumber.Value == 0
? "-specials"
: item.IndexNumber.Value.ToString("00", _usCulture);
// Get this one directly from the file system since we have to go up a level
var filename = "season" + seasonMarker + "-fanart";
var path = Path.GetDirectoryName(item.Path);
path = Path.Combine(path, filename);
var image = new FileInfo(path);
if (image.Exists)
{
backdropFiles.Add(image.FullName);
}
}
PopulateBackdropsFromExtraFanart(args, backdropFiles); PopulateBackdropsFromExtraFanart(args, backdropFiles);
if (backdropFiles.Count > 0) if (backdropFiles.Count > 0)
@ -425,5 +511,49 @@ namespace MediaBrowser.Providers
} }
} }
} }
/// <summary>
/// Populates the screenshots.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="args">The args.</param>
private void PopulateScreenshots(BaseItem item, ItemResolveArgs args)
{
// Screenshot Image
var image = GetImage(item, args, "screenshot");
var screenshotFiles = new List<string>();
if (image != null)
{
screenshotFiles.Add(image.FullName);
}
var unfound = 0;
for (var i = 1; i <= 20; i++)
{
// Screenshot Image
image = GetImage(item, args, "screenshot" + i);
if (image != null)
{
screenshotFiles.Add(image.FullName);
}
else
{
unfound++;
if (unfound >= 3)
{
break;
}
}
}
if (screenshotFiles.Count > 0)
{
item.ScreenshotImagePaths = screenshotFiles;
}
}
} }
} }

View File

@ -218,8 +218,6 @@ namespace MediaBrowser.Providers.TV
if (!string.IsNullOrEmpty(seriesId)) if (!string.IsNullOrEmpty(seriesId))
{ {
series.SetProviderId(MetadataProviders.Tvdb, seriesId);
var seriesDataPath = GetSeriesDataPath(ConfigurationManager.ApplicationPaths, seriesId); var seriesDataPath = GetSeriesDataPath(ConfigurationManager.ApplicationPaths, seriesId);
await FetchSeriesData(series, seriesId, seriesDataPath, force, cancellationToken).ConfigureAwait(false); await FetchSeriesData(series, seriesId, seriesDataPath, force, cancellationToken).ConfigureAwait(false);
@ -255,19 +253,25 @@ namespace MediaBrowser.Providers.TV
await DownloadSeriesZip(seriesId, seriesDataPath, null, cancellationToken).ConfigureAwait(false); await DownloadSeriesZip(seriesId, seriesDataPath, null, cancellationToken).ConfigureAwait(false);
} }
// Examine if there's no local metadata, or save local is on (to get updates) // Have to check this here since we prevent the normal enforcement through ProviderManager
if (isForcedRefresh || ConfigurationManager.Configuration.EnableTvDbUpdates || !HasLocalMeta(series)) if (!series.DontFetchMeta)
{ {
var seriesXmlPath = Path.Combine(seriesDataPath, seriesXmlFilename); // Examine if there's no local metadata, or save local is on (to get updates)
var actorsXmlPath = Path.Combine(seriesDataPath, "actors.xml"); if (isForcedRefresh || ConfigurationManager.Configuration.EnableTvDbUpdates || !HasLocalMeta(series))
FetchSeriesInfo(series, seriesXmlPath, cancellationToken);
if (!series.LockedFields.Contains(MetadataFields.Cast))
{ {
series.People.Clear(); series.SetProviderId(MetadataProviders.Tvdb, seriesId);
FetchActors(series, actorsXmlPath, cancellationToken); var seriesXmlPath = Path.Combine(seriesDataPath, seriesXmlFilename);
var actorsXmlPath = Path.Combine(seriesDataPath, "actors.xml");
FetchSeriesInfo(series, seriesXmlPath, cancellationToken);
if (!series.LockedFields.Contains(MetadataFields.Cast))
{
series.People.Clear();
FetchActors(series, actorsXmlPath, cancellationToken);
}
} }
} }
} }

View File

@ -396,6 +396,24 @@ namespace MediaBrowser.Server.Implementations.Providers
if (imageIndex.Value == 0) if (imageIndex.Value == 0)
{ {
if (item is Series)
{
return new[] { Path.Combine(item.Path, "season-all-fanart" + extension) };
}
if (item is Season && item.IndexNumber.HasValue)
{
var seriesFolder = Path.GetDirectoryName(item.Path);
var seasonMarker = item.IndexNumber.Value == 0
? "-specials"
: item.IndexNumber.Value.ToString("00", UsCulture);
var imageFilename = "season" + seasonMarker + "-fanart" + extension;
return new[] { Path.Combine(seriesFolder, imageFilename) };
}
return new[] return new[]
{ {
Path.Combine(item.MetaLocation, "fanart" + extension) Path.Combine(item.MetaLocation, "fanart" + extension)
@ -413,6 +431,11 @@ namespace MediaBrowser.Server.Implementations.Providers
if (type == ImageType.Primary) if (type == ImageType.Primary)
{ {
if (item is Series)
{
return new[] { Path.Combine(item.Path, "season-all-poster" + extension) };
}
if (item is Season && item.IndexNumber.HasValue) if (item is Season && item.IndexNumber.HasValue)
{ {
var seriesFolder = Path.GetDirectoryName(item.Path); var seriesFolder = Path.GetDirectoryName(item.Path);
@ -446,6 +469,11 @@ namespace MediaBrowser.Server.Implementations.Providers
if (type == ImageType.Banner) if (type == ImageType.Banner)
{ {
if (item is Series)
{
return new[] { Path.Combine(item.Path, "season-all-banner" + extension) };
}
if (item is Season && item.IndexNumber.HasValue) if (item is Season && item.IndexNumber.HasValue)
{ {
var seriesFolder = Path.GetDirectoryName(item.Path); var seriesFolder = Path.GetDirectoryName(item.Path);
@ -462,6 +490,11 @@ namespace MediaBrowser.Server.Implementations.Providers
if (type == ImageType.Thumb) if (type == ImageType.Thumb)
{ {
if (item is Series)
{
return new[] { Path.Combine(item.Path, "season-all-landscape" + extension) };
}
if (item is Season && item.IndexNumber.HasValue) if (item is Season && item.IndexNumber.HasValue)
{ {
var seriesFolder = Path.GetDirectoryName(item.Path); var seriesFolder = Path.GetDirectoryName(item.Path);
@ -475,7 +508,7 @@ namespace MediaBrowser.Server.Implementations.Providers
return new[] { Path.Combine(seriesFolder, imageFilename) }; return new[] { Path.Combine(seriesFolder, imageFilename) };
} }
} }
// All other paths are the same // All other paths are the same
return new[] { GetLegacySavePath(item, type, imageIndex, mimeType, true) }; return new[] { GetLegacySavePath(item, type, imageIndex, mimeType, true) };
} }