|
@@ -0,0 +1,67 @@
|
|
|
+# 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 <http://www.gnu.org/licenses/>.
|
|
|
+
|
|
|
+
|
|
|
+# -*- 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)
|
|
|
+ if arguments.add:
|
|
|
+ program.add_subscription(conf, database, arguments.channel,
|
|
|
+ arguments.searchparameter,
|
|
|
+ arguments.playlist)
|
|
|
+ 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.0wip")
|
|
|
+ else:
|
|
|
+ parser.print_help()
|
|
|
+ helpers.remove_lock()
|