You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

94 lines
2.0 KiB

10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
  1. #!/usr/bin/env python2
  2. # -*- coding: utf-8 -*-
  3. """Youtubedlg __init__ file.
  4. Responsible on how the package looks from the outside.
  5. Example:
  6. In order to load the GUI from a python script.
  7. import youtube_dl_gui
  8. youtube_dl_gui.main()
  9. """
  10. from __future__ import unicode_literals
  11. import sys
  12. import gettext
  13. import os.path
  14. try:
  15. import wx
  16. except ImportError as error:
  17. print error
  18. sys.exit(1)
  19. __packagename__ = "youtube_dl_gui"
  20. # For package use
  21. from .version import __version__
  22. from .info import (
  23. __author__,
  24. __appname__,
  25. __contact__,
  26. __license__,
  27. __projecturl__,
  28. __licensefull__,
  29. __description__,
  30. __descriptionfull__,
  31. )
  32. gettext.install(__packagename__)
  33. from .formats import reload_strings
  34. from .logmanager import LogManager
  35. from .optionsmanager import OptionsManager
  36. from .utils import (
  37. get_config_path,
  38. get_locale_file,
  39. os_path_exists,
  40. YOUTUBEDL_BIN
  41. )
  42. # Set config path and create options and log managers
  43. config_path = get_config_path()
  44. opt_manager = OptionsManager(config_path)
  45. log_manager = None
  46. if opt_manager.options['enable_log']:
  47. log_manager = LogManager(config_path, opt_manager.options['log_time'])
  48. # Set gettext before MainFrame import
  49. # because the GUI strings are class level attributes
  50. locale_dir = get_locale_file()
  51. try:
  52. gettext.translation(__packagename__, locale_dir, [opt_manager.options['locale_name']]).install(unicode=True)
  53. except IOError:
  54. opt_manager.options['locale_name'] = 'en_US'
  55. gettext.install(__packagename__)
  56. reload_strings()
  57. from .mainframe import MainFrame
  58. def main():
  59. """The real main. Creates and calls the main app windows. """
  60. youtubedl_path = os.path.join(opt_manager.options["youtubedl_path"], YOUTUBEDL_BIN)
  61. app = wx.App()
  62. frame = MainFrame(opt_manager, log_manager)
  63. frame.Show()
  64. if opt_manager.options["disable_update"] and not os_path_exists(youtubedl_path):
  65. wx.MessageBox(_("Failed to locate youtube-dl and updates are disabled"), _("Error"), wx.OK | wx.ICON_ERROR)
  66. frame.close()
  67. app.MainLoop()