Пример #1
0
    def test_clean_series_name(self):
        self.CONF.set_override('input_series_replacements', dict())

        self.assertIsNone(formatter.clean_series_name(None))
        self.assertEqual(formatter.clean_series_name(''), '')

        name = 'an.example.1.0.test'
        self.assertEqual(formatter.clean_series_name(name),
                         'an example 1.0 test')

        name = 'an_example_1.0_test'
        self.assertEqual(formatter.clean_series_name(name),
                         'an example 1.0 test')
Пример #2
0
    def test_clean_series_name(self):
        self.CONF.set_override('input_series_replacements', dict())

        self.assertIsNone(formatter.clean_series_name(None))
        self.assertEqual(formatter.clean_series_name(''), '')

        name = 'an.example.1.0.test'
        self.assertEqual(formatter.clean_series_name(name),
                         'an example 1.0 test')

        name = 'an_example_1.0_test'
        self.assertEqual(formatter.clean_series_name(name),
                         'an example 1.0 test')
Пример #3
0
    def parse(self):
        """Extracts component keys from filename.

        :raises tvrenamer.exceptions.InvalidFilename:
            when filename was not parseable
        :raises tvrenamer.exceptions.ConfigValueError:
            when regex used for parsing was incorrectly configured
        """

        self.clean_name = formatter.apply_replacements(
            self.name, cfg.CONF.input_filename_replacements)

        output = parser.parse_filename(self.clean_name)

        if output is None:
            self.messages.append(
                'Invalid filename: unable to parse {0}'.format(
                    self.clean_name))
            LOG.info(self.messages[-1])
            raise exc.InvalidFilename(self.messages[-1])

        self.episode_numbers = output.get('episode_numbers')
        if self.episode_numbers is None:
            self.messages.append(
                'Regex does not contain episode number group, '
                'should contain episodenumber, episodenumber1-9, '
                'or episodenumberstart and episodenumberend\n\n'
                'Pattern was:\n' + output.get('pattern'))
            LOG.info(self.messages[-1])
            raise exc.ConfigValueError(self.messages[-1])

        self.series_name = output.get('series_name')
        if self.series_name is None:
            self.messages.append(
                'Regex must contain seriesname. Pattern was:\n' +
                output.get('pattern'))
            LOG.info(self.messages[-1])
            raise exc.ConfigValueError(self.messages[-1])

        self.series_name = formatter.clean_series_name(self.series_name)
        self.season_number = output.get('season_number')
Пример #4
0
    def parse(self):
        """Extracts component keys from filename.

        :raises tvrenamer.exceptions.InvalidFilename:
            when filename was not parseable
        :raises tvrenamer.exceptions.ConfigValueError:
            when regex used for parsing was incorrectly configured
        """

        self.clean_name = formatter.apply_replacements(
            self.name, cfg.CONF.input_filename_replacements)

        output = parser.parse_filename(self.clean_name)

        if output is None:
            self.messages.append(
                'Invalid filename: unable to parse {0}'.format(
                    self.clean_name))
            LOG.info(self.messages[-1])
            raise exc.InvalidFilename(self.messages[-1])

        self.episode_numbers = output.get('episode_numbers')
        if self.episode_numbers is None:
            self.messages.append(
                'Regex does not contain episode number group, '
                'should contain episodenumber, episodenumber1-9, '
                'or episodenumberstart and episodenumberend\n\n'
                'Pattern was:\n' + output.get('pattern'))
            LOG.info(self.messages[-1])
            raise exc.ConfigValueError(self.messages[-1])

        self.series_name = output.get('series_name')
        if self.series_name is None:
            self.messages.append(
                'Regex must contain seriesname. Pattern was:\n' +
                output.get('pattern'))
            LOG.info(self.messages[-1])
            raise exc.ConfigValueError(self.messages[-1])

        self.series_name = formatter.clean_series_name(self.series_name)
        self.season_number = output.get('season_number')