示例#1
0
	def auto(self, dir):
		# Find all files in the dir
		files = listFiles(os.path.join(settings.MEDIA_DIR, dir))
		
		# Now sort the files alphabetically
		files.sort()

		# Check for pickle file
		temp = files
		for file in files:
			# Check if this file is the pickle file.
			if file == ".pickle":
				# Load this file
				self.pickle = pickle.load(open(os.path.join(settings.MEDIA_DIR, dir, ".pickle"), "rb"))
				temp.remove(file)
		files = temp
		
		# Get rid of files that don't have a media extension
		temp = []
		for file in files:
			found = False
			for extension in self.extensions:
				if file.endswith("." + extension):
					found = True
			if found:
				temp.append(file)
		files = temp
		
		
		# Now make video objects for remaining files
		self.videos = []
		for file in files:
			newVideo = Video()
			newVideo.path = os.path.join(dir, file)
			newVideo.number = files.index(file)
			
			# While we are here, we can check if there are any subs for this video
			if "subs" in listDirs(os.path.join(settings.MEDIA_DIR, dir)):
				for sub in listFiles(os.path.join(settings.MEDIA_DIR, dir, "subs")):
					
					# Check if any of these subs match the video
					if sub.split(".")[0] == file.split(".")[0]:
						
						# Cool, this file has some subtitles
						newVideo.sub_path = os.path.join(settings.MEDIA_DIR, dir, "subs", sub)

			self.videos.append(newVideo)
				
			
		# Make this dir our new path
		self.path = os.path.join(settings.MEDIA_DIR, dir)
		
		# Make sure we note how many files there were.
		self.pickle.num = len(self.videos)
示例#2
0
文件: block.py 项目: bombpersons/MYOT
	def autoAd(self, dir):
		# Find all files in the dir
		files = listFiles(os.path.join(settings.MEDIA_DIR, dir))
		
		# Now sort the files alphabetically
		files.sort()
		
		# Get rid of files that don't have a media extension
		temp = []
		for file in files:
			found = False
			for extension in settings.SERIES_AUTOFIND_EXTENSIONS:
				if file.endswith("." + extension):
					found = True
			if found:
				temp.append(file)
		files = temp
		
		# Now make video objects for remaining files
		self.videos = []
		for file in files:
			newVideo = Video()
			newVideo.path = os.path.join(dir, file)
			newVideo.number = files.index(file)
			self.ads.append(newVideo)
示例#3
0
    def existsInDirectory(self, fileName):
        result = False

        if self.options['directoryToCheckForDuplicates'] != 1:
            return result

        for file in helpers.listFiles(self.options['outputDirectory'], False):
            if helpers.fileNameOnly(file, True) == fileName:
                outputDirectory = self.options['outputDirectory']
                logging.info(
                    f'Skipping. Output file already exists in {outputDirectory}.'
                )
                result = True
                break

        return result