Exemplo n.º 1
0
def is_naming_pattern_valid(pattern=None,
                            multi=None,
                            abd=None,
                            sports=None,
                            anime_type=None):
    if pattern is None:
        return 'invalid'

    if anime_type is not None:
        anime_type = int(anime_type)

    # air by date shows just need one check, we don't need to worry about season folders
    if abd:
        is_valid = validator.check_valid_abd_naming(pattern)
        require_season_folders = False

    # sport shows just need one check, we don't need to worry about season folders
    elif sports:
        is_valid = validator.check_valid_sports_naming(pattern)
        require_season_folders = False

    else:
        # check validity of single and multi ep cases for the whole path
        is_valid = validator.check_valid_naming(pattern, multi, anime_type)

        # check validity of single and multi ep cases for only the file name
        require_season_folders = validator.check_force_season_folders(
            pattern, multi, anime_type)

    if is_valid and not require_season_folders:
        return 'valid'
    elif is_valid and require_season_folders:
        return 'seasonfolders'
    else:
        return 'invalid'
Exemplo n.º 2
0
    def get(self, *args, **kwargs):
        pattern = self.get_argument('pattern', None)
        multi = self.get_argument('multi', None)
        abd = self.get_argument('abd', None)
        sports = self.get_argument('sports', None)
        anime_type = self.get_argument('anime_type', None)

        if pattern is None:
            return self.write('invalid')

        if multi is not None:
            multi = int(multi)

        if anime_type is not None:
            anime_type = int(anime_type)

        # air by date shows just need one check, we don't need to worry about season folders
        if abd:
            is_valid = validator.check_valid_abd_naming(pattern)
            require_season_folders = False

        # sport shows just need one check, we don't need to worry about season folders
        elif sports:
            is_valid = validator.check_valid_sports_naming(pattern)
            require_season_folders = False

        else:
            # check validity of single and multi ep cases for the whole path
            is_valid = validator.check_valid_naming(pattern, multi, anime_type)

            # check validity of single and multi ep cases for only the file name
            require_season_folders = validator.check_force_season_folders(pattern, multi, anime_type)

        if is_valid and not require_season_folders:
            return self.write('valid')
        elif is_valid and require_season_folders:
            return self.write('seasonfolders')
        else:
            return self.write('invalid')