# 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() helpers.setup_configuration(arguments) logger = logging.getLogger("stov") helpers.setup_database() helpers.find_youtubedl() program.initialize_sites() if arguments.add: if arguments.site: program.add_subscription(arguments.channel, arguments.searchparameter, arguments.playlist, arguments.site) else: program.add_subscription(arguments.channel, arguments.searchparameter, arguments.playlist) elif arguments.lssites: program.list_sites() elif arguments.list: program.list_subscriptions() elif arguments.deleteid: program.delete_subscription(arguments.deleteid) elif arguments.update is not None: program.update_subscriptions(arguments.update) elif arguments.download is not None: program.download_notify(arguments.download) elif arguments.subscriptionid: program.list_videos(arguments.subscriptionid) elif arguments.catchup: program.catchup(arguments.catchup) elif arguments.cleanup: program.clean_database() elif arguments.enableid: program.change_subscription_state(arguments.enableid, True) elif arguments.disableid: program.change_subscription_state(arguments.disableid, False) elif arguments.license: program.print_license() elif arguments.version: logger.info("1.2") else: parser.print_help() helpers.remove_lock()