1
0
Эх сурвалжийг харах

Add basic interactive configuration assistant

Helmut Pozimski 12 жил өмнө
parent
commit
25c9a53a96
4 өөрчлөгдсөн 48 нэмэгдсэн , 8 устгасан
  1. 1 0
      CHANGELOG
  2. 0 3
      TODO
  3. 36 0
      configuration.py
  4. 11 5
      stov.py

+ 1 - 0
CHANGELOG

@@ -5,6 +5,7 @@
 * Added "verbose" and "quiet" output modes
 * Added switch to clean the database of old video entries
 * Added maxfails option and mark videos as permanently failed when that value is reached
+* Added basic interactive configuration (doesn't check if your input makes sense at all!)
 * Implemented MAXVIDEOS configuration option to limit the number of videos retrieved from the youtube API
 * Changed --lsvids to print the download status
 * Made the youtube-dl output shown to the user depend on the defined output level

+ 0 - 3
TODO

@@ -1,6 +1,3 @@
 Long term goals:
 
-* Rethink video and subscription class to cover several video sites
 * Add full german translation
-* Add interactive configuration option
-* Add additional video sites

+ 36 - 0
configuration.py

@@ -50,6 +50,23 @@ class conf(object):
 				"maxresolution": "1080p",
 				"maxfails": "50"
 				}
+
+		self.__explanations = {
+				"database": _("the name of your database file"),
+				"downloaddir": _("the directory where downloaded videos are saved"),
+				"maxvideos": _("the maximum number of videos to retrieve for each subscription"),
+				"mailhost": _("the host of your mail server"),
+				"mailto": _("the address used for notifications"),
+				"mailfrom": _("the sender address of notification e-mails"),
+				"smtpport": _("the port to use on your mail server"),
+				"auth_needed": _("if your mail server requires authentication"),
+				"user_name": _("the user name used to authenticate to your mail server"),
+				"password": _("the password used to authenticate to your mail server"),
+				"youtube-dl": _("the path to your youtube-dl installation"),
+				"notify": _("if you want to be notified via e-mail about new videos"),
+				"videocodec": _("which video codec you prefer (h264, webm or flv)"),
+				"maxresolution": _("which resolution you prefer (360p, 480p, 720p or 1080p)"),
+				}
 		self.dbpath = str(os.environ['HOME']) + "/.stov/" + self.values["database"]
 		self.outputlevel = "default"
 
@@ -261,3 +278,22 @@ class conf(object):
 		printf(_("Found value: %s" % itag_value),
 			outputlevel="verbose", level=self.outputlevel, descriptor="stderr")
 		return itag_value
+
+	def assist(self):
+		""" Ask the user to set all required configuration parameters """
+
+		printf(_("This assistant will help you to perform the initial configuration"
+			" of stov. \nThe default value will be displayed in brackets.\n"
+			"Please specify now :\n"), outputlevel="default", level=self.outputlevel,
+			descriptor="stdout")
+		for value in self.__explanations:
+			printf(_(self.__explanations[value] + " [" + self.values[value] + "]: "),
+				outputlevel="default", level=self.outputlevel, 
+				descriptor="stdout")
+			self.__user_input = raw_input()
+			if self.__user_input != "":
+				self.values[value] = self.__user_input
+		self.dbpath = str(os.environ['HOME']) + "/.stov/" + self.values["database"]
+		self.Initialize()
+		printf(_("Writing initial configuration according to your input, have fun!"),
+			outputlevel="default", level=self.outputlevel, descriptor="stdout")

+ 11 - 5
stov.py

@@ -1,8 +1,8 @@
 #! /usr/bin/env python
 # -*- coding: utf8 -*-
 
-#stov - a program to subscribe to channels and users from online video
-#	portals and download the videos automatically
+#stov - a program to subscribe to channels and users from youtube
+#	and download the videos automatically
 #
 #	written by Helmut Pozimski in 2012
 #
@@ -207,11 +207,17 @@ doesnt, create it using the configuration class.
 
 """
 if os.access(os.environ['HOME'] + "/.stov", os.F_OK & os.W_OK) is not True:
-	printf(_("This seems to be the first time you run the programm, it will now "
-		"create the default configuration for you"),
+	printf(_("This seems to be the first time you run the programm, do you"
+		" want to run the interactive assistant? (yes/no)"),
 		outputlevel="default", level=outputlevel, descriptor="stdout")
 	conf = configuration.conf()
-	conf.Initialize()
+	temp_input = raw_input()
+	if temp_input == "yes":
+		conf.assist()
+	else:
+		printf(_("Writing initial configuration according to default values"),
+			outputlevel="default", level=outputlevel, descriptor="stdout")
+		conf.Initialize()
 else:
 	conf = configuration.conf()
 	if conf.CheckConfig() is not True: