added game xml provider
This commit is contained in:
parent
3481d0d8e7
commit
9b167174ad
|
@ -278,6 +278,7 @@ namespace MediaBrowser.Controller.Providers
|
|||
case "ContentRating":
|
||||
case "certification":
|
||||
case "MPAARating":
|
||||
case "ESRBRating":
|
||||
{
|
||||
var rating = reader.ReadElementContentAsString();
|
||||
|
||||
|
@ -475,6 +476,7 @@ namespace MediaBrowser.Controller.Providers
|
|||
|
||||
case "Rating":
|
||||
case "IMDBrating":
|
||||
case "TGDBRating":
|
||||
{
|
||||
|
||||
var rating = reader.ReadElementContentAsString();
|
||||
|
|
93
MediaBrowser.Providers/Games/GameProviderFromXml.cs
Normal file
93
MediaBrowser.Providers/Games/GameProviderFromXml.cs
Normal file
|
@ -0,0 +1,93 @@
|
|||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.IO;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Providers.Games
|
||||
{
|
||||
public class GameProviderFromXml : BaseMetadataProvider
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="logManager"></param>
|
||||
/// <param name="configurationManager"></param>
|
||||
public GameProviderFromXml(ILogManager logManager, IServerConfigurationManager configurationManager)
|
||||
: base(logManager, configurationManager)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <returns></returns>
|
||||
public override bool Supports(BaseItem item)
|
||||
{
|
||||
return item is Game;
|
||||
}
|
||||
|
||||
protected override DateTime CompareDate(BaseItem item)
|
||||
{
|
||||
var xml = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, "game.xml"));
|
||||
return xml != null ? FileSystem.GetLastWriteTimeUtc(xml, Logger) : DateTime.MinValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="force"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public override Task<bool> FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
|
||||
{
|
||||
return Fetch((Game)item, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="game"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
private async Task<bool> Fetch(Game game, CancellationToken cancellationToken)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
var metaFile = Path.Combine(game.MetaLocation, "game.xml");
|
||||
|
||||
if (File.Exists(metaFile))
|
||||
{
|
||||
await XmlParsingResourcePool.WaitAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
try
|
||||
{
|
||||
new BaseItemXmlParser<Game>(Logger).Fetch(game, metaFile, cancellationToken);
|
||||
}
|
||||
finally
|
||||
{
|
||||
XmlParsingResourcePool.Release();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
SetLastRefreshed(game, DateTime.UtcNow);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public override MetadataProviderPriority Priority
|
||||
{
|
||||
get { return MetadataProviderPriority.First; }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -50,6 +50,7 @@
|
|||
<Compile Include="Extensions\XmlExtensions.cs" />
|
||||
<Compile Include="FanartBaseProvider.cs" />
|
||||
<Compile Include="FolderProviderFromXml.cs" />
|
||||
<Compile Include="Games\GameProviderFromXml.cs" />
|
||||
<Compile Include="ImageFromMediaLocationProvider.cs" />
|
||||
<Compile Include="ImagesByNameProvider.cs" />
|
||||
<Compile Include="MediaInfo\AudioImageProvider.cs" />
|
||||
|
|
|
@ -48,7 +48,7 @@ namespace MediaBrowser.Providers.Movies
|
|||
{
|
||||
case "Chapters":
|
||||
|
||||
_chaptersTask = FetchChaptersFromXmlNode(item.Id, reader.ReadSubtree(), _itemRepo, CancellationToken.None);
|
||||
_chaptersTask = FetchChaptersFromXmlNode(item, reader.ReadSubtree(), _itemRepo, CancellationToken.None);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
using System.Security;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Providers.Movies;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Security;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
|
@ -87,14 +87,7 @@ namespace MediaBrowser.Providers.Savers
|
|||
|
||||
public string GetSavePath(BaseItem item)
|
||||
{
|
||||
if (item.ResolveArgs.IsDirectory)
|
||||
{
|
||||
var path = Directory.Exists(item.Path) ? item.Path : Path.GetDirectoryName(item.Path);
|
||||
|
||||
return Path.Combine(path, "game.xml");
|
||||
}
|
||||
|
||||
return Path.ChangeExtension(item.Path, ".xml");
|
||||
return Path.Combine(item.MetaLocation, "game.xml");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ namespace MediaBrowser.Providers.TV
|
|||
{
|
||||
case "Chapters":
|
||||
|
||||
_chaptersTask = FetchChaptersFromXmlNode(item.Id, reader.ReadSubtree(), _itemRepo, CancellationToken.None);
|
||||
_chaptersTask = FetchChaptersFromXmlNode(item, reader.ReadSubtree(), _itemRepo, CancellationToken.None);
|
||||
break;
|
||||
|
||||
case "Episode":
|
||||
|
|
Loading…
Reference in New Issue
Block a user