|
@@ -25,6 +25,8 @@ import signal
|
|
|
import argparse
|
|
|
import logging
|
|
|
|
|
|
+from distutils.spawn import find_executable
|
|
|
+
|
|
|
from lib_stov import stov_exceptions
|
|
|
from lib_stov import configuration
|
|
|
from lib_stov import database
|
|
@@ -233,7 +235,7 @@ def setup_configuration(args):
|
|
|
try:
|
|
|
logger.debug(
|
|
|
_("Comparing current and running configuration version."))
|
|
|
- CHECK_RESULT = conf.check_config()
|
|
|
+ check_result = conf.check_config()
|
|
|
except stov_exceptions.ConfigFileReadErrorException as error:
|
|
|
logger.error(error)
|
|
|
sys.exit(1)
|
|
@@ -241,7 +243,7 @@ def setup_configuration(args):
|
|
|
logger.error(error)
|
|
|
sys.exit(1)
|
|
|
else:
|
|
|
- if not CHECK_RESULT:
|
|
|
+ if not check_result:
|
|
|
logger.info(
|
|
|
_("Your configuration needs to be updated, performing"
|
|
|
" update now."))
|
|
@@ -306,3 +308,32 @@ def setup_database(conf):
|
|
|
LOGGER.error(error)
|
|
|
sys.exit(1)
|
|
|
return db
|
|
|
+
|
|
|
+
|
|
|
+def find_youtubedl(conf):
|
|
|
+ """
|
|
|
+ Tries to find youtube-dl and writes it's path to the configuration file
|
|
|
+ :param conf: configuration object
|
|
|
+ :type conf: lib_stov.configuration.Conf
|
|
|
+ """
|
|
|
+ if conf.values["youtube-dl"] == "":
|
|
|
+ youtubedl_path = find_executable("youtube-dl")
|
|
|
+ conf.values["youtube-dl"] = youtubedl_path
|
|
|
+ if os.access(conf.values["youtube-dl"], os.F_OK & os.R_OK & os.X_OK):
|
|
|
+ LOGGER.info(_("Found youtube-dl, writing it's path to the "
|
|
|
+ "configuration file."))
|
|
|
+ LOGGER.debug("Opening configuration file.")
|
|
|
+ try:
|
|
|
+ conf.write_config()
|
|
|
+ except stov_exceptions.ConfigFileWriteErrorException as error:
|
|
|
+ LOGGER.error(error)
|
|
|
+ sys.exit(1)
|
|
|
+ else:
|
|
|
+ LOGGER.error(
|
|
|
+ _("Could not find youtube-dl, it either does not exist, "
|
|
|
+ "is not readable or not executable. Please note that "
|
|
|
+ "youtube-dl is not needed for the program to run but "
|
|
|
+ "is needed to use the download option which won't work "
|
|
|
+ "otherwise. If youtube-dl isn't found automatically, "
|
|
|
+ "you may also enter the path to it in the configuration"
|
|
|
+ " file."))
|