2014-09-06 04:21:23 +00:00
|
|
|
|
using MediaBrowser.Controller.Configuration;
|
|
|
|
|
using MediaBrowser.Controller.Entities;
|
|
|
|
|
using MediaBrowser.Controller.Entities.Movies;
|
|
|
|
|
using MediaBrowser.Controller.Entities.TV;
|
|
|
|
|
using MediaBrowser.Controller.Persistence;
|
|
|
|
|
using MediaBrowser.Controller.Playlists;
|
|
|
|
|
using MediaBrowser.Model.Entities;
|
|
|
|
|
using System;
|
2013-06-24 16:41:37 +00:00
|
|
|
|
using System.Collections.Generic;
|
2013-06-23 17:48:30 +00:00
|
|
|
|
using System.Globalization;
|
|
|
|
|
using System.IO;
|
2013-06-24 16:41:37 +00:00
|
|
|
|
using System.Linq;
|
2013-06-23 17:48:30 +00:00
|
|
|
|
using System.Security;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Xml;
|
|
|
|
|
|
2014-06-30 03:04:50 +00:00
|
|
|
|
namespace MediaBrowser.LocalMetadata.Savers
|
2013-06-23 17:48:30 +00:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Class XmlHelpers
|
|
|
|
|
/// </summary>
|
2013-06-23 18:55:30 +00:00
|
|
|
|
public static class XmlSaverHelpers
|
2013-06-23 17:48:30 +00:00
|
|
|
|
{
|
2013-09-26 02:01:50 +00:00
|
|
|
|
private static readonly Dictionary<string, string> CommonTags = new[] {
|
|
|
|
|
|
|
|
|
|
"Added",
|
|
|
|
|
"AspectRatio",
|
2014-02-19 05:21:03 +00:00
|
|
|
|
"AudioDbAlbumId",
|
|
|
|
|
"AudioDbArtistId",
|
2014-01-15 05:01:58 +00:00
|
|
|
|
"AwardSummary",
|
2013-09-26 02:01:50 +00:00
|
|
|
|
"BirthDate",
|
|
|
|
|
"Budget",
|
2014-03-25 05:25:03 +00:00
|
|
|
|
|
|
|
|
|
// Deprecated. No longer saving in this field.
|
2013-09-26 02:01:50 +00:00
|
|
|
|
"certification",
|
2014-03-25 05:25:03 +00:00
|
|
|
|
|
2013-09-26 02:01:50 +00:00
|
|
|
|
"Chapters",
|
|
|
|
|
"ContentRating",
|
2014-05-16 19:16:29 +00:00
|
|
|
|
"Countries",
|
2013-09-26 02:01:50 +00:00
|
|
|
|
"CustomRating",
|
|
|
|
|
"CriticRating",
|
|
|
|
|
"CriticRatingSummary",
|
|
|
|
|
"DeathDate",
|
2014-01-03 20:32:27 +00:00
|
|
|
|
"DisplayOrder",
|
2013-09-26 02:01:50 +00:00
|
|
|
|
"EndDate",
|
|
|
|
|
"Genres",
|
|
|
|
|
"Genre",
|
|
|
|
|
"GamesDbId",
|
2014-03-25 05:25:03 +00:00
|
|
|
|
|
|
|
|
|
// Deprecated. No longer saving in this field.
|
2013-09-26 02:01:50 +00:00
|
|
|
|
"IMDB_ID",
|
2014-03-25 05:25:03 +00:00
|
|
|
|
|
2013-09-26 02:01:50 +00:00
|
|
|
|
"IMDB",
|
2014-03-25 05:25:03 +00:00
|
|
|
|
|
|
|
|
|
// Deprecated. No longer saving in this field.
|
2013-09-26 02:01:50 +00:00
|
|
|
|
"IMDbId",
|
2014-03-25 05:25:03 +00:00
|
|
|
|
|
2013-09-26 02:01:50 +00:00
|
|
|
|
"Language",
|
|
|
|
|
"LocalTitle",
|
|
|
|
|
"LockData",
|
|
|
|
|
"LockedFields",
|
2013-12-15 01:17:57 +00:00
|
|
|
|
"Format3D",
|
2014-01-15 05:01:58 +00:00
|
|
|
|
"Metascore",
|
2014-03-25 05:25:03 +00:00
|
|
|
|
|
|
|
|
|
// Deprecated. No longer saving in this field.
|
2013-09-26 02:01:50 +00:00
|
|
|
|
"MPAARating",
|
2014-03-25 05:25:03 +00:00
|
|
|
|
|
2014-07-22 01:29:06 +00:00
|
|
|
|
"MPAADescription",
|
|
|
|
|
|
2014-02-09 17:44:25 +00:00
|
|
|
|
"MusicBrainzArtistId",
|
|
|
|
|
"MusicBrainzAlbumArtistId",
|
|
|
|
|
"MusicBrainzAlbumId",
|
2013-09-26 02:01:50 +00:00
|
|
|
|
"MusicBrainzReleaseGroupId",
|
2014-02-25 15:40:16 +00:00
|
|
|
|
|
2014-03-25 05:25:03 +00:00
|
|
|
|
// Deprecated. No longer saving in this field.
|
2014-02-25 15:40:16 +00:00
|
|
|
|
"MusicbrainzId",
|
|
|
|
|
|
2013-09-26 02:01:50 +00:00
|
|
|
|
"Overview",
|
2014-06-25 15:12:39 +00:00
|
|
|
|
"ShortOverview",
|
2013-09-26 02:01:50 +00:00
|
|
|
|
"Persons",
|
2014-01-15 05:01:58 +00:00
|
|
|
|
"PlotKeywords",
|
2013-09-26 02:01:50 +00:00
|
|
|
|
"PremiereDate",
|
|
|
|
|
"ProductionYear",
|
|
|
|
|
"Rating",
|
|
|
|
|
"Revenue",
|
|
|
|
|
"RottenTomatoesId",
|
|
|
|
|
"RunningTime",
|
2014-03-25 05:25:03 +00:00
|
|
|
|
|
|
|
|
|
// Deprecated. No longer saving in this field.
|
2013-09-26 02:01:50 +00:00
|
|
|
|
"Runtime",
|
2014-03-25 05:25:03 +00:00
|
|
|
|
|
2013-09-26 02:01:50 +00:00
|
|
|
|
"SortTitle",
|
|
|
|
|
"Studios",
|
|
|
|
|
"Tags",
|
2014-03-25 05:25:03 +00:00
|
|
|
|
|
|
|
|
|
// Deprecated. No longer saving in this field.
|
2013-09-26 02:01:50 +00:00
|
|
|
|
"TagLine",
|
2014-03-25 05:25:03 +00:00
|
|
|
|
|
2013-09-26 02:01:50 +00:00
|
|
|
|
"Taglines",
|
|
|
|
|
"TMDbCollectionId",
|
|
|
|
|
"TMDbId",
|
2014-03-25 05:25:03 +00:00
|
|
|
|
|
|
|
|
|
// Deprecated. No longer saving in this field.
|
2013-09-26 02:01:50 +00:00
|
|
|
|
"Trailer",
|
2014-03-25 05:25:03 +00:00
|
|
|
|
|
2013-12-01 20:17:40 +00:00
|
|
|
|
"Trailers",
|
2013-09-26 02:01:50 +00:00
|
|
|
|
"TVcomId",
|
|
|
|
|
"TvDbId",
|
|
|
|
|
"Type",
|
2014-02-19 05:21:03 +00:00
|
|
|
|
"TVRageId",
|
2013-10-13 13:32:53 +00:00
|
|
|
|
"VoteCount",
|
2013-09-26 02:01:50 +00:00
|
|
|
|
"Website",
|
2014-03-07 15:53:23 +00:00
|
|
|
|
"Zap2ItId",
|
2014-08-03 02:16:37 +00:00
|
|
|
|
"CollectionItems",
|
|
|
|
|
"PlaylistItems"
|
2013-09-26 02:01:50 +00:00
|
|
|
|
|
|
|
|
|
}.ToDictionary(i => i, StringComparer.OrdinalIgnoreCase);
|
|
|
|
|
|
2013-06-23 17:48:30 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The us culture
|
|
|
|
|
/// </summary>
|
|
|
|
|
private static readonly CultureInfo UsCulture = new CultureInfo("en-US");
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Saves the specified XML.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="xml">The XML.</param>
|
|
|
|
|
/// <param name="path">The path.</param>
|
2013-06-24 16:41:37 +00:00
|
|
|
|
/// <param name="xmlTagsUsed">The XML tags used.</param>
|
2014-09-06 04:21:23 +00:00
|
|
|
|
public static void Save(StringBuilder xml, string path, List<string> xmlTagsUsed, IServerConfigurationManager config)
|
2013-06-23 17:48:30 +00:00
|
|
|
|
{
|
2013-06-24 16:41:37 +00:00
|
|
|
|
if (File.Exists(path))
|
|
|
|
|
{
|
|
|
|
|
var position = xml.ToString().LastIndexOf("</", StringComparison.OrdinalIgnoreCase);
|
2013-09-25 15:11:23 +00:00
|
|
|
|
xml.Insert(position, GetCustomTags(path, xmlTagsUsed));
|
2013-06-24 16:41:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-06-23 17:48:30 +00:00
|
|
|
|
var xmlDocument = new XmlDocument();
|
|
|
|
|
xmlDocument.LoadXml(xml.ToString());
|
|
|
|
|
|
|
|
|
|
//Add the new node to the document.
|
|
|
|
|
xmlDocument.InsertBefore(xmlDocument.CreateXmlDeclaration("1.0", "UTF-8", "yes"), xmlDocument.DocumentElement);
|
|
|
|
|
|
2014-06-24 04:18:02 +00:00
|
|
|
|
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
2013-06-23 18:55:30 +00:00
|
|
|
|
|
2013-06-25 01:22:21 +00:00
|
|
|
|
var wasHidden = false;
|
|
|
|
|
|
|
|
|
|
var file = new FileInfo(path);
|
|
|
|
|
|
|
|
|
|
// This will fail if the file is hidden
|
|
|
|
|
if (file.Exists)
|
|
|
|
|
{
|
|
|
|
|
if ((file.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
|
|
|
|
|
{
|
|
|
|
|
file.Attributes &= ~FileAttributes.Hidden;
|
|
|
|
|
|
|
|
|
|
wasHidden = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
using (var filestream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read))
|
|
|
|
|
{
|
|
|
|
|
using (var streamWriter = new StreamWriter(filestream, Encoding.UTF8))
|
|
|
|
|
{
|
|
|
|
|
xmlDocument.Save(streamWriter);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-06 04:21:23 +00:00
|
|
|
|
if (wasHidden || config.Configuration.SaveMetadataHidden)
|
2013-06-23 17:48:30 +00:00
|
|
|
|
{
|
2013-06-25 01:22:21 +00:00
|
|
|
|
file.Refresh();
|
|
|
|
|
|
|
|
|
|
// Add back the attribute
|
|
|
|
|
file.Attributes |= FileAttributes.Hidden;
|
2013-06-23 17:48:30 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-24 16:41:37 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the custom tags.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="path">The path.</param>
|
|
|
|
|
/// <param name="xmlTagsUsed">The XML tags used.</param>
|
|
|
|
|
/// <returns>System.String.</returns>
|
2013-09-26 02:01:50 +00:00
|
|
|
|
private static string GetCustomTags(string path, List<string> xmlTagsUsed)
|
2013-06-24 16:41:37 +00:00
|
|
|
|
{
|
2013-09-25 15:11:23 +00:00
|
|
|
|
var settings = new XmlReaderSettings
|
|
|
|
|
{
|
|
|
|
|
CheckCharacters = false,
|
|
|
|
|
IgnoreProcessingInstructions = true,
|
|
|
|
|
IgnoreComments = true,
|
|
|
|
|
ValidationType = ValidationType.None
|
|
|
|
|
};
|
2013-06-24 16:41:37 +00:00
|
|
|
|
|
2013-09-25 15:11:23 +00:00
|
|
|
|
var builder = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
using (var streamReader = new StreamReader(path, Encoding.UTF8))
|
|
|
|
|
{
|
|
|
|
|
// Use XmlReader for best performance
|
|
|
|
|
using (var reader = XmlReader.Create(streamReader, settings))
|
|
|
|
|
{
|
|
|
|
|
reader.MoveToContent();
|
|
|
|
|
|
|
|
|
|
// Loop through each element
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
if (reader.NodeType == XmlNodeType.Element)
|
|
|
|
|
{
|
2013-09-26 02:01:50 +00:00
|
|
|
|
var name = reader.Name;
|
|
|
|
|
|
|
|
|
|
if (!CommonTags.ContainsKey(name) && !xmlTagsUsed.Contains(name, StringComparer.OrdinalIgnoreCase))
|
2013-09-25 15:11:23 +00:00
|
|
|
|
{
|
|
|
|
|
builder.AppendLine(reader.ReadOuterXml());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
reader.Skip();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-12-01 20:17:40 +00:00
|
|
|
|
|
2013-09-25 15:11:23 +00:00
|
|
|
|
return builder.ToString();
|
2013-06-24 16:41:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-06-23 17:48:30 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Adds the common nodes.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="item">The item.</param>
|
|
|
|
|
/// <param name="builder">The builder.</param>
|
|
|
|
|
public static void AddCommonNodes(BaseItem item, StringBuilder builder)
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(item.OfficialRating))
|
|
|
|
|
{
|
|
|
|
|
builder.Append("<ContentRating>" + SecurityElement.Escape(item.OfficialRating) + "</ContentRating>");
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-22 01:29:06 +00:00
|
|
|
|
if (!string.IsNullOrEmpty(item.OfficialRatingDescription))
|
|
|
|
|
{
|
|
|
|
|
builder.Append("<MPAADescription>" + SecurityElement.Escape(item.OfficialRatingDescription) + "</MPAADescription>");
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-17 15:19:28 +00:00
|
|
|
|
builder.Append("<Added>" + SecurityElement.Escape(item.DateCreated.ToLocalTime().ToString("G")) + "</Added>");
|
2013-06-23 17:48:30 +00:00
|
|
|
|
|
2014-03-22 16:16:43 +00:00
|
|
|
|
builder.Append("<LockData>" + item.IsLocked.ToString().ToLower() + "</LockData>");
|
2013-06-27 16:58:28 +00:00
|
|
|
|
|
2013-08-04 00:59:23 +00:00
|
|
|
|
if (item.LockedFields.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
builder.Append("<LockedFields>" + string.Join("|", item.LockedFields.Select(i => i.ToString()).ToArray()) + "</LockedFields>");
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-25 01:22:21 +00:00
|
|
|
|
if (!string.IsNullOrEmpty(item.DisplayMediaType))
|
|
|
|
|
{
|
|
|
|
|
builder.Append("<Type>" + SecurityElement.Escape(item.DisplayMediaType) + "</Type>");
|
|
|
|
|
}
|
2013-06-23 17:48:30 +00:00
|
|
|
|
|
2013-11-06 16:06:16 +00:00
|
|
|
|
var hasCriticRating = item as IHasCriticRating;
|
|
|
|
|
if (hasCriticRating != null)
|
2013-06-25 01:22:21 +00:00
|
|
|
|
{
|
2013-11-06 16:06:16 +00:00
|
|
|
|
if (hasCriticRating.CriticRating.HasValue)
|
|
|
|
|
{
|
|
|
|
|
builder.Append("<CriticRating>" + SecurityElement.Escape(hasCriticRating.CriticRating.Value.ToString(UsCulture)) + "</CriticRating>");
|
|
|
|
|
}
|
2013-06-23 17:48:30 +00:00
|
|
|
|
|
2013-11-06 16:06:16 +00:00
|
|
|
|
if (!string.IsNullOrEmpty(hasCriticRating.CriticRatingSummary))
|
|
|
|
|
{
|
|
|
|
|
builder.Append("<CriticRatingSummary><![CDATA[" + hasCriticRating.CriticRatingSummary + "]]></CriticRatingSummary>");
|
|
|
|
|
}
|
2013-06-23 17:48:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-06-25 15:12:39 +00:00
|
|
|
|
if (!string.IsNullOrEmpty(item.Overview))
|
|
|
|
|
{
|
|
|
|
|
builder.Append("<Overview><![CDATA[" + item.Overview + "]]></Overview>");
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-24 04:18:02 +00:00
|
|
|
|
var hasShortOverview = item as IHasShortOverview;
|
|
|
|
|
if (hasShortOverview != null)
|
2013-06-23 17:48:30 +00:00
|
|
|
|
{
|
2014-06-24 04:18:02 +00:00
|
|
|
|
if (!string.IsNullOrEmpty(hasShortOverview.ShortOverview))
|
|
|
|
|
{
|
|
|
|
|
builder.Append("<ShortOverview><![CDATA[" + hasShortOverview.ShortOverview + "]]></ShortOverview>");
|
|
|
|
|
}
|
2013-06-23 17:48:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(item.CustomRating))
|
|
|
|
|
{
|
|
|
|
|
builder.Append("<CustomRating>" + SecurityElement.Escape(item.CustomRating) + "</CustomRating>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(item.Name) && !(item is Episode))
|
|
|
|
|
{
|
|
|
|
|
builder.Append("<LocalTitle>" + SecurityElement.Escape(item.Name) + "</LocalTitle>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(item.ForcedSortName))
|
|
|
|
|
{
|
|
|
|
|
builder.Append("<SortTitle>" + SecurityElement.Escape(item.ForcedSortName) + "</SortTitle>");
|
|
|
|
|
}
|
2013-06-23 18:55:30 +00:00
|
|
|
|
|
2013-07-20 21:36:59 +00:00
|
|
|
|
if (item.PremiereDate.HasValue)
|
2013-06-23 18:55:30 +00:00
|
|
|
|
{
|
2013-07-20 21:36:59 +00:00
|
|
|
|
if (item is Person)
|
|
|
|
|
{
|
2014-01-24 15:30:05 +00:00
|
|
|
|
builder.Append("<BirthDate>" + SecurityElement.Escape(item.PremiereDate.Value.ToLocalTime().ToString("yyyy-MM-dd")) + "</BirthDate>");
|
2013-07-20 21:36:59 +00:00
|
|
|
|
}
|
|
|
|
|
else if (!(item is Episode))
|
|
|
|
|
{
|
2014-01-24 15:30:05 +00:00
|
|
|
|
builder.Append("<PremiereDate>" + SecurityElement.Escape(item.PremiereDate.Value.ToLocalTime().ToString("yyyy-MM-dd")) + "</PremiereDate>");
|
2013-07-20 21:36:59 +00:00
|
|
|
|
}
|
2013-06-23 18:55:30 +00:00
|
|
|
|
}
|
2013-06-27 16:58:28 +00:00
|
|
|
|
|
2013-07-29 18:33:48 +00:00
|
|
|
|
if (item.EndDate.HasValue)
|
|
|
|
|
{
|
|
|
|
|
if (item is Person)
|
|
|
|
|
{
|
|
|
|
|
builder.Append("<DeathDate>" + SecurityElement.Escape(item.EndDate.Value.ToString("yyyy-MM-dd")) + "</DeathDate>");
|
|
|
|
|
}
|
|
|
|
|
else if (!(item is Episode))
|
|
|
|
|
{
|
|
|
|
|
builder.Append("<EndDate>" + SecurityElement.Escape(item.EndDate.Value.ToString("yyyy-MM-dd")) + "</EndDate>");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-02 16:46:25 +00:00
|
|
|
|
var hasTrailers = item as IHasTrailers;
|
|
|
|
|
if (hasTrailers != null)
|
2013-06-27 16:58:28 +00:00
|
|
|
|
{
|
2013-12-02 16:46:25 +00:00
|
|
|
|
if (hasTrailers.RemoteTrailers.Count > 0)
|
2013-12-01 20:17:40 +00:00
|
|
|
|
{
|
2013-12-02 16:46:25 +00:00
|
|
|
|
builder.Append("<Trailers>");
|
|
|
|
|
|
|
|
|
|
foreach (var trailer in hasTrailers.RemoteTrailers)
|
|
|
|
|
{
|
|
|
|
|
builder.Append("<Trailer>" + SecurityElement.Escape(trailer.Url) + "</Trailer>");
|
|
|
|
|
}
|
2013-12-01 20:17:40 +00:00
|
|
|
|
|
2013-12-02 16:46:25 +00:00
|
|
|
|
builder.Append("</Trailers>");
|
|
|
|
|
}
|
2013-06-27 16:58:28 +00:00
|
|
|
|
}
|
2013-06-24 16:41:37 +00:00
|
|
|
|
|
2014-05-16 19:16:29 +00:00
|
|
|
|
var hasProductionLocations = item as IHasProductionLocations;
|
|
|
|
|
if (hasProductionLocations != null)
|
|
|
|
|
{
|
|
|
|
|
if (hasProductionLocations.ProductionLocations.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
builder.Append("<Countries>");
|
|
|
|
|
|
|
|
|
|
foreach (var name in hasProductionLocations.ProductionLocations)
|
|
|
|
|
{
|
|
|
|
|
builder.Append("<Country>" + SecurityElement.Escape(name) + "</Country>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
builder.Append("</Countries>");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-03 20:32:27 +00:00
|
|
|
|
var hasDisplayOrder = item as IHasDisplayOrder;
|
|
|
|
|
if (hasDisplayOrder != null && !string.IsNullOrEmpty(hasDisplayOrder.DisplayOrder))
|
|
|
|
|
{
|
|
|
|
|
builder.Append("<DisplayOrder>" + SecurityElement.Escape(hasDisplayOrder.DisplayOrder) + "</DisplayOrder>");
|
|
|
|
|
}
|
2014-01-15 05:01:58 +00:00
|
|
|
|
|
|
|
|
|
var hasMetascore = item as IHasMetascore;
|
|
|
|
|
if (hasMetascore != null && hasMetascore.Metascore.HasValue)
|
|
|
|
|
{
|
|
|
|
|
builder.Append("<Metascore>" + SecurityElement.Escape(hasMetascore.Metascore.Value.ToString(UsCulture)) + "</Metascore>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var hasAwards = item as IHasAwards;
|
|
|
|
|
if (hasAwards != null && !string.IsNullOrEmpty(hasAwards.AwardSummary))
|
|
|
|
|
{
|
|
|
|
|
builder.Append("<AwardSummary>" + SecurityElement.Escape(hasAwards.AwardSummary) + "</AwardSummary>");
|
|
|
|
|
}
|
2014-02-09 21:11:11 +00:00
|
|
|
|
|
2013-12-02 16:16:03 +00:00
|
|
|
|
var hasBudget = item as IHasBudget;
|
|
|
|
|
if (hasBudget != null)
|
2013-06-23 17:48:30 +00:00
|
|
|
|
{
|
2013-12-02 16:16:03 +00:00
|
|
|
|
if (hasBudget.Budget.HasValue)
|
|
|
|
|
{
|
|
|
|
|
builder.Append("<Budget>" + SecurityElement.Escape(hasBudget.Budget.Value.ToString(UsCulture)) + "</Budget>");
|
|
|
|
|
}
|
2013-06-23 17:48:30 +00:00
|
|
|
|
|
2013-12-02 16:16:03 +00:00
|
|
|
|
if (hasBudget.Revenue.HasValue)
|
|
|
|
|
{
|
|
|
|
|
builder.Append("<Revenue>" + SecurityElement.Escape(hasBudget.Revenue.Value.ToString(UsCulture)) + "</Revenue>");
|
|
|
|
|
}
|
2013-06-23 17:48:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item.CommunityRating.HasValue)
|
|
|
|
|
{
|
|
|
|
|
builder.Append("<Rating>" + SecurityElement.Escape(item.CommunityRating.Value.ToString(UsCulture)) + "</Rating>");
|
|
|
|
|
}
|
2013-10-13 13:32:53 +00:00
|
|
|
|
if (item.VoteCount.HasValue)
|
|
|
|
|
{
|
|
|
|
|
builder.Append("<VoteCount>" + SecurityElement.Escape(item.VoteCount.Value.ToString(UsCulture)) + "</VoteCount>");
|
|
|
|
|
}
|
2013-06-23 17:48:30 +00:00
|
|
|
|
|
2013-07-30 14:51:39 +00:00
|
|
|
|
if (item.ProductionYear.HasValue && !(item is Person))
|
2013-06-23 17:48:30 +00:00
|
|
|
|
{
|
|
|
|
|
builder.Append("<ProductionYear>" + SecurityElement.Escape(item.ProductionYear.Value.ToString(UsCulture)) + "</ProductionYear>");
|
|
|
|
|
}
|
2013-06-24 16:41:37 +00:00
|
|
|
|
|
2013-06-23 17:48:30 +00:00
|
|
|
|
if (!string.IsNullOrEmpty(item.HomePageUrl))
|
|
|
|
|
{
|
|
|
|
|
builder.Append("<Website>" + SecurityElement.Escape(item.HomePageUrl) + "</Website>");
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-20 03:15:48 +00:00
|
|
|
|
var hasAspectRatio = item as IHasAspectRatio;
|
|
|
|
|
if (hasAspectRatio != null)
|
2013-06-23 17:48:30 +00:00
|
|
|
|
{
|
2013-11-20 03:15:48 +00:00
|
|
|
|
if (!string.IsNullOrEmpty(hasAspectRatio.AspectRatio))
|
|
|
|
|
{
|
|
|
|
|
builder.Append("<AspectRatio>" + SecurityElement.Escape(hasAspectRatio.AspectRatio) + "</AspectRatio>");
|
|
|
|
|
}
|
2013-06-23 17:48:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-12-28 16:58:13 +00:00
|
|
|
|
var hasLanguage = item as IHasPreferredMetadataLanguage;
|
2013-12-05 16:50:21 +00:00
|
|
|
|
if (hasLanguage != null)
|
2013-06-23 17:48:30 +00:00
|
|
|
|
{
|
2013-12-28 16:58:13 +00:00
|
|
|
|
if (!string.IsNullOrEmpty(hasLanguage.PreferredMetadataLanguage))
|
2013-12-05 16:50:21 +00:00
|
|
|
|
{
|
2013-12-28 16:58:13 +00:00
|
|
|
|
builder.Append("<Language>" + SecurityElement.Escape(hasLanguage.PreferredMetadataLanguage) + "</Language>");
|
2013-12-05 16:50:21 +00:00
|
|
|
|
}
|
2013-06-23 17:48:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-06-25 01:22:21 +00:00
|
|
|
|
// Use original runtime here, actual file runtime later in MediaInfo
|
2014-01-24 15:30:05 +00:00
|
|
|
|
var runTimeTicks = item.RunTimeTicks;
|
2013-06-25 01:22:21 +00:00
|
|
|
|
|
|
|
|
|
if (runTimeTicks.HasValue)
|
2013-06-23 17:48:30 +00:00
|
|
|
|
{
|
2013-06-25 01:22:21 +00:00
|
|
|
|
var timespan = TimeSpan.FromTicks(runTimeTicks.Value);
|
2013-06-23 17:48:30 +00:00
|
|
|
|
|
|
|
|
|
builder.Append("<RunningTime>" + Convert.ToInt32(timespan.TotalMinutes).ToString(UsCulture) + "</RunningTime>");
|
|
|
|
|
}
|
2013-06-24 16:41:37 +00:00
|
|
|
|
|
2013-06-23 17:48:30 +00:00
|
|
|
|
var imdb = item.GetProviderId(MetadataProviders.Imdb);
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(imdb))
|
|
|
|
|
{
|
|
|
|
|
builder.Append("<IMDB>" + SecurityElement.Escape(imdb) + "</IMDB>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var tmdb = item.GetProviderId(MetadataProviders.Tmdb);
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(tmdb))
|
|
|
|
|
{
|
|
|
|
|
builder.Append("<TMDbId>" + SecurityElement.Escape(tmdb) + "</TMDbId>");
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-16 17:18:32 +00:00
|
|
|
|
if (!(item is Series))
|
|
|
|
|
{
|
|
|
|
|
var tvdb = item.GetProviderId(MetadataProviders.Tvdb);
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(tvdb))
|
|
|
|
|
{
|
|
|
|
|
builder.Append("<TvDbId>" + SecurityElement.Escape(tvdb) + "</TvDbId>");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-09 21:11:11 +00:00
|
|
|
|
var externalId = item.GetProviderId(MetadataProviders.Tvcom);
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(externalId))
|
|
|
|
|
{
|
|
|
|
|
builder.Append("<TVcomId>" + SecurityElement.Escape(externalId) + "</TVcomId>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
externalId = item.GetProviderId(MetadataProviders.RottenTomatoes);
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(externalId))
|
|
|
|
|
{
|
|
|
|
|
builder.Append("<RottenTomatoesId>" + SecurityElement.Escape(externalId) + "</RottenTomatoesId>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
externalId = item.GetProviderId(MetadataProviders.Zap2It);
|
2013-06-23 17:48:30 +00:00
|
|
|
|
|
2014-02-09 21:11:11 +00:00
|
|
|
|
if (!string.IsNullOrEmpty(externalId))
|
2013-06-23 17:48:30 +00:00
|
|
|
|
{
|
2014-02-09 21:11:11 +00:00
|
|
|
|
builder.Append("<Zap2ItId>" + SecurityElement.Escape(externalId) + "</Zap2ItId>");
|
2013-06-23 17:48:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-02-09 21:11:11 +00:00
|
|
|
|
externalId = item.GetProviderId(MetadataProviders.MusicBrainzAlbum);
|
2013-06-23 17:48:30 +00:00
|
|
|
|
|
2014-02-09 21:11:11 +00:00
|
|
|
|
if (!string.IsNullOrEmpty(externalId))
|
2013-06-23 17:48:30 +00:00
|
|
|
|
{
|
2014-02-09 21:11:11 +00:00
|
|
|
|
builder.Append("<MusicBrainzAlbumId>" + SecurityElement.Escape(externalId) + "</MusicBrainzAlbumId>");
|
2013-06-23 17:48:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-02-09 21:11:11 +00:00
|
|
|
|
externalId = item.GetProviderId(MetadataProviders.MusicBrainzAlbumArtist);
|
2013-09-02 15:45:39 +00:00
|
|
|
|
|
2014-02-09 21:11:11 +00:00
|
|
|
|
if (!string.IsNullOrEmpty(externalId))
|
2013-09-02 15:45:39 +00:00
|
|
|
|
{
|
2014-02-09 21:11:11 +00:00
|
|
|
|
builder.Append("<MusicBrainzAlbumArtistId>" + SecurityElement.Escape(externalId) + "</MusicBrainzAlbumArtistId>");
|
2013-09-02 15:45:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-02-09 21:11:11 +00:00
|
|
|
|
externalId = item.GetProviderId(MetadataProviders.MusicBrainzArtist);
|
2013-06-23 18:55:30 +00:00
|
|
|
|
|
2014-02-09 21:11:11 +00:00
|
|
|
|
if (!string.IsNullOrEmpty(externalId))
|
2013-06-23 18:55:30 +00:00
|
|
|
|
{
|
2014-02-09 21:11:11 +00:00
|
|
|
|
builder.Append("<MusicBrainzArtistId>" + SecurityElement.Escape(externalId) + "</MusicBrainzArtistId>");
|
2014-02-07 22:40:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-02-09 21:11:11 +00:00
|
|
|
|
externalId = item.GetProviderId(MetadataProviders.MusicBrainzReleaseGroup);
|
2014-02-07 22:40:03 +00:00
|
|
|
|
|
2014-02-09 21:11:11 +00:00
|
|
|
|
if (!string.IsNullOrEmpty(externalId))
|
2014-02-07 22:40:03 +00:00
|
|
|
|
{
|
2014-02-09 21:11:11 +00:00
|
|
|
|
builder.Append("<MusicBrainzReleaseGroupId>" + SecurityElement.Escape(externalId) + "</MusicBrainzReleaseGroupId>");
|
2014-02-07 22:40:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-02-09 21:11:11 +00:00
|
|
|
|
externalId = item.GetProviderId(MetadataProviders.Gamesdb);
|
2014-02-07 22:40:03 +00:00
|
|
|
|
|
2014-02-09 21:11:11 +00:00
|
|
|
|
if (!string.IsNullOrEmpty(externalId))
|
2014-02-07 22:40:03 +00:00
|
|
|
|
{
|
2014-02-09 21:11:11 +00:00
|
|
|
|
builder.Append("<GamesDbId>" + SecurityElement.Escape(externalId) + "</GamesDbId>");
|
2013-06-23 18:55:30 +00:00
|
|
|
|
}
|
2013-06-24 16:41:37 +00:00
|
|
|
|
|
2014-02-09 21:11:11 +00:00
|
|
|
|
externalId = item.GetProviderId(MetadataProviders.TmdbCollection);
|
2013-08-25 17:18:56 +00:00
|
|
|
|
|
2014-02-09 21:11:11 +00:00
|
|
|
|
if (!string.IsNullOrEmpty(externalId))
|
2013-08-25 17:18:56 +00:00
|
|
|
|
{
|
2014-02-09 21:11:11 +00:00
|
|
|
|
builder.Append("<TMDbCollectionId>" + SecurityElement.Escape(externalId) + "</TMDbCollectionId>");
|
2013-08-25 17:18:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-02-09 21:11:11 +00:00
|
|
|
|
externalId = item.GetProviderId(MetadataProviders.AudioDbArtist);
|
2013-07-16 17:18:32 +00:00
|
|
|
|
|
2014-02-09 21:11:11 +00:00
|
|
|
|
if (!string.IsNullOrEmpty(externalId))
|
2013-07-16 17:18:32 +00:00
|
|
|
|
{
|
2014-02-09 21:11:11 +00:00
|
|
|
|
builder.Append("<AudioDbArtistId>" + SecurityElement.Escape(externalId) + "</AudioDbArtistId>");
|
2013-07-16 17:18:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-02-09 21:13:17 +00:00
|
|
|
|
externalId = item.GetProviderId(MetadataProviders.AudioDbAlbum);
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(externalId))
|
|
|
|
|
{
|
|
|
|
|
builder.Append("<AudioDbAlbumId>" + SecurityElement.Escape(externalId) + "</AudioDbAlbumId>");
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-09 21:11:11 +00:00
|
|
|
|
externalId = item.GetProviderId(MetadataProviders.TvRage);
|
2013-06-23 17:48:30 +00:00
|
|
|
|
|
2014-02-09 21:11:11 +00:00
|
|
|
|
if (!string.IsNullOrEmpty(externalId))
|
2013-06-23 17:48:30 +00:00
|
|
|
|
{
|
2014-02-19 05:21:03 +00:00
|
|
|
|
builder.Append("<TVRageId>" + SecurityElement.Escape(externalId) + "</TVRageId>");
|
2013-06-23 17:48:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-12-05 16:50:21 +00:00
|
|
|
|
var hasTagline = item as IHasTaglines;
|
|
|
|
|
if (hasTagline != null)
|
2013-06-25 01:22:21 +00:00
|
|
|
|
{
|
2013-12-05 16:50:21 +00:00
|
|
|
|
if (hasTagline.Taglines.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
builder.Append("<Taglines>");
|
2013-06-25 01:22:21 +00:00
|
|
|
|
|
2013-12-05 16:50:21 +00:00
|
|
|
|
foreach (var tagline in hasTagline.Taglines)
|
|
|
|
|
{
|
|
|
|
|
builder.Append("<Tagline>" + SecurityElement.Escape(tagline) + "</Tagline>");
|
|
|
|
|
}
|
2013-06-25 01:22:21 +00:00
|
|
|
|
|
2013-12-05 16:50:21 +00:00
|
|
|
|
builder.Append("</Taglines>");
|
|
|
|
|
}
|
2013-06-25 01:22:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-06-23 17:48:30 +00:00
|
|
|
|
if (item.Genres.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
builder.Append("<Genres>");
|
|
|
|
|
|
|
|
|
|
foreach (var genre in item.Genres)
|
|
|
|
|
{
|
|
|
|
|
builder.Append("<Genre>" + SecurityElement.Escape(genre) + "</Genre>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
builder.Append("</Genres>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item.Studios.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
builder.Append("<Studios>");
|
|
|
|
|
|
|
|
|
|
foreach (var studio in item.Studios)
|
|
|
|
|
{
|
|
|
|
|
builder.Append("<Studio>" + SecurityElement.Escape(studio) + "</Studio>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
builder.Append("</Studios>");
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-05 16:50:21 +00:00
|
|
|
|
var hasTags = item as IHasTags;
|
|
|
|
|
if (hasTags != null)
|
2013-06-23 18:55:30 +00:00
|
|
|
|
{
|
2013-12-05 16:50:21 +00:00
|
|
|
|
if (hasTags.Tags.Count > 0)
|
2013-06-23 18:55:30 +00:00
|
|
|
|
{
|
2013-12-05 16:50:21 +00:00
|
|
|
|
builder.Append("<Tags>");
|
2013-06-23 18:55:30 +00:00
|
|
|
|
|
2013-12-05 16:50:21 +00:00
|
|
|
|
foreach (var tag in hasTags.Tags)
|
|
|
|
|
{
|
|
|
|
|
builder.Append("<Tag>" + SecurityElement.Escape(tag) + "</Tag>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
builder.Append("</Tags>");
|
|
|
|
|
}
|
2013-06-23 18:55:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-01-14 15:50:39 +00:00
|
|
|
|
var hasKeywords = item as IHasKeywords;
|
|
|
|
|
if (hasKeywords != null)
|
|
|
|
|
{
|
|
|
|
|
if (hasKeywords.Keywords.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
builder.Append("<PlotKeywords>");
|
|
|
|
|
|
|
|
|
|
foreach (var tag in hasKeywords.Keywords)
|
|
|
|
|
{
|
|
|
|
|
builder.Append("<PlotKeyword>" + SecurityElement.Escape(tag) + "</PlotKeyword>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
builder.Append("</PlotKeywords>");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-25 01:22:21 +00:00
|
|
|
|
if (item.People.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
builder.Append("<Persons>");
|
|
|
|
|
|
|
|
|
|
foreach (var person in item.People)
|
|
|
|
|
{
|
|
|
|
|
builder.Append("<Person>");
|
|
|
|
|
builder.Append("<Name>" + SecurityElement.Escape(person.Name) + "</Name>");
|
|
|
|
|
builder.Append("<Type>" + SecurityElement.Escape(person.Type) + "</Type>");
|
|
|
|
|
builder.Append("<Role>" + SecurityElement.Escape(person.Role) + "</Role>");
|
2013-11-20 03:47:29 +00:00
|
|
|
|
|
|
|
|
|
if (person.SortOrder.HasValue)
|
|
|
|
|
{
|
|
|
|
|
builder.Append("<SortOrder>" + SecurityElement.Escape(person.SortOrder.Value.ToString(UsCulture)) + "</SortOrder>");
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-25 01:22:21 +00:00
|
|
|
|
builder.Append("</Person>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
builder.Append("</Persons>");
|
|
|
|
|
}
|
2014-03-07 15:53:23 +00:00
|
|
|
|
|
2014-08-03 02:16:37 +00:00
|
|
|
|
var boxset = item as BoxSet;
|
|
|
|
|
if (boxset != null)
|
2014-03-07 15:53:23 +00:00
|
|
|
|
{
|
2014-08-03 02:16:37 +00:00
|
|
|
|
AddLinkedChildren(boxset, builder, "CollectionItems", "CollectionItem");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var playlist = item as Playlist;
|
|
|
|
|
if (playlist != null)
|
|
|
|
|
{
|
|
|
|
|
AddLinkedChildren(playlist, builder, "PlaylistItems", "PlaylistItem");
|
2014-03-07 15:53:23 +00:00
|
|
|
|
}
|
2013-08-12 19:18:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void AddChapters(Video item, StringBuilder builder, IItemRepository repository)
|
|
|
|
|
{
|
|
|
|
|
var chapters = repository.GetChapters(item.Id);
|
|
|
|
|
|
|
|
|
|
builder.Append("<Chapters>");
|
|
|
|
|
|
|
|
|
|
foreach (var chapter in chapters)
|
|
|
|
|
{
|
|
|
|
|
builder.Append("<Chapter>");
|
|
|
|
|
builder.Append("<Name>" + SecurityElement.Escape(chapter.Name) + "</Name>");
|
|
|
|
|
|
|
|
|
|
var time = TimeSpan.FromTicks(chapter.StartPositionTicks);
|
|
|
|
|
var ms = Convert.ToInt64(time.TotalMilliseconds);
|
|
|
|
|
|
|
|
|
|
builder.Append("<StartPositionMs>" + SecurityElement.Escape(ms.ToString(UsCulture)) + "</StartPositionMs>");
|
|
|
|
|
builder.Append("</Chapter>");
|
|
|
|
|
}
|
2013-06-25 01:22:21 +00:00
|
|
|
|
|
2013-08-12 19:18:31 +00:00
|
|
|
|
builder.Append("</Chapters>");
|
2013-06-23 17:48:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Appends the media info.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <typeparam name="T"></typeparam>
|
2013-08-30 23:55:17 +00:00
|
|
|
|
public static void AddMediaInfo<T>(T item, StringBuilder builder, IItemRepository itemRepository)
|
2014-06-03 02:01:30 +00:00
|
|
|
|
where T : BaseItem
|
2013-06-23 17:48:30 +00:00
|
|
|
|
{
|
2013-08-30 23:55:17 +00:00
|
|
|
|
var video = item as Video;
|
|
|
|
|
|
2014-05-14 20:43:31 +00:00
|
|
|
|
if (video != null)
|
2013-12-06 03:39:44 +00:00
|
|
|
|
{
|
2014-06-24 04:18:02 +00:00
|
|
|
|
//AddChapters(video, builder, itemRepository);
|
2014-05-14 20:43:31 +00:00
|
|
|
|
|
|
|
|
|
if (video.Video3DFormat.HasValue)
|
2013-07-01 16:00:20 +00:00
|
|
|
|
{
|
2014-05-14 20:43:31 +00:00
|
|
|
|
switch (video.Video3DFormat.Value)
|
|
|
|
|
{
|
|
|
|
|
case Video3DFormat.FullSideBySide:
|
|
|
|
|
builder.Append("<Format3D>FSBS</Format3D>");
|
|
|
|
|
break;
|
|
|
|
|
case Video3DFormat.FullTopAndBottom:
|
|
|
|
|
builder.Append("<Format3D>FTAB</Format3D>");
|
|
|
|
|
break;
|
|
|
|
|
case Video3DFormat.HalfSideBySide:
|
|
|
|
|
builder.Append("<Format3D>HSBS</Format3D>");
|
|
|
|
|
break;
|
|
|
|
|
case Video3DFormat.HalfTopAndBottom:
|
|
|
|
|
builder.Append("<Format3D>HTAB</Format3D>");
|
|
|
|
|
break;
|
|
|
|
|
}
|
2013-06-23 17:48:30 +00:00
|
|
|
|
}
|
2013-12-10 20:42:42 +00:00
|
|
|
|
}
|
2013-06-23 17:48:30 +00:00
|
|
|
|
}
|
2014-03-07 15:53:23 +00:00
|
|
|
|
|
2014-08-03 02:16:37 +00:00
|
|
|
|
public static void AddLinkedChildren(Folder item, StringBuilder builder, string pluralNodeName, string singularNodeName)
|
2014-03-07 15:53:23 +00:00
|
|
|
|
{
|
|
|
|
|
var items = item.LinkedChildren
|
2014-08-05 23:59:24 +00:00
|
|
|
|
.Where(i => i.Type == LinkedChildType.Manual)
|
2014-03-07 15:53:23 +00:00
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
if (items.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-03 02:16:37 +00:00
|
|
|
|
builder.Append("<" + pluralNodeName + ">");
|
2014-03-07 15:53:23 +00:00
|
|
|
|
foreach (var link in items)
|
|
|
|
|
{
|
2014-08-03 02:16:37 +00:00
|
|
|
|
builder.Append("<" + singularNodeName + ">");
|
2014-03-07 15:53:23 +00:00
|
|
|
|
|
2014-08-05 23:59:24 +00:00
|
|
|
|
if (!string.IsNullOrWhiteSpace(link.ItemType))
|
|
|
|
|
{
|
|
|
|
|
builder.Append("<Type>" + SecurityElement.Escape(link.ItemType) + "</Type>");
|
|
|
|
|
}
|
2014-03-07 15:53:23 +00:00
|
|
|
|
|
|
|
|
|
if (link.ItemYear.HasValue)
|
|
|
|
|
{
|
|
|
|
|
builder.Append("<Year>" + SecurityElement.Escape(link.ItemYear.Value.ToString(UsCulture)) + "</Year>");
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-05 23:59:24 +00:00
|
|
|
|
if (!string.IsNullOrWhiteSpace(link.Path))
|
|
|
|
|
{
|
|
|
|
|
builder.Append("<Path>" + SecurityElement.Escape((link.Path)) + "</Path>");
|
|
|
|
|
}
|
2014-08-03 02:16:37 +00:00
|
|
|
|
|
|
|
|
|
builder.Append("</" + singularNodeName + ">");
|
2014-03-07 15:53:23 +00:00
|
|
|
|
}
|
2014-08-03 02:16:37 +00:00
|
|
|
|
builder.Append("</" + pluralNodeName + ">");
|
2014-03-07 15:53:23 +00:00
|
|
|
|
}
|
2013-06-23 17:48:30 +00:00
|
|
|
|
}
|
|
|
|
|
}
|