Beispiel #1
0
        public IEnumerable <string> GetPossibleOrderedSeriesSearchValues(string fileName)
        {
            string noExtension = Path.GetFileNameWithoutExtension(fileName).Trim();
            string noMetadata  = MediaNameHelper.RemoveMetadata(noExtension).Trim();

            string noEpisode = MediaNameHelper.RemoveEpisode(noMetadata).Trim();

            yield return(noEpisode);

            string noSeason = MediaNameHelper.RemoveSeasonNotation(noEpisode).Trim();

            yield return(noSeason);

            // remove the last word ~ this is odd, but it's a last ditch,
            // and often we get shows with silly names at the end.
            if (noSeason.Contains(' ') && noSeason.Length > 8)
            {
                yield return(noSeason.Substring(0, noSeason.LastIndexOf(' ')).Trim());
            }

            // return the full one as the lowest priority (without an extension).
            yield return(noMetadata);

            yield return(noExtension);
        }
        private int FindSeasonNumber(Series series, string fileName)
        {
            var removedMetadata = MediaNameHelper.RemoveMetadata(fileName);

            // TODO: add regex to pattern match on S{digit}E{digit}.
            var fileParts = removedMetadata.Split('-');

            // for now, we just look for special notation
            // we can also look at our db to see latest season & if already exists?

            return(1);
        }
        private int FindEpisodeNumber(string fileName)
        {
            var removedMetadata = MediaNameHelper.RemoveMetadata(fileName);

            // TODO: add regex to pattern match on S{digit}E{digit}.
            var fileParts = removedMetadata.Split('-');

            // files sometimes contain versions
            // i.e. [jam] one piece - 12v3.mkv
            // so we wanna throw that version away.
            var noVersionNumbers = fileParts.Select(val => val.Split('v').First());

            var episodePart = noVersionNumbers.Last().Split(' ', StringSplitOptions.RemoveEmptyEntries).FirstOrDefault(part => part.All(char.IsDigit));

            return(string.IsNullOrWhiteSpace(episodePart)
                ? 1
                : int.Parse(episodePart));
        }