Example #1
0
    def create_episode(self, string, **kwargs):

        # parse given string and extract episode attributes
        if MultiEpisode.handle(string):
            params = MultiEpisode.extract_from_string(string, **kwargs)
        elif DailyEpisode.handle(string):
            params = DailyEpisode.extract_from_string(string, **kwargs)
        elif SingleEpisode.handle(string):
            params = SingleEpisode.extract_from_string(string, **kwargs)
        else:
            raise InvalidEpisodeString("unable to identify episode type: %r" % string)

            # locate series object.  If series is unknown, create new series
        if type(params["series"]) is not Series:
            sanitized_series = Series.sanitize_series_name(params["series"])
            if sanitized_series in self.watched_series:
                params["series"] = self.watched_series[sanitized_series]
            else:
                params["series"] = Series(params["series"])
        else:
            sanitized_series = params["series"].sanitized_name

        if "quality" not in kwargs:
            if sanitized_series in self.config["tv"]["filter"]:
                params["quality"] = self.config["tv"]["filter"][sanitized_series]["desired_quality"]
            else:
                params["quality"] = self.config["tv"]["library"]["quality"]["desired"]

        if "start_episode" in params:
            return MultiEpisode(**params)
        elif "year" in params:
            return DailyEpisode(**params)
        else:
            return SingleEpisode(**params)
Example #2
0
	def create_episode(self, string, **kwargs):

		# parse given string and extract episode attributes
		if MultiEpisode.handle(string):
			params = MultiEpisode.extract_from_string(string, **kwargs)
		elif SingleEpisode.handle(string):
			params = SingleEpisode.extract_from_string(string, **kwargs)
		elif NzbmatrixDailyEpisode.handle(string):
			params = NzbmatrixDailyEpisode.extract_from_string(string, **kwargs)
		else:
			raise InvalidEpisodeString("unable to identify episode type: %r" % string)

		# locate series object.  If series is unknown, create new series
		sanitized_series = Series.sanitize_series_name(params['series'])
		if sanitized_series in self.watched_series:
			params['series'] = self.watched_series[sanitized_series]
		else:
			params['series'] = Series(params['series'])

		if 'quality' not in kwargs:
			if sanitized_series in self.config['tv']['filter']:
				params['quality'] = self.config['tv']['filter'][sanitized_series]['desired_quality']
			else:
				params['quality'] = self.config['tv']['library']['quality']['desired']

		if 'start_episode' in params:
			return MultiEpisode(**params)
		elif 'year' in params:
			return NzbmatrixDailyEpisode(**params)
		else:
			return SingleEpisode(**params)
Example #3
0
	def extract_from_string(cls, string, **kwargs):
		""" parse given string and extract values necessary to create a new MultiEpisode object """

		# grab the series name
		(kwargs['series'], sep, other) = string.partition(" - ")

		# grab the episode title (if provided)
		(other, sep, kwargs['title']) = other.partition(" - ")

		return MultiEpisode.extract_from_string(other, **kwargs)
Example #4
0
	def extract_from_string(cls, string, **kwargs):
		""" parse given string and extract values necessary to create a new MultiEpisode object """

		# split the given report and extract series name and episode title
		parts = re.split(NEWZBIN_SEPARATOR_REGEX, string, 2)

		other = ''
		if len(parts) > 1:
			kwargs['series'], other = parts[0:2]
			if len(parts) == 3:
				kwargs['title'] = parts[2]

		return MultiEpisode.extract_from_string(other, **kwargs)