Exemplo n.º 1
0
        private bool ScanDirectory(string partialPath, string fullPath, string libraryType)
        {
            var includeGroup = Plugin.Instance.Configuration.SeriesGrouping == Ordering.GroupType.ShokoGroup;
            var series       = ApiManager.GetSeriesInfoByPathSync(fullPath);

            // We warn here since we enabled the provider in our library, but we can't find a match for the given folder path.
            if (series == null)
            {
                Logger.LogWarning($"Skipped unknown folder at path \"{partialPath}\"");
                return(false);
            }
            Logger.LogInformation($"Found series with id \"{series.Id}\" at path \"{partialPath}\"");

            // Filter library if we enabled the option.
            if (Plugin.Instance.Configuration.FilterOnLibraryTypes)
            {
                switch (libraryType)
                {
                default:
                    break;

                case "tvshows":
                    if (series.AniDB.Type == SeriesType.Movie)
                    {
                        Logger.LogInformation($"Library seperatation is enabled, ignoring series with id \"{series.Id}\" at path \"{partialPath}\"");
                        return(true);
                    }

                    // If we're using series grouping, pre-load the group now to help reduce load times later.
                    if (includeGroup)
                    {
                        ApiManager.GetGroupInfoForSeriesSync(series.Id, Ordering.GroupFilterType.Others);
                    }
                    break;

                case "movies":
                    if (series.AniDB.Type != SeriesType.Movie)
                    {
                        Logger.LogInformation($"Library seperatation is enabled, ignoring series with id \"{series.Id}\" at path \"{partialPath}\"");
                        return(true);
                    }

                    // If we're using series grouping, pre-load the group now to help reduce load times later.
                    if (includeGroup)
                    {
                        ApiManager.GetGroupInfoForSeriesSync(series.Id, Ordering.GroupFilterType.Movies);
                    }
                    break;
                }
            }
            // If we're using series grouping, pre-load the group now to help reduce load times later.
            else if (includeGroup)
            {
                ApiManager.GetGroupInfoForSeriesSync(series.Id);
            }

            return(false);
        }