Esempio n. 1
0
        public override MetadataFile FindMetadataFile(Movie movie, string path)
        {
            var filename = Path.GetFileName(path);

            if (filename == null)
            {
                return(null);
            }

            var metadata = new MetadataFile
            {
                MovieId      = movie.Id,
                Consumer     = GetType().Name,
                RelativePath = movie.Path.GetRelativePath(path)
            };

            if (MovieImagesRegex.IsMatch(filename))
            {
                metadata.Type = MetadataType.MovieImage;
                return(metadata);
            }

            if (MovieFileImageRegex.IsMatch(filename))
            {
                metadata.Type = MetadataType.MovieImage;
                return(metadata);
            }

            if (filename.Equals("movie.nfo", StringComparison.OrdinalIgnoreCase) &&
                _detectNfo.IsXbmcNfoFile(path))
            {
                metadata.Type = MetadataType.MovieMetadata;
                return(metadata);
            }

            var parseResult = Parser.Parser.ParseMovieTitle(filename, false);

            if (parseResult != null &&
                Path.GetExtension(filename).Equals(".nfo", StringComparison.OrdinalIgnoreCase) &&
                _detectNfo.IsXbmcNfoFile(path))
            {
                metadata.Type = MetadataType.MovieMetadata;
                return(metadata);
            }

            return(null);
        }
Esempio n. 2
0
        public override MetadataFile FindMetadataFile(Artist artist, string path)
        {
            var filename = Path.GetFileName(path);

            if (filename == null)
            {
                return(null);
            }

            var metadata = new MetadataFile
            {
                ArtistId     = artist.Id,
                Consumer     = GetType().Name,
                RelativePath = artist.Path.GetRelativePath(path)
            };

            if (ArtistImagesRegex.IsMatch(filename))
            {
                metadata.Type = MetadataType.ArtistImage;
                return(metadata);
            }

            var albumMatch = AlbumImagesRegex.Match(filename);

            if (albumMatch.Success)
            {
                metadata.Type = MetadataType.AlbumImage;
                return(metadata);
            }

            var isXbmcNfoFile = _detectNfo.IsXbmcNfoFile(path);

            if (filename.Equals("artist.nfo", StringComparison.OrdinalIgnoreCase) &&
                isXbmcNfoFile)
            {
                metadata.Type = MetadataType.ArtistMetadata;
                return(metadata);
            }

            if (filename.Equals("album.nfo", StringComparison.OrdinalIgnoreCase) &&
                isXbmcNfoFile)
            {
                metadata.Type = MetadataType.AlbumMetadata;
                return(metadata);
            }

            return(null);
        }
Esempio n. 3
0
        public override MetadataFile FindMetadataFile(Series series, string path)
        {
            var filename = Path.GetFileName(path);

            if (filename == null)
            {
                return(null);
            }

            var metadata = new MetadataFile
            {
                SeriesId     = series.Id,
                Consumer     = GetType().Name,
                RelativePath = series.Path.GetRelativePath(path)
            };

            if (SeriesImagesRegex.IsMatch(filename))
            {
                metadata.Type = MetadataType.SeriesImage;
                return(metadata);
            }

            var seasonMatch = SeasonImagesRegex.Match(filename);

            if (seasonMatch.Success)
            {
                metadata.Type = MetadataType.SeasonImage;

                var seasonNumberMatch = seasonMatch.Groups["season"].Value;
                int seasonNumber;

                if (seasonNumberMatch.Contains("specials"))
                {
                    metadata.SeasonNumber = 0;
                }

                else if (int.TryParse(seasonNumberMatch, out seasonNumber))
                {
                    metadata.SeasonNumber = seasonNumber;
                }

                else
                {
                    return(null);
                }

                return(metadata);
            }

            if (EpisodeImageRegex.IsMatch(filename))
            {
                metadata.Type = MetadataType.EpisodeImage;
                return(metadata);
            }

            if (filename.Equals("tvshow.nfo", StringComparison.OrdinalIgnoreCase))
            {
                metadata.Type = MetadataType.SeriesMetadata;
                return(metadata);
            }

            var parseResult = Parser.Parser.ParseTitle(filename);

            if (parseResult != null &&
                !parseResult.FullSeason &&
                Path.GetExtension(filename).Equals(".nfo", StringComparison.OrdinalIgnoreCase) &&
                _detectNfo.IsXbmcNfoFile(path))
            {
                metadata.Type = MetadataType.EpisodeMetadata;
                return(metadata);
            }

            return(null);
        }