Пример #1
0
	def index(self, plugin=None, root=None, api_key=None, backup_dir=None, username=None, password=None):
		vars = build_default_template_vars(self._config)

		if cherrypy.request.method == "POST":

			error = ""

			# check if given plugin is already defined
			new = False
			if plugin not in self._config['queue']:
				self._config['queue'][plugin] = {}
				new = True

			queue_data = self._config['queue'][plugin]

			# set root
			if root not in ("", None):
				queue_data['root'] = root

			# set api_key
			if api_key not in ("", None):
				queue_data['api_key'] = api_key

			# set backup_dir
			if backup_dir not in ("", None):
				queue_data['backup_dir'] = backup_dir

			# set username
			if username == "":
				if 'username' in queue_data:
					del queue_data['username']
			else:
				queue_data['username'] = username

			# set password
			if password == "":
				if 'password' in queue_data:
					del queue_data['password']
			else:
				queue_data['password'] = password

			# if no errors were encountered, save the updated
			# config file
			if error == "":
				save_config(self._config)

			# otherwise, remove the new source and continue processing
			elif new:
				del self._config['queue'][label]
				vars['error'] = error

		vars['supported_queues'] = self._config['__SYSTEM__']['__available_queues']
		vars['queue_list'] = self._config['queue'].values()

		t = Template(file=os.path.join(vars['template_dir'], "queue", "index.tmpl"), searchList=[vars])
		return t.respond()
Пример #2
0
	def index(self, generate_sorting_log=None):
		vars = build_default_template_vars(self._config)

		if cherrypy.request.method == "POST":
			if generate_sorting_log is None:
				self._config['logging']['generate_sorting_log'] = False
			else:
				self._config['logging']['generate_sorting_log'] = True

			# write out config to disk
			save_config(self._config)

		vars['generate_sorting_log'] = self._config['logging']['generate_sorting_log']

		t = Template(file=os.path.join(vars['template_dir'], "logging", "index.tmpl"), searchList=[vars])
		return t.respond()
Пример #3
0
	def index(self, allow=None, prefer=None):
		vars = build_default_template_vars(self._config)

		if cherrypy.request.method == "POST":

			self._config['tv']['multiepisode']['allow'] = True if allow else False

			self._config['tv']['multiepisode']['prefer'] = True if prefer else False

			# write out config to disk
			save_config(self._config)

		vars['allow'] = self._config['tv']['multiepisode']['allow']
		vars['prefer'] = self._config['tv']['multiepisode']['prefer']

		t = Template(file=os.path.join(vars['template_dir'], "tv", "multiepisode", "index.tmpl"), searchList=[vars])
		return t.respond()
Пример #4
0
	def index(self, series=None, season=None, title=None, 
		smart_title=None, series_episode=None, daily_episode=None):

		if cherrypy.request.method == "POST":
			self._config['tv']['template']['series'] = series
			self._config['tv']['template']['season'] = season
			self._config['tv']['template']['title'] = title
			self._config['tv']['template']['smart_title'] = smart_title
			self._config['tv']['template']['series_episode'] = series_episode
			self._config['tv']['template']['daily_episode'] = daily_episode
			save_config(self._config)

		vars = build_default_template_vars(self._config)
		vars['series'] = self._config['tv']['template']['series']
		vars['season'] = self._config['tv']['template']['season']
		vars['title'] = self._config['tv']['template']['title']
		vars['smart_title'] = self._config['tv']['template']['smart_title']
		vars['series_episode'] = self._config['tv']['template']['series_episode']
		vars['daily_episode'] = self._config['tv']['template']['daily_episode']
		
		t = Cheetah.Template.Template(file=os.path.join(vars['template_dir'], "tv", "template", "index.tmpl"), searchList=[vars])
		return t.respond()
Пример #5
0
	def index(self, default_timeout=None, source=None, label=None, url=None, category=None, timeout=None):
		vars = build_default_template_vars(self._config)

		if cherrypy.request.method == "POST":

			error = ""
			
			# check if given label already exists
			new = False
			if label not in self._config['source'][source]:
				self._config['source'][source][label] = {}
				new = True

			source_data = self._config['source'][source][label]

			# set url
			if url not in ("", None):
				source_data['url'] = url

			# set category
			if category == "":
				if 'category' in source_data:
					del source_data['category']
			else:
				source_data['category'] = category

			# set timeout
			if timeout == "":
				if 'timeout' in source_data:	
					del source_data['timeout']
			else:
				source_data['timeout'] = timeout

			# if no errors were encountered, save the updated
			# config file
			if error == "":
				save_config(self._config)
			
			# otherwise, remove the new source and continue processing
			elif new:
				del self._config['source'][source][label]
				vars['error'] = error
				

		# get dict of available sources
		available_sources = dict(
			zip(
				self._config['__SYSTEM__']['__available_sources'], 
				self._config['__SYSTEM__']['__available_sources_label']
			)
		)

		vars['default_timeout'] = self._config['source']['default_timeout']
		vars['supported_sources'] = available_sources
		vars['source_list'] = {}

		for plugin in self._config['__SYSTEM__']['__available_sources']:
			current_plugin = []
			if plugin in self._config['source']:
				for label, data in self._config['source'][plugin].items():
					current_plugin.append(
						self._build_template_source(
							plugin,
							available_sources[plugin],
							label, 
							data 
						)
					)
			
			vars['source_list'][available_sources[plugin]] = current_plugin

		t = Template(file=os.path.join(vars['template_dir'], "source", "index.tmpl"), searchList=[vars])
		return t.respond()
Пример #6
0
	def list(self, series=None, skip=None, ignore=None):
		logger = logging.getLogger("mediarover.interface.tv.filter")

		vars = build_default_template_vars(self._config)

		all_filters = {}
		for name in self._config['tv']['filter']:
			clean = Series.sanitize_series_name(name, self._config['tv']['ignore_series_metadata'])
			all_filters[clean] = {
				'name': name,
				'filters': self._config['tv']['filter'][name],
			}

		# build list of template filters
		vars['dir_list'] = []
		for root in self._config['tv']['tv_root']:
			for dir in os.listdir(root):
				if dir.startswith("."):
					continue

				if os.path.isdir(os.path.join(root, dir)):

					# look for existing filters.  If none are found, 
					# build list using default values
					clean = Series.sanitize_series_name(dir, self._config['tv']['ignore_series_metadata'])
					if clean in all_filters:
						filters = self._config['tv']['filter'][all_filters[clean]['name']]
					else:
						filters = build_series_filters(os.path.join(root, dir))
						
						# add current series to all_filters list
						all_filters[clean] = {
							'name': dir,
							'filters': filters
						}

					# generate template filters. Add to all_filters 
					# and template variables
					all_filters[clean]['template'] = self._build_template_filters(dir, os.path.join(root, dir), filters)
					vars['dir_list'].append(all_filters[clean]['template'])

		# add / modify filter
		if cherrypy.request.method == "POST":

			error = ""

			# parse ignore list
			# TODO check for non-integers
			if ignore in ("", None):
				ignore = []
			else:
				ignore = [int(i) for i in ignore.split(",")]

			# check if given series already exists.  If it does, modify 
			# its existing filters.  If not, we need to create a directory
			# on disk
			clean = Series.sanitize_series_name(series, self._config['tv']['ignore_series_metadata'])
			if clean in all_filters and 'template' in all_filters[clean]:
				filters = all_filters[clean]['filters']
				template = all_filters[clean]['template']
				message = "Successfully updated filter for %s" % series

			# create new series directory on disk
			else:
	
				# before creating a directory on disk, check if there are filters for current series
				# if yes, this means that we have some stale filters.  Delete them and proceed
				if clean in all_filters:
					logger.info("Found stale filters for '%s', deleting", series)
					del self._config['tv']['filter'][all_filters[clean]['name']]
					del all_filters[clean]

				# TODO trap exceptions
				path = os.path.join(self._config['tv']['tv_root'][0], series)
				try:
					os.makedirs(path, self._config['tv']['umask'])
				except IOError:
					raise
				else:
					filters = build_series_filters(path)
					template = self._build_template_filters(series, path, filters)
					all_filters[clean] = {
						'name': series,
						'filters': filters,
						'template': template
					}
					vars['dir_list'].append(template)
					message = "Successfully created filter for %s" % series

			# update current filter with new values
			if skip is not None:
				filters['skip'] = template['skip'] = True
			elif filters['skip'] == True:
				filters['skip'] = template['skip'] = False

			if len(ignore):
				filters['ignore'] = template['ignore'] = ignore

			if error == "":
				self._config['tv']['filter'][series] = filters
				save_config(self._config)

			vars['message'] = message
			vars['error'] = error

		# sort filters
		self._sort_filters(vars['dir_list'], 0, len(vars['dir_list'])-1)

		t = Template(file=os.path.join(vars['template_dir'], "tv", "filter", "list.tmpl"), searchList=[vars])
		return t.respond()