当前位置: 首页>>代码示例>>Python>>正文


Python Video.sub_path方法代码示例

本文整理汇总了Python中video.Video.sub_path方法的典型用法代码示例。如果您正苦于以下问题:Python Video.sub_path方法的具体用法?Python Video.sub_path怎么用?Python Video.sub_path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在video.Video的用法示例。


在下文中一共展示了Video.sub_path方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: auto

# 需要导入模块: from video import Video [as 别名]
# 或者: from video.Video import sub_path [as 别名]
	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)
开发者ID:bombpersons,项目名称:MYOT,代码行数:56,代码来源:series.py


注:本文中的video.Video.sub_path方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。