mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-06 11:34:57 +02:00
fixes for saving media info xml
This commit is contained in:
parent
673bc9d31b
commit
d94c8495b8
3 changed files with 90 additions and 108 deletions
|
@ -78,7 +78,7 @@ namespace MediaBrowser.Providers.Savers
|
|||
}
|
||||
|
||||
XmlSaverHelpers.AddCommonNodes(item, builder);
|
||||
XmlSaverHelpers.AppendMediaInfo(episode, builder);
|
||||
XmlSaverHelpers.AddMediaInfo(episode, builder);
|
||||
|
||||
builder.Append("</Item>");
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using MediaBrowser.Controller.Configuration;
|
||||
using System.Globalization;
|
||||
using System.Security;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Movies;
|
||||
using MediaBrowser.Controller.Library;
|
||||
|
@ -51,6 +53,8 @@ namespace MediaBrowser.Providers.Savers
|
|||
return false;
|
||||
}
|
||||
|
||||
private static readonly CultureInfo UsCulture = new CultureInfo("en-US");
|
||||
|
||||
/// <summary>
|
||||
/// Saves the specified item.
|
||||
/// </summary>
|
||||
|
@ -64,13 +68,28 @@ namespace MediaBrowser.Providers.Savers
|
|||
builder.Append("<Title>");
|
||||
|
||||
XmlSaverHelpers.AddCommonNodes(item, builder);
|
||||
XmlSaverHelpers.AppendMediaInfo((Video)item, builder);
|
||||
|
||||
if (item.CommunityRating.HasValue)
|
||||
{
|
||||
builder.Append("<IMDBrating>" + SecurityElement.Escape(item.CommunityRating.Value.ToString(UsCulture)) + "</IMDBrating>");
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(item.Overview))
|
||||
{
|
||||
builder.Append("<Description><![CDATA[" + item.Overview + "]]></Description>");
|
||||
}
|
||||
|
||||
XmlSaverHelpers.AddMediaInfo((Video)item, builder);
|
||||
|
||||
builder.Append("</Title>");
|
||||
|
||||
var xmlFilePath = GetSavePath(item);
|
||||
|
||||
XmlSaverHelpers.Save(builder, xmlFilePath, new string[] { });
|
||||
XmlSaverHelpers.Save(builder, xmlFilePath, new[]
|
||||
{
|
||||
"IMDBrating",
|
||||
"Description"
|
||||
});
|
||||
|
||||
// Set last refreshed so that the provider doesn't trigger after the file save
|
||||
MovieProviderFromXml.Current.SetLastRefreshed(item, DateTime.UtcNow);
|
||||
|
|
|
@ -57,7 +57,7 @@ namespace MediaBrowser.Providers.Savers
|
|||
"RunningTime",
|
||||
"Runtime",
|
||||
"TagLine",
|
||||
"TagLines",
|
||||
"Taglines",
|
||||
"IMDB_ID",
|
||||
"IMDB",
|
||||
"IMDbId",
|
||||
|
@ -71,7 +71,9 @@ namespace MediaBrowser.Providers.Savers
|
|||
"Tags",
|
||||
"Added",
|
||||
"LockData",
|
||||
"Trailer"
|
||||
"Trailer",
|
||||
"CriticRating",
|
||||
"CriticRatingSummary"
|
||||
});
|
||||
|
||||
var position = xml.ToString().LastIndexOf("</", StringComparison.OrdinalIgnoreCase);
|
||||
|
@ -299,14 +301,14 @@ namespace MediaBrowser.Providers.Savers
|
|||
{
|
||||
builder.Append("<TagLine>" + SecurityElement.Escape(item.Taglines[0]) + "</TagLine>");
|
||||
|
||||
builder.Append("<TagLines>");
|
||||
builder.Append("<Taglines>");
|
||||
|
||||
foreach (var tagline in item.Taglines)
|
||||
{
|
||||
builder.Append("<Tagline>" + SecurityElement.Escape(tagline) + "</Tagline>");
|
||||
}
|
||||
|
||||
builder.Append("</TagLines>");
|
||||
builder.Append("</Taglines>");
|
||||
}
|
||||
|
||||
if (item.Genres.Count > 0)
|
||||
|
@ -369,16 +371,14 @@ namespace MediaBrowser.Providers.Savers
|
|||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="builder">The builder.</param>
|
||||
public static void AppendMediaInfo<T>(T item, StringBuilder builder)
|
||||
public static void AddMediaInfo<T>(T item, StringBuilder builder)
|
||||
where T : BaseItem, IHasMediaStreams
|
||||
{
|
||||
builder.Append("<MediaInfo>");
|
||||
|
||||
foreach (var stream in item.MediaStreams)
|
||||
{
|
||||
if (stream.Type == MediaStreamType.Video)
|
||||
{
|
||||
builder.Append("<Video>");
|
||||
builder.Append("<" + stream.Type + ">");
|
||||
|
||||
if (!string.IsNullOrEmpty(stream.Codec))
|
||||
{
|
||||
|
@ -423,6 +423,21 @@ namespace MediaBrowser.Providers.Savers
|
|||
builder.Append("<ScanType>" + SecurityElement.Escape(stream.ScanType) + "</ScanType>");
|
||||
}
|
||||
|
||||
if (stream.Channels.HasValue)
|
||||
{
|
||||
builder.Append("<Channels>" + stream.Channels.Value.ToString(UsCulture) + "</Channels>");
|
||||
}
|
||||
|
||||
if (stream.SampleRate.HasValue)
|
||||
{
|
||||
builder.Append("<SamplingRate>" + stream.SampleRate.Value.ToString(UsCulture) + "</SamplingRate>");
|
||||
}
|
||||
|
||||
builder.Append("<Default>" + SecurityElement.Escape(stream.IsDefault.ToString()) + "</Default>");
|
||||
builder.Append("<Forced>" + SecurityElement.Escape(stream.IsForced.ToString()) + "</Forced>");
|
||||
|
||||
if (stream.Type == MediaStreamType.Video)
|
||||
{
|
||||
if (item.RunTimeTicks.HasValue)
|
||||
{
|
||||
var timespan = TimeSpan.FromTicks(item.RunTimeTicks.Value);
|
||||
|
@ -431,9 +446,6 @@ namespace MediaBrowser.Providers.Savers
|
|||
builder.Append("<DurationSeconds>" + Convert.ToInt32(timespan.TotalSeconds).ToString(UsCulture) + "</DurationSeconds>");
|
||||
}
|
||||
|
||||
builder.Append("<Default>" + SecurityElement.Escape(stream.IsDefault.ToString()) + "</Default>");
|
||||
builder.Append("<Forced>" + SecurityElement.Escape(stream.IsForced.ToString()) + "</Forced>");
|
||||
|
||||
var video = item as Video;
|
||||
|
||||
if (video != null && video.Video3DFormat.HasValue)
|
||||
|
@ -454,58 +466,9 @@ namespace MediaBrowser.Providers.Savers
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
builder.Append("</Video>");
|
||||
}
|
||||
else if (stream.Type == MediaStreamType.Audio)
|
||||
{
|
||||
builder.Append("<Audio>");
|
||||
|
||||
if (!string.IsNullOrEmpty(stream.Codec))
|
||||
{
|
||||
builder.Append("<Codec>" + SecurityElement.Escape(stream.Codec) + "</Codec>");
|
||||
builder.Append("<FFCodec>" + SecurityElement.Escape(stream.Codec) + "</FFCodec>");
|
||||
}
|
||||
|
||||
if (stream.Channels.HasValue)
|
||||
{
|
||||
builder.Append("<Channels>" + stream.Channels.Value.ToString(UsCulture) + "</Channels>");
|
||||
}
|
||||
|
||||
if (stream.BitRate.HasValue)
|
||||
{
|
||||
builder.Append("<BitRate>" + stream.BitRate.Value.ToString(UsCulture) + "</BitRate>");
|
||||
}
|
||||
|
||||
if (stream.SampleRate.HasValue)
|
||||
{
|
||||
builder.Append("<SamplingRate>" + stream.SampleRate.Value.ToString(UsCulture) + "</SamplingRate>");
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(stream.Language))
|
||||
{
|
||||
builder.Append("<Language>" + SecurityElement.Escape(stream.Language) + "</Language>");
|
||||
}
|
||||
|
||||
builder.Append("<Default>" + SecurityElement.Escape(stream.IsDefault.ToString()) + "</Default>");
|
||||
builder.Append("<Forced>" + SecurityElement.Escape(stream.IsForced.ToString()) + "</Forced>");
|
||||
|
||||
builder.Append("</Audio>");
|
||||
}
|
||||
else if (stream.Type == MediaStreamType.Subtitle)
|
||||
{
|
||||
builder.Append("<Subtitle>");
|
||||
|
||||
if (!string.IsNullOrEmpty(stream.Language))
|
||||
{
|
||||
builder.Append("<Language>" + SecurityElement.Escape(stream.Language) + "</Language>");
|
||||
}
|
||||
|
||||
builder.Append("<Default>" + SecurityElement.Escape(stream.IsDefault.ToString()) + "</Default>");
|
||||
builder.Append("<Forced>" + SecurityElement.Escape(stream.IsForced.ToString()) + "</Forced>");
|
||||
|
||||
builder.Append("</Subtitle>");
|
||||
}
|
||||
builder.Append("</" + stream.Type + ">");
|
||||
}
|
||||
|
||||
builder.Append("</MediaInfo>");
|
||||
|
|
Loading…
Reference in a new issue