# This file is part of stov, written by Helmut Pozimski 2012-2017. # # stov is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, version 2 of the License. # # stov is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with stov. If not, see . # -*- coding: utf8 -*- """ Contains the main function of stov to start the application. """ import logging from lib_stov import helpers from lib_stov import program def main(): """ Main function """ helpers.initialize_gettext() helpers.setup_sighandler() parser = helpers.parse_arguments() arguments = parser.parse_args() helpers.create_lock() conf = helpers.setup_configuration(arguments) logger = logging.getLogger("stov") database = helpers.setup_database(conf) helpers.find_youtubedl(conf) program.initialize_sites(database) if arguments.add: if arguments.site: program.add_subscription(conf, database, arguments.channel, arguments.searchparameter, arguments.playlist, arguments.site) else: program.add_subscription(conf, database, arguments.channel, arguments.searchparameter, arguments.playlist) elif arguments.lssites: program.list_sites(database) elif arguments.list: program.list_subscriptions(conf, database) elif arguments.deleteid: program.delete_subscription(database, arguments.deleteid) elif arguments.update: program.update_subscriptions(database, conf) elif arguments.download: program.download_notify(database, conf) elif arguments.subscriptionid: program.list_videos(database, conf, arguments.subscriptionid) elif arguments.catchup: program.catchup(database, arguments.catchup) elif arguments.cleanup: program.clean_database(database, conf) elif arguments.enableid: program.change_subscription_state(database, arguments.enableid, True) elif arguments.disableid: program.change_subscription_state(database, arguments.disableid, False) elif arguments.license: program.print_license() elif arguments.version: logger.info("1.0rc1") else: parser.print_help() helpers.remove_lock()