add ShortOverview

This commit is contained in:
Luke Pulverenti 2014-06-24 00:18:02 -04:00
parent e379e3fe95
commit 88d241edc1
21 changed files with 161 additions and 38 deletions

View File

@ -108,6 +108,12 @@ namespace MediaBrowser.Api
hasTags.Tags = request.Tags; hasTags.Tags = request.Tags;
} }
var hasShortOverview = item as IHasShortOverview;
if (hasShortOverview != null)
{
hasShortOverview.ShortOverview = request.ShortOverview;
}
var hasKeywords = item as IHasKeywords; var hasKeywords = item as IHasKeywords;
if (hasKeywords != null) if (hasKeywords != null)
{ {

View File

@ -1594,11 +1594,6 @@ namespace MediaBrowser.Api.Playback
{ {
return source; return source;
} }
Logger.Warn("Invalid channel MediaSourceId requested, defaulting to first. Item: {0}. Requested MediaSourceId: {1}.",
id,
mediaSourceId
);
} }
return list.First(); return list.First();

View File

@ -0,0 +1,12 @@

namespace MediaBrowser.Controller.Entities
{
public interface IHasShortOverview
{
/// <summary>
/// Gets or sets the short overview.
/// </summary>
/// <value>The short overview.</value>
string ShortOverview { get; set; }
}
}

View File

@ -14,7 +14,7 @@ namespace MediaBrowser.Controller.Entities.Movies
/// <summary> /// <summary>
/// Class Movie /// Class Movie
/// </summary> /// </summary>
public class Movie : Video, IHasCriticRating, IHasSoundtracks, IHasProductionLocations, IHasBudget, IHasKeywords, IHasTrailers, IHasThemeMedia, IHasTaglines, IHasPreferredMetadataLanguage, IHasAwards, IHasMetascore, IHasLookupInfo<MovieInfo>, ISupportsBoxSetGrouping public class Movie : Video, IHasCriticRating, IHasSoundtracks, IHasProductionLocations, IHasBudget, IHasKeywords, IHasTrailers, IHasThemeMedia, IHasTaglines, IHasPreferredMetadataLanguage, IHasAwards, IHasMetascore, IHasLookupInfo<MovieInfo>, ISupportsBoxSetGrouping, IHasShortOverview
{ {
public List<Guid> SpecialFeatureIds { get; set; } public List<Guid> SpecialFeatureIds { get; set; }
@ -52,6 +52,7 @@ namespace MediaBrowser.Controller.Entities.Movies
ProductionLocations = new List<string>(); ProductionLocations = new List<string>();
} }
public string ShortOverview { get; set; }
public string AwardSummary { get; set; } public string AwardSummary { get; set; }
public float? Metascore { get; set; } public float? Metascore { get; set; }

View File

@ -133,6 +133,7 @@
<Compile Include="Entities\IHasProductionLocations.cs" /> <Compile Include="Entities\IHasProductionLocations.cs" />
<Compile Include="Entities\IHasScreenshots.cs" /> <Compile Include="Entities\IHasScreenshots.cs" />
<Compile Include="Entities\IHasSeries.cs" /> <Compile Include="Entities\IHasSeries.cs" />
<Compile Include="Entities\IHasShortOverview.cs" />
<Compile Include="Entities\IHasSoundtracks.cs" /> <Compile Include="Entities\IHasSoundtracks.cs" />
<Compile Include="Entities\IHasTaglines.cs" /> <Compile Include="Entities\IHasTaglines.cs" />
<Compile Include="Entities\IHasTags.cs" /> <Compile Include="Entities\IHasTags.cs" />

View File

@ -1,5 +1,4 @@
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Persistence;
using MediaBrowser.Model.Entities; using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Logging; using MediaBrowser.Model.Logging;
using System; using System;
@ -9,7 +8,6 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks;
using System.Xml; using System.Xml;
namespace MediaBrowser.Controller.Providers namespace MediaBrowser.Controller.Providers
@ -249,6 +247,23 @@ namespace MediaBrowser.Controller.Providers
break; break;
} }
case "ShortOverview":
{
var val = reader.ReadElementContentAsString();
if (!string.IsNullOrWhiteSpace(val))
{
var hasShortOverview = item as IHasShortOverview;
if (hasShortOverview != null)
{
hasShortOverview.ShortOverview = val;
}
}
break;
}
case "CriticRatingSummary": case "CriticRatingSummary":
{ {
var val = reader.ReadElementContentAsString(); var val = reader.ReadElementContentAsString();
@ -812,19 +827,19 @@ namespace MediaBrowser.Controller.Providers
{ {
var val = reader.ReadElementContentAsString(); var val = reader.ReadElementContentAsString();
if (string.Equals("HSBS", val)) if (string.Equals("HSBS", val, StringComparison.CurrentCulture))
{ {
video.Video3DFormat = Video3DFormat.HalfSideBySide; video.Video3DFormat = Video3DFormat.HalfSideBySide;
} }
else if (string.Equals("HTAB", val)) else if (string.Equals("HTAB", val, StringComparison.CurrentCulture))
{ {
video.Video3DFormat = Video3DFormat.HalfTopAndBottom; video.Video3DFormat = Video3DFormat.HalfTopAndBottom;
} }
else if (string.Equals("FTAB", val)) else if (string.Equals("FTAB", val, StringComparison.CurrentCulture))
{ {
video.Video3DFormat = Video3DFormat.FullTopAndBottom; video.Video3DFormat = Video3DFormat.FullTopAndBottom;
} }
else if (string.Equals("FSBS", val)) else if (string.Equals("FSBS", val, StringComparison.CurrentCulture))
{ {
video.Video3DFormat = Video3DFormat.FullSideBySide; video.Video3DFormat = Video3DFormat.FullSideBySide;
} }
@ -1195,10 +1210,10 @@ namespace MediaBrowser.Controller.Providers
/// </summary> /// </summary>
/// <param name="reader">The reader.</param> /// <param name="reader">The reader.</param>
/// <returns>IEnumerable{PersonInfo}.</returns> /// <returns>IEnumerable{PersonInfo}.</returns>
private IEnumerable<Entities.PersonInfo> GetPersonsFromXmlNode(XmlReader reader) private IEnumerable<PersonInfo> GetPersonsFromXmlNode(XmlReader reader)
{ {
var name = string.Empty; var name = string.Empty;
var type = "Actor"; // If type is not specified assume actor var type = PersonType.Actor; // If type is not specified assume actor
var role = string.Empty; var role = string.Empty;
int? sortOrder = null; int? sortOrder = null;
@ -1257,7 +1272,7 @@ namespace MediaBrowser.Controller.Providers
} }
} }
var personInfo = new Entities.PersonInfo var personInfo = new PersonInfo
{ {
Name = name.Trim(), Name = name.Trim(),
Role = role, Role = role,

View File

@ -147,6 +147,12 @@ namespace MediaBrowser.Model.Dto
/// <value>The overview.</value> /// <value>The overview.</value>
public string Overview { get; set; } public string Overview { get; set; }
/// <summary>
/// Gets or sets the short overview.
/// </summary>
/// <value>The short overview.</value>
public string ShortOverview { get; set; }
/// <summary> /// <summary>
/// Gets or sets the name of the TMDB collection. /// Gets or sets the name of the TMDB collection.
/// </summary> /// </summary>

View File

@ -8,10 +8,22 @@ namespace MediaBrowser.Model.Dto
/// <value>The item identifier.</value> /// <value>The item identifier.</value>
public string ItemId { get; set; } public string ItemId { get; set; }
/// <summary>
/// Gets or sets the media source identifier.
/// </summary>
/// <value>The media source identifier.</value>
public string MediaSourceId { get; set; }
/// <summary> /// <summary>
/// Gets or sets the index of the stream. /// Gets or sets the index of the stream.
/// </summary> /// </summary>
/// <value>The index of the stream.</value> /// <value>The index of the stream.</value>
public int StreamIndex { get; set; } public int StreamIndex { get; set; }
/// <summary>
/// Gets or sets the format.
/// </summary>
/// <value>The format.</value>
public string Format { get; set; }
} }
} }

View File

@ -131,6 +131,11 @@ namespace MediaBrowser.Model.Querying
/// </summary> /// </summary>
Revenue, Revenue,
/// <summary>
/// The short overview
/// </summary>
ShortOverview,
/// <summary> /// <summary>
/// The screenshot image tags /// The screenshot image tags
/// </summary> /// </summary>

View File

@ -150,9 +150,13 @@ namespace MediaBrowser.Providers.Manager
var preferredLanguage = item.GetPreferredMetadataLanguage(); var preferredLanguage = item.GetPreferredMetadataLanguage();
var language = query.IncludeAllLanguages ? null : preferredLanguage; var languages = new List<string>();
if (!query.IncludeAllLanguages && !string.IsNullOrWhiteSpace(preferredLanguage))
{
languages.Add(preferredLanguage);
}
var tasks = providers.Select(i => GetImages(item, cancellationToken, i, language, query.ImageType)); var tasks = providers.Select(i => GetImages(item, cancellationToken, i, languages, query.ImageType));
var results = await Task.WhenAll(tasks).ConfigureAwait(false); var results = await Task.WhenAll(tasks).ConfigureAwait(false);
@ -167,10 +171,10 @@ namespace MediaBrowser.Providers.Manager
/// <param name="item">The item.</param> /// <param name="item">The item.</param>
/// <param name="cancellationToken">The cancellation token.</param> /// <param name="cancellationToken">The cancellation token.</param>
/// <param name="provider">The provider.</param> /// <param name="provider">The provider.</param>
/// <param name="preferredLanguage">The preferred language.</param> /// <param name="preferredLanguages">The preferred languages.</param>
/// <param name="type">The type.</param> /// <param name="type">The type.</param>
/// <returns>Task{IEnumerable{RemoteImageInfo}}.</returns> /// <returns>Task{IEnumerable{RemoteImageInfo}}.</returns>
private async Task<IEnumerable<RemoteImageInfo>> GetImages(IHasImages item, CancellationToken cancellationToken, IRemoteImageProvider provider, string preferredLanguage, ImageType? type = null) private async Task<IEnumerable<RemoteImageInfo>> GetImages(IHasImages item, CancellationToken cancellationToken, IRemoteImageProvider provider, List<string> preferredLanguages, ImageType? type = null)
{ {
try try
{ {
@ -181,12 +185,18 @@ namespace MediaBrowser.Providers.Manager
result = result.Where(i => i.Type == type.Value); result = result.Where(i => i.Type == type.Value);
} }
if (string.Equals(preferredLanguage, "en", StringComparison.OrdinalIgnoreCase)) if (preferredLanguages.Count > 0)
{ {
result = result.Where(i => string.IsNullOrEmpty(i.Language) || result = result.Where(i => string.IsNullOrEmpty(i.Language) ||
string.Equals(i.Language, "en", StringComparison.OrdinalIgnoreCase)); preferredLanguages.Contains(i.Language, StringComparer.OrdinalIgnoreCase));
} }
//if (string.Equals(preferredLanguage, "en", StringComparison.OrdinalIgnoreCase))
//{
// result = result.Where(i => string.IsNullOrEmpty(i.Language) ||
// string.Equals(i.Language, "en", StringComparison.OrdinalIgnoreCase));
//}
return result; return result;
} }
catch (OperationCanceledException) catch (OperationCanceledException)

View File

@ -183,6 +183,7 @@ namespace MediaBrowser.Providers.Manager
MergeAwards(source, target, lockedFields, replaceData); MergeAwards(source, target, lockedFields, replaceData);
MergeTaglines(source, target, lockedFields, replaceData); MergeTaglines(source, target, lockedFields, replaceData);
MergeTrailers(source, target, lockedFields, replaceData); MergeTrailers(source, target, lockedFields, replaceData);
MergeShortOverview(source, target, lockedFields, replaceData);
if (mergeMetadataSettings) if (mergeMetadataSettings)
{ {
@ -216,6 +217,20 @@ namespace MediaBrowser.Providers.Manager
} }
} }
private static void MergeShortOverview(BaseItem source, BaseItem target, List<MetadataFields> lockedFields, bool replaceData)
{
var sourceHasShortOverview = source as IHasShortOverview;
var targetHasShortOverview = target as IHasShortOverview;
if (sourceHasShortOverview != null && targetHasShortOverview != null)
{
if (replaceData || string.IsNullOrEmpty(targetHasShortOverview.ShortOverview))
{
targetHasShortOverview.ShortOverview = sourceHasShortOverview.ShortOverview;
}
}
}
private static void MergeAlbumArtist(BaseItem source, BaseItem target, List<MetadataFields> lockedFields, bool replaceData) private static void MergeAlbumArtist(BaseItem source, BaseItem target, List<MetadataFields> lockedFields, bool replaceData)
{ {
var sourceHasAlbumArtist = source as IHasAlbumArtist; var sourceHasAlbumArtist = source as IHasAlbumArtist;

View File

@ -220,6 +220,7 @@
<Compile Include="TV\TvExternalIds.cs" /> <Compile Include="TV\TvExternalIds.cs" />
<Compile Include="Users\UserMetadataService.cs" /> <Compile Include="Users\UserMetadataService.cs" />
<Compile Include="Videos\VideoMetadataService.cs" /> <Compile Include="Videos\VideoMetadataService.cs" />
<Compile Include="Videos\VideoXmlProvider.cs" />
<Compile Include="Xbmc\XbmcImageSaver.cs" /> <Compile Include="Xbmc\XbmcImageSaver.cs" />
<Compile Include="Years\YearMetadataService.cs" /> <Compile Include="Years\YearMetadataService.cs" />
</ItemGroup> </ItemGroup>

View File

@ -286,7 +286,6 @@ namespace MediaBrowser.Providers.MediaInfo
if (!string.Equals(originalVal, val, StringComparison.OrdinalIgnoreCase)) if (!string.Equals(originalVal, val, StringComparison.OrdinalIgnoreCase))
{ {
// TODO: Preserve casing from original value
artistsFound.Add(whitelistArtist); artistsFound.Add(whitelistArtist);
} }
} }

View File

@ -129,6 +129,13 @@ namespace MediaBrowser.Providers.Omdb
{ {
hasAwards.AwardSummary = WebUtility.HtmlDecode(result.Awards); hasAwards.AwardSummary = WebUtility.HtmlDecode(result.Awards);
} }
var hasShortOverview = item as IHasShortOverview;
if (hasShortOverview != null)
{
// Imdb plots are usually pretty short
hasShortOverview.ShortOverview = result.Plot;
}
} }
private bool ShouldFetchGenres(BaseItem item) private bool ShouldFetchGenres(BaseItem item)

View File

@ -1,7 +1,6 @@
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Entities;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Text; using System.Text;

View File

@ -56,8 +56,6 @@ namespace MediaBrowser.Providers.Savers
return false; return false;
} }
private static readonly CultureInfo UsCulture = new CultureInfo("en-US");
/// <summary> /// <summary>
/// Saves the specified item. /// Saves the specified item.
/// </summary> /// </summary>

View File

@ -135,9 +135,7 @@ namespace MediaBrowser.Providers.Savers
//Add the new node to the document. //Add the new node to the document.
xmlDocument.InsertBefore(xmlDocument.CreateXmlDeclaration("1.0", "UTF-8", "yes"), xmlDocument.DocumentElement); xmlDocument.InsertBefore(xmlDocument.CreateXmlDeclaration("1.0", "UTF-8", "yes"), xmlDocument.DocumentElement);
var parentPath = Path.GetDirectoryName(path); Directory.CreateDirectory(Path.GetDirectoryName(path));
Directory.CreateDirectory(parentPath);
var wasHidden = false; var wasHidden = false;
@ -259,9 +257,13 @@ namespace MediaBrowser.Providers.Savers
} }
} }
if (!string.IsNullOrEmpty(item.Overview)) var hasShortOverview = item as IHasShortOverview;
if (hasShortOverview != null)
{ {
builder.Append("<Overview><![CDATA[" + item.Overview + "]]></Overview>"); if (!string.IsNullOrEmpty(hasShortOverview.ShortOverview))
{
builder.Append("<ShortOverview><![CDATA[" + hasShortOverview.ShortOverview + "]]></ShortOverview>");
}
} }
if (!string.IsNullOrEmpty(item.CustomRating)) if (!string.IsNullOrEmpty(item.CustomRating))
@ -655,7 +657,7 @@ namespace MediaBrowser.Providers.Savers
if (video != null) if (video != null)
{ {
AddChapters(video, builder, itemRepository); //AddChapters(video, builder, itemRepository);
if (video.Video3DFormat.HasValue) if (video.Video3DFormat.HasValue)
{ {

View File

@ -89,12 +89,6 @@ namespace MediaBrowser.Providers.TV
} }
break; break;
} }
case "SeriesName":
// TODO: Deprecate in mid-2014
// No longer saving this tag but will still read it for a while
item.Name = reader.ReadElementContentAsString();
break;
case "Status": case "Status":
{ {
var status = reader.ReadElementContentAsString(); var status = reader.ReadElementContentAsString();

View File

@ -0,0 +1,37 @@
using MediaBrowser.Common.IO;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Logging;
using MediaBrowser.Providers.Movies;
using System.Collections.Generic;
using System.IO;
using System.Threading;
namespace MediaBrowser.Providers.Videos
{
class VideoXmlProvider : BaseXmlProvider<Video>
{
private readonly ILogger _logger;
public VideoXmlProvider(IFileSystem fileSystem, ILogger logger)
: base(fileSystem)
{
_logger = logger;
}
protected override void Fetch(LocalMetadataResult<Video> result, string path, CancellationToken cancellationToken)
{
var chapters = new List<ChapterInfo>();
new MovieXmlParser(_logger).Fetch(result.Item, chapters, path, cancellationToken);
result.Chapters = chapters;
}
protected override FileSystemInfo GetXmlFile(ItemInfo info, IDirectoryService directoryService)
{
return MovieXmlProvider.GetXmlFileInfo(info, FileSystem);
}
}
}

View File

@ -781,6 +781,15 @@ namespace MediaBrowser.Server.Implementations.Dto
} }
} }
if (fields.Contains(ItemFields.ShortOverview))
{
var hasShortOverview = item as IHasShortOverview;
if (hasShortOverview != null)
{
dto.ShortOverview = hasShortOverview.ShortOverview;
}
}
// If there are no backdrops, indicate what parent has them in case the Ui wants to allow inheritance // If there are no backdrops, indicate what parent has them in case the Ui wants to allow inheritance
if (dto.BackdropImageTags.Count == 0) if (dto.BackdropImageTags.Count == 0)
{ {

View File

@ -42,7 +42,6 @@ namespace MediaBrowser.ServerApplication.IO
{ {
var link = new ShellLink(); var link = new ShellLink();
((IPersistFile)link).Load(filename, NativeMethods.STGM_READ); ((IPersistFile)link).Load(filename, NativeMethods.STGM_READ);
// TODO: if I can get hold of the hwnd call resolve first. This handles moved and renamed files.
// ((IShellLinkW)link).Resolve(hwnd, 0) // ((IShellLinkW)link).Resolve(hwnd, 0)
var sb = new StringBuilder(NativeMethods.MAX_PATH); var sb = new StringBuilder(NativeMethods.MAX_PATH);
WIN32_FIND_DATA data; WIN32_FIND_DATA data;