diff --git a/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs b/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs index 59307f4e7..0084fe96c 100644 --- a/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs +++ b/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs @@ -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(); diff --git a/MediaBrowser.Providers/Games/GameProviderFromXml.cs b/MediaBrowser.Providers/Games/GameProviderFromXml.cs new file mode 100644 index 000000000..4c6b9fc66 --- /dev/null +++ b/MediaBrowser.Providers/Games/GameProviderFromXml.cs @@ -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 + { + /// + /// + /// + /// + /// + public GameProviderFromXml(ILogManager logManager, IServerConfigurationManager configurationManager) + : base(logManager, configurationManager) + { + + } + + /// + /// + /// + /// + /// + 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; + } + + /// + /// + /// + /// + /// + /// + /// + public override Task FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken) + { + return Fetch((Game)item, cancellationToken); + } + + /// + /// + /// + /// + /// + /// + private async Task 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(Logger).Fetch(game, metaFile, cancellationToken); + } + finally + { + XmlParsingResourcePool.Release(); + } + + } + + SetLastRefreshed(game, DateTime.UtcNow); + return true; + } + + /// + /// + /// + public override MetadataProviderPriority Priority + { + get { return MetadataProviderPriority.First; } + } + } +} \ No newline at end of file diff --git a/MediaBrowser.Providers/MediaBrowser.Providers.csproj b/MediaBrowser.Providers/MediaBrowser.Providers.csproj index 806a2f113..f8011a5c4 100644 --- a/MediaBrowser.Providers/MediaBrowser.Providers.csproj +++ b/MediaBrowser.Providers/MediaBrowser.Providers.csproj @@ -50,6 +50,7 @@ + diff --git a/MediaBrowser.Providers/Movies/MovieXmlParser.cs b/MediaBrowser.Providers/Movies/MovieXmlParser.cs index e397e1d20..a26541955 100644 --- a/MediaBrowser.Providers/Movies/MovieXmlParser.cs +++ b/MediaBrowser.Providers/Movies/MovieXmlParser.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: diff --git a/MediaBrowser.Providers/Savers/GameXmlSaver.cs b/MediaBrowser.Providers/Savers/GameXmlSaver.cs index eb17658ee..41bd364c8 100644 --- a/MediaBrowser.Providers/Savers/GameXmlSaver.cs +++ b/MediaBrowser.Providers/Savers/GameXmlSaver.cs @@ -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"); } } } diff --git a/MediaBrowser.Providers/TV/EpisodeXmlParser.cs b/MediaBrowser.Providers/TV/EpisodeXmlParser.cs index 9dad56a84..792027300 100644 --- a/MediaBrowser.Providers/TV/EpisodeXmlParser.cs +++ b/MediaBrowser.Providers/TV/EpisodeXmlParser.cs @@ -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":