Kaynağa Gözat

Make the youtube-dl output shown to the user depend on the requested level of output

Helmut Pozimski 11 yıl önce
ebeveyn
işleme
2a11802746
2 değiştirilmiş dosya ile 12 ekleme ve 4 silme
  1. 0 1
      TODO
  2. 12 3
      youtube.py

+ 0 - 1
TODO

@@ -8,6 +8,5 @@ Long term goals:
 * Implement maxvids option
 * Improve handling of situations where a video is permanently unavailable
 * Add verbose output
-* Make youtube-dl output depend on output level
 * Add option to clean database of old entries 
 * Fix Bugs that lead to double subscription entries

+ 12 - 3
youtube.py

@@ -47,9 +47,18 @@ and can't be created. Please check your configuration and try again"),
 		os.chdir(self.__targetdir)
 		if self.downloaded == 0:
 			try:
-				subprocess.check_call(["youtube-dl", "--max-quality=%s" % itag_value, "-t",
-				"http://www.youtube.com/watch?v=%s" % self.ytid],
-				stderr=sys.stderr, stdout=open("/dev/null", "w"))
+				if self.__conf.outputlevel == "default":
+					subprocess.check_call(["youtube-dl", "--max-quality=%s" % itag_value, "-t",
+					"http://www.youtube.com/watch?v=%s" % self.ytid],
+					stderr=sys.stderr, stdout=open("/dev/null", "w"))
+				elif self.__conf.outputlevel == "verbose":
+					subprocess.check_call(["youtube-dl", "--max-quality=%s" % itag_value, "-t",
+					"http://www.youtube.com/watch?v=%s" % self.ytid],
+					stderr=sys.stderr, stdout=sys.stdout)
+				elif self.__conf.outputlevel == "quiet":
+					subprocess.check_call(["youtube-dl", "--max-quality=%s" % itag_value, "-t",
+					"http://www.youtube.com/watch?v=%s" % self.ytid],
+					stderr=open("/dev/null", "w"), stdout=open("/dev/null", "w"))
 				try:
 					self.__database = sqlite3.connect(self.__conf.dbpath)
 				except sqlite3.OperationalError: