main.py 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. # This file is part of stov, written by Helmut Pozimski 2012-2017.
  2. #
  3. # stov is free software: you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License as published by
  5. # the Free Software Foundation, version 2 of the License.
  6. #
  7. # stov is distributed in the hope that it will be useful,
  8. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. # GNU General Public License for more details.
  11. #
  12. # You should have received a copy of the GNU General Public License
  13. # along with stov. If not, see <http://www.gnu.org/licenses/>.
  14. # -*- coding: utf8 -*-
  15. """ Contains the main function of stov to start the application.
  16. """
  17. import logging
  18. from lib_stov import helpers
  19. from lib_stov import program
  20. def main():
  21. """
  22. Main function
  23. """
  24. helpers.initialize_gettext()
  25. helpers.setup_sighandler()
  26. parser = helpers.parse_arguments()
  27. arguments = parser.parse_args()
  28. helpers.create_lock()
  29. conf = helpers.setup_configuration(arguments)
  30. logger = logging.getLogger("stov")
  31. database = helpers.setup_database(conf)
  32. helpers.find_youtubedl(conf)
  33. if arguments.add:
  34. program.add_subscription(conf, database, arguments.channel,
  35. arguments.searchparameter,
  36. arguments.playlist)
  37. elif arguments.list:
  38. program.list_subscriptions(conf, database)
  39. elif arguments.deleteid:
  40. program.delete_subscription(database, arguments.deleteid)
  41. elif arguments.update:
  42. program.update_subscriptions(database, conf)
  43. elif arguments.download:
  44. program.download_notify(database, conf)
  45. elif arguments.subscriptionid:
  46. program.list_videos(database, conf, arguments.subscriptionid)
  47. elif arguments.catchup:
  48. program.catchup(database, arguments.catchup)
  49. elif arguments.cleanup:
  50. program.clean_database(database, conf)
  51. elif arguments.enableid:
  52. program.change_subscription_state(database, arguments.enableid, True)
  53. elif arguments.disableid:
  54. program.change_subscription_state(database, arguments.disableid, False)
  55. elif arguments.license:
  56. program.print_license()
  57. elif arguments.version:
  58. logger.info("1.0wip")
  59. else:
  60. parser.print_help()
  61. helpers.remove_lock()