Skip to content

Commit

Permalink
add game classes
Browse files Browse the repository at this point in the history
  • Loading branch information
LukePulverenti committed Jul 11, 2024
1 parent ac1e7ac commit a348e1b
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 0 deletions.
23 changes: 23 additions & 0 deletions NfoMetadata/Parsers/GameNfoParser.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Logging;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using System.Xml;

namespace NfoMetadata.Parsers
{
public class GameNfoParser : BaseNfoParser<Game>
{
public GameNfoParser(ILogger logger, IConfigurationManager config, IProviderManager providerManager, IFileSystem fileSystem) : base(logger, config, providerManager, fileSystem)
{
}
}
}
51 changes: 51 additions & 0 deletions NfoMetadata/Providers/GameNfoProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Logging;
using NfoMetadata.Parsers;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using System.Threading;

namespace NfoMetadata.Providers
{
public class GameNfoProvider : BaseNfoProvider<Game>
{
private readonly ILogger _logger;
private readonly IConfigurationManager _config;
private readonly IProviderManager _providerManager;

public GameNfoProvider(IFileSystem fileSystem, ILogger logger, IConfigurationManager config, IProviderManager providerManager)
: base(fileSystem)
{
_logger = logger;
_config = config;
_providerManager = providerManager;
}

protected override Task Fetch(MetadataResult<Game> result, string path, CancellationToken cancellationToken)
{
return new GameNfoParser(_logger, _config, _providerManager, FileSystem).Fetch(result, path, cancellationToken);
}

protected override FileSystemMetadata GetXmlFile(ItemInfo info, LibraryOptions libraryOptions, IDirectoryService directoryService)
{
var path = info.Path;

if (string.IsNullOrEmpty(path) || BaseItem.MediaSourceManager.GetPathProtocol(path.AsSpan()) != MediaBrowser.Model.MediaInfo.MediaProtocol.File)
{
return null;
}

path = Path.ChangeExtension(path, ".nfo");

return directoryService.GetFile(path);
}
}
}
58 changes: 58 additions & 0 deletions NfoMetadata/Savers/GameNfoSaver.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Logging;
using NfoMetadata.Configuration;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml;

namespace NfoMetadata.Savers
{
public class GameNfoSaver : BaseNfoSaver
{
public GameNfoSaver(IFileSystem fileSystem, ILibraryMonitor libraryMonitor, IServerConfigurationManager configurationManager, ILibraryManager libraryManager, IUserManager userManager, IUserDataManager userDataManager, ILogger logger) : base(fileSystem, libraryMonitor, configurationManager, libraryManager, userManager, userDataManager, logger)
{
}

protected override string GetSavePath(BaseItem item, LibraryOptions libraryOptions)
{
return Path.ChangeExtension(item.Path, ".nfo");
}

protected override string GetRootElementName(BaseItem item)
{
return "game";
}

public override bool IsEnabledFor(BaseItem item, ItemUpdateType updateType)
{
if (!item.IsFileProtocol)
{
return false;
}

return item is Game && updateType >= MinimumUpdateType;
}

protected override void WriteCustomElements(BaseItem item, XmlWriter writer, int nodeIndex, int numNodes)
{
}

protected override List<string> GetTagsUsed(BaseItem item, XbmcMetadataOptions options)
{
var list = base.GetTagsUsed(item, options);
list.AddRange(new string[]
{
});
return list;
}
}
}

0 comments on commit a348e1b

Please sign in to comment.