def test_name(pattern, multi=None, abd=False, sports=False, anime_type=None): ep = generate_sample_ep(multi, abd, sports, anime_type) return { 'name': formatted_filename(ep.show, ep, pattern, multi, anime_type), 'dir': formatted_dir(ep.show, ep, pattern, multi) }
def validate_name(pattern, multi=None, anime_type=None, file_only=False, abd=False, sports=False): """ See if we understand a name :param pattern: Name to analyse :param multi: Is this a multi-episode name :param anime_type: Is this anime :param file_only: Is this just a file or a dir :param abd: Is air-by-date enabled :param sports: Is this sports :return: True if valid name, False if not """ ep = generate_sample_ep(multi, abd, sports, anime_type) new_name = formatted_filename(ep.show, ep, pattern, multi, anime_type) + '.ext' new_path = formatted_dir(ep.show, ep, pattern, multi) if not file_only: new_name = os.path.join(new_path, new_name) if not new_name: sickrage.LOGGER.debug("Unable to create a name out of " + pattern) return False sickrage.LOGGER.debug("Trying to parse " + new_name) parser = NameParser(True, showObj=ep.show, naming_pattern=True) try: result = parser.parse(new_name) except Exception: sickrage.LOGGER.debug("Unable to parse " + new_name + ", not valid") return False sickrage.LOGGER.debug("Parsed " + new_name + " into " + str(result)) if abd or sports: if result.air_date != ep.airdate: sickrage.LOGGER.debug("Air date incorrect in parsed episode, pattern isn't valid") return False elif anime_type != 3: if len(result.ab_episode_numbers) and result.ab_episode_numbers != [x.absolute_number for x in [ep] + ep.relatedEps]: sickrage.LOGGER.debug("Absolute numbering incorrect in parsed episode, pattern isn't valid") return False else: if result.season_number != ep.season: sickrage.LOGGER.debug("Season number incorrect in parsed episode, pattern isn't valid") return False if result.episode_numbers != [x.episode for x in [ep] + ep.relatedEps]: sickrage.LOGGER.debug("Episode numbering incorrect in parsed episode, pattern isn't valid") return False return True
def proper_path(self): """ Figures out the path where this episode SHOULD live according to the renaming rules, relative from the show dir """ anime_type = sickrage.NAMING_ANIME if not self.show.is_anime: anime_type = 3 result = formatted_filename(self.show, self, anime_type=anime_type) # if they want us to flatten it and we're allowed to flatten it then we will if self.show.flatten_folders and not sickrage.NAMING_FORCE_FOLDERS: return result # if not we append the folder on and use that else: result = os.path.join(formatted_dir(self.show, self), result) return result
def validate_name(pattern, multi=None, anime_type=None, file_only=False, abd=False, sports=False): """ See if we understand a name :param pattern: Name to analyse :param multi: Is this a multi-episode name :param anime_type: Is this anime :param file_only: Is this just a file or a dir :param abd: Is air-by-date enabled :param sports: Is this sports :return: True if valid name, False if not """ ep = generate_sample_ep(multi, abd, sports, anime_type) new_name = formatted_filename(ep.show, ep, pattern, multi, anime_type) + '.ext' new_path = formatted_dir(ep.show, ep, pattern, multi) if not file_only: new_name = os.path.join(new_path, new_name) if not new_name: sickrage.LOGGER.debug("Unable to create a name out of " + pattern) return False sickrage.LOGGER.debug("Trying to parse " + new_name) parser = NameParser(True, showObj=ep.show, naming_pattern=True) try: result = parser.parse(new_name) except Exception: sickrage.LOGGER.debug("Unable to parse " + new_name + ", not valid") return False sickrage.LOGGER.debug("Parsed " + new_name + " into " + str(result)) if abd or sports: if result.air_date != ep.airdate: sickrage.LOGGER.debug( "Air date incorrect in parsed episode, pattern isn't valid") return False elif anime_type != 3: if len(result.ab_episode_numbers) and result.ab_episode_numbers != [ x.absolute_number for x in [ep] + ep.relatedEps ]: sickrage.LOGGER.debug( "Absolute numbering incorrect in parsed episode, pattern isn't valid" ) return False else: if result.season_number != ep.season: sickrage.LOGGER.debug( "Season number incorrect in parsed episode, pattern isn't valid" ) return False if result.episode_numbers != [x.episode for x in [ep] + ep.relatedEps]: sickrage.LOGGER.debug( "Episode numbering incorrect in parsed episode, pattern isn't valid" ) return False return True
def test_name(pattern, multi=None, abd=False, sports=False, anime_type=None): ep = generate_sample_ep(multi, abd, sports, anime_type) return {'name': formatted_filename(ep.show, ep, pattern, multi, anime_type), 'dir': formatted_dir(ep.show, ep, pattern, multi)}