Example #1
0
        static async Task <bool> ExtractGameData(ILocalFsResourceAccessor lfsra, IDictionary <Guid, IList <MediaItemAspect> > extractedAspectData, bool forceQuickMode)
        {
            var    categories = ServiceRegistration.Get <IMediaCategoryHelper>().GetMediaCategories(lfsra.CanonicalLocalResourcePath);
            string platform   = categories.FirstOrDefault(s => _platformCategories.ContainsKey(s));

            if (string.IsNullOrEmpty(platform))
            {
                Logger.Warn("GamesMetadataExtractor: Unable to import {0}, no platform categories have been selected", lfsra.LocalFileSystemPath);
                return(false);
            }

            var configurations = ServiceRegistration.Get <ISettingsManager>().Load <CommonSettings>().ConfiguredEmulators;

            if (!HasGameExtension(lfsra.CanonicalLocalResourcePath.BasePathSegment.Path, platform, configurations))
            {
                return(false);
            }

            Logger.Debug("GamesMetadataExtractor: Importing game: '{0}', '{1}'", lfsra.LocalFileSystemPath, platform);
            string   name     = DosPathHelper.GetFileNameWithoutExtension(lfsra.CanonicalLocalResourcePath.BasePathSegment.Path);
            GameInfo gameInfo = new GameInfo()
            {
                GameName = name,
                Platform = platform
            };

            GameMatcher matcher = GameMatcher.Instance;

            if (!forceQuickMode && !await matcher.FindAndUpdateGameAsync(gameInfo).ConfigureAwait(false))
            {
                Logger.Debug("GamesMetadataExtractor: No match found for game: '{0}', '{1}'", lfsra.LocalFileSystemPath, platform);
                gameInfo.GameName = name;
            }
            gameInfo.SetMetadata(extractedAspectData, lfsra);
            return(true);
        }