Browse Source

removed all uses of the printf function in the youtube file

Helmut Pozimski 10 years ago
parent
commit
02191ba68f
4 changed files with 19 additions and 10 deletions
  1. 1 1
      lib_stov/configuration.py
  2. 12 0
      lib_stov/stov_exceptions.py
  3. 2 8
      lib_stov/youtube.py
  4. 4 1
      stov

+ 1 - 1
lib_stov/configuration.py

@@ -21,7 +21,7 @@ from __future__ import print_function
 import os
 import subprocess
 
-import stov_exceptions
+from lib_stov import stov_exceptions
 
 
 

+ 12 - 0
lib_stov/stov_exceptions.py

@@ -143,4 +143,16 @@ class SubscriptionDisabledException(Exception):
     def __str__(self):
         return self.__message
 
+class DownloadDirectoryCreationFailedException(Exception):
+    """This exception will be raised when the creation of a subscription
+    directory to download a video failed.
+
+    """
+    def __init__(self):
+        self.__message = _("Download directory does not exist and can't be "
+                           "created. Please check your configuration and try again")
+
+    def __str__(self):
+        return self.__message
+
 

+ 2 - 8
lib_stov/youtube.py

@@ -22,7 +22,7 @@ import os
 import sys
 import subprocess
 
-from lib_stov.outputhelper import printf
+from lib_stov import stov_exceptions
 
 
 class video(object):
@@ -41,19 +41,13 @@ class video(object):
         self.__targetdir = self.__conf.values["downloaddir"] + "/" + directory
         if os.access(self.__targetdir, os.F_OK) is False:
             try:
-                printf(_("Creating directory %s") % self.__targetdir,
-                    outputlevel="verbose", level=self.__conf.outputlevel, descriptor="stderr")
                 os.makedirs(self.__targetdir, 0o750)
             except os.error:
-                printf(_("Download directory does not exist \
-and can't be created. Please check your configuration and try again"),
-                    outputlevel="default", level=self.__conf.outputlevel, descriptor="stderr")
+                raise stov_exceptions.DirectoryCreationFailedException()
 
         os.chdir(self.__targetdir)
         if self.downloaded == 0:
             try:
-                printf(_('Downloading video "%s"') % self.title,
-                    outputlevel="verbose", level=self.__conf.outputlevel, descriptor="stderr")
                 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],

+ 4 - 1
stov

@@ -207,10 +207,13 @@ if options.verbose is True and options.quiet is True:
         "exiting."), outputlevel="default")
     sys.exit(1)
 elif options.verbose is True:
+    outputlevel = "verbose"
     logger.setLevel(logging.DEBUG)
 elif options.quiet is True:
+    outputlevel = "quiet"
     logger.setLevel(logging.ERROR)
 else:
+    outputlevel = "default"
     logger.setLevel(logging.INFO)
 
 """Create the lock file which is used to determine if another instance is
@@ -345,7 +348,7 @@ accordingly.
 TODO: Remove after replacing all occurences of the variable
 """
 
-conf.outputlevel = "default"
+conf.outputlevel = outputlevel
 
 """youtube-dl is really a dependency but the program will run with limited
 functionality without it so we need to check that here