def parse(self):
        # type: () -> BaseInfo
        """Runs path via configured regex, extracting data from groups.
        Returns an EpisodeInfo instance containing extracted data.
        """
        _, filename = os.path.split(self.path)

        filename = _apply_replacements_input(filename)

        for cmatcher in self.compiled_regexs:
            match = cmatcher.match(filename)
            if match:
                namedgroups = match.groupdict().keys()

                if 'episodenumber1' in namedgroups:
                    # Multiple episodes, have episodenumber1 or 2 etc
                    epnos = []
                    for cur in namedgroups:
                        epnomatch = re.match(r'episodenumber(\d+)', cur)
                        if epnomatch:
                            epnos.append(int(match.group(cur)))
                    epnos.sort()
                    episodenumbers = epnos # type: List[int]

                elif 'episodenumberstart' in namedgroups:
                    # Multiple episodes, regex specifies start and end number
                    start = int(match.group('episodenumberstart'))
                    end = int(match.group('episodenumberend'))
                    if end - start > 5:
                        warn(
                            "WARNING: %s episodes detected in file: %s, confused by numeric episode name, using first match: %s"
                            % (end - start, filename, start)
                        )
                        episodenumbers = [start]
                    elif start > end:
                        # Swap start and end
                        start, end = end, start
                        episodenumbers = list(range(start, end + 1))
                    else:
                        episodenumbers = list(range(start, end + 1))

                elif 'episodenumber' in namedgroups:
                    episodenumbers = [
                        int(match.group('episodenumber')),
                    ]

                elif (
                    'year' in namedgroups
                    or 'month' in namedgroups
                    or 'day' in namedgroups
                ):
                    if not all(
                        [
                            'year' in namedgroups,
                            'month' in namedgroups,
                            'day' in namedgroups,
                        ]
                    ):
                        raise ConfigValueError(
                            "Date-based regex must contain groups 'year', 'month' and 'day'"
                        )
                    match.group('year')

                    year = intepret_year(match.group('year'))

                    episodedates = [
                        datetime.date(
                            year, int(match.group('month')), int(match.group('day'))
                        )
                    ]

                else:
                    raise ConfigValueError(
                        "Regex does not contain episode number group, should"
                        "contain episodenumber, episodenumber1-9, or"
                        "episodenumberstart and episodenumberend\n\nPattern"
                        "was:\n" + cmatcher.pattern
                    )

                if 'seriesname' in namedgroups:
                    seriesname = match.group('seriesname')
                else:
                    raise ConfigValueError(
                        "Regex must contain seriesname. Pattern was:\n"
                        + cmatcher.pattern
                    )

                if seriesname is not None:
                    seriesname = _clean_extracted_series_name(seriesname)
                    seriesname = _replace_input_series_name(seriesname)

                extra_values = match.groupdict()

                if 'seasonnumber' in namedgroups:
                    seasonnumber = int(match.group('seasonnumber'))

                    episode = EpisodeInfo(
                        seriesname=seriesname,
                        seasonnumber=seasonnumber,
                        episodenumbers=episodenumbers,
                        filename=self.path,
                        extra=extra_values,
                    ) # type: BaseInfo
                elif (
                    'year' in namedgroups
                    and 'month' in namedgroups
                    and 'day' in namedgroups
                ):
                    episode = DatedEpisodeInfo(
                        seriesname=seriesname,
                        episodenumbers=episodedates, # FIXME: Refactor so this is defined closer to here, prone to name not defined error
                        filename=self.path,
                        extra=extra_values,
                    )
                elif 'group' in namedgroups:
                    episode = AnimeEpisodeInfo(
                        seriesname=seriesname,
                        episodenumbers=episodenumbers,
                        filename=self.path,
                        extra=extra_values,
                    )
                else:
                    # No season number specified, usually for Anime
                    episode = NoSeasonEpisodeInfo(
                        seriesname=seriesname,
                        episodenumbers=episodenumbers,
                        filename=self.path,
                        extra=extra_values,
                    )

                return episode
        else:
            emsg = "Cannot parse %r" % self.path
            if len(Config['input_filename_replacements']) > 0:
                emsg += " with replacements: %r" % filename
            raise InvalidFilename(emsg)
Runs path via configured regex, extracting data from groups.
        Returns an EpisodeInfo instance containing extracted data.
        
tvnamer/files.py