Beispiel #1
0
	# move downloaded file to new location and rename
	if not options.dry_run:

		# build a filesystem episode object
		file = FilesystemEpisode(orig_path, episode, size)
		logger.debug("created %r" % file)

		# determine quality of given job if quality management is turned on
		if config['tv']['quality']['managed']:
			if 'quality' in kwargs:
				episode.quality = kwargs['quality']
			else:
				result = broker['metadata_data_store'].get_in_progress(job)
				if result is None:
					if config['tv']['quality']['guess']:
						episode.quality = guess_quality_level(config, file.extension, episode.quality)
					else:
						logger.info("unable to find quality information in metadata db, assuming default quality level!")
				else:
					episode.quality = result['quality']

		dest_dir = series.locate_season_folder(episode.season)
		if dest_dir is None:
			
			# determine series path
			if len(series.path) == 0:
				root = os.path.join(tv_root[0], series.format(config['tv']['template']['series']))
			else:
				root = series.path[0]

			# get season folder (if desired)
Beispiel #2
0
	def __find_series_episodes(self):
		""" return list of episode objects for current series """
		logger = logging.getLogger("mediarover.series")
		logger.info("scanning filesystem for episodes belonging to '%s'..." % self)

		# duplicate episodes are appended with the date and time that 
		# they were detected.
		dup_regex = re.compile("\.\d{12}$")

		compiled = []
		daily = []
		single = []
		multipart = []

		sanitized_name = self.sanitize_series_name(series=self)
		if sanitized_name in self.config['tv']['filter']:
			desired = self.config['tv']['filter'][sanitized_name]['quality']['desired']
		else:
			desired = self.config['tv']['quality']['desired']

		for root in self.path:
			for dirpath, dirnames, filenames in os.walk(root):
				# skip any directory that start with a '.'
				if os.path.basename(dirpath).startswith('.'):
					continue

				# process files and identify episodes
				for filename in filenames:
					# skip any files that start with a '.'
					if filename.startswith('.'):
						continue

					(name, ext) = os.path.splitext(filename)

					# skip duplicates when building list of episodes
					if dup_regex.search(name):
						continue

					ext = ext.lstrip(".")
					if ext not in self.config['tv']['ignored_extensions']:

						path = os.path.join(dirpath, filename)
						size = os.path.getsize(path)

						# skip this file if it is less than 50 MB
						if size < 52428800:
							continue

						try:
							file = FilesystemEpisode(
								path,
								self.factory.create_episode(name, series=self), 
								size
							)
						except (InvalidEpisodeString, InvalidMultiEpisodeData, MissingParameterError), e:
							logger.warning("skipping file, encountered error while parsing filename: %s (%s)" % (e, path))
							pass
						else:
							episode = file.episode
							list = []

							# multipart
							if hasattr(episode, "episodes"):
								multipart.append(file)

								# now look at individual parts and determine
								# if they should be added to compiled episode list
								list = []
								for ep in episode.episodes:
									if ep not in compiled:
										list.append(ep)
							else:
								list.append(episode)
								if hasattr(episode, "year"):
									daily.append(file)
								else:
									single.append(file)
						
							# add to compiled list
							compiled.extend(list)

							# see if we can come up with a more accurate quality level 
							# for current file
							if len(list) > 0 and self.config['tv']['quality']['managed']:
								record = self.meta_ds.get_episode(list[0])
								if record is None:
									if self.config['tv']['quality']['guess']:
										episode.quality = guess_quality_level(self.config, file.extension, episode.quality)
									else:
										logger.warning("quality level of '%s' unknown, defaulting to desired level of '%s'" % (episode, desired))
								else:
									episode.quality = record['quality']

							logger.debug("created %r" % file)