Example #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)
Example #2
0
	def auto(self, dir):
		#List all dirs
		dirs = listDirs(os.path.join(settings.MEDIA_DIR, dir))
		
		for d in dirs[:]:
			series = Series()
			series.auto(d)
			
			# Check if auto found any files
			if len(series.videos) != 0:
				self.series.append(series)
			
			else:
				dirs.remove(d)