Scripting way to upload videos to peertube and youtube
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.

112 lines
3.2 KiB

  1. #!/usr/bin/python
  2. # coding: utf-8
  3. """
  4. prismedia - tool to upload videos to Peertube and Youtube
  5. Usage:
  6. prismedia [--interface=INTERFACE [--help]] [--platforms=PLATFORMS] [--consumers=CONSUMERS]
  7. prismedia --list-plugins
  8. prismedia -h | --help
  9. prismedia --version
  10. Options:
  11. -i --interface=INTERFACE Interface plugin to use. Select the interface you want to use (only one) [default: cli]
  12. -p --platforms=PLATFORMS Platforms plugins to use. Usually one platform plugin upload to one platform website (comma separated list) [default: all]
  13. -c --consumers=CONSUMERS Consumers plugins to use. They are executed after an upload has been done (comma separated list) [default: all]
  14. --list-plugins List all the plugins currently installed by category.
  15. -h --help Show this help.
  16. -V --version Show version.
  17. """
  18. import video
  19. from docopt import docopt
  20. from yapsy.PluginManager import PluginManagerSingleton
  21. import pluginInterfaces as pi
  22. import os
  23. import logging
  24. # logging.basicConfig(level=logging.DEBUG)
  25. VERSION = "prismedia v1.0.0"
  26. def loadPlugins():
  27. manager = PluginManagerSingleton.get()
  28. manager.setPluginPlaces([os.path.dirname(os.path.abspath(__file__)) + "/plugins"])
  29. print(manager.getPluginLocator().plugins_places)
  30. # Define the various categories corresponding to the different
  31. # kinds of plugins you have defined
  32. manager.setCategoriesFilter({
  33. "Interface" : pi.IInterfacePlugin,
  34. "Platform" : pi.IPlatformPlugin,
  35. "Consumer" : pi.IConsumerPlugin,
  36. })
  37. manager.collectPlugins()
  38. def listPlugins():
  39. manager = PluginManagerSingleton.get()
  40. print("Category: Interface")
  41. for plugin in manager.getPluginsOfCategory("Interface"):
  42. print(plugin.name)
  43. print("Category: Platform")
  44. for plugin in manager.getPluginsOfCategory("Platform"):
  45. print(plugin.name)
  46. print("Category: Consumer")
  47. for plugin in manager.getPluginsOfCategory("Consumer"):
  48. print(plugin.name)
  49. def main():
  50. manager = loadPlugins()
  51. options = docopt(__doc__, version=VERSION)
  52. print(options)
  53. if options.get('--list-plugins'):
  54. listPlugins()
  55. exit(0)
  56. print()
  57. print("# Plugins")
  58. #def test_loadPlugins(arg):
  59. # Loop round the plugins and print their names.
  60. print("debug")
  61. print(manager.getAllPlugins())
  62. print("all plugins")
  63. for plugin in manager.getAllPlugins():
  64. print(plugin.name)
  65. # plugin.plugin_object.print_name()
  66. print()
  67. print("# Video")
  68. v = video.Video("/path/to/video")
  69. v.name = "vidéo"
  70. print(v.__dict__)
  71. print(v.thumbnail)
  72. # def startInterface():
  73. # interface = loadPlugins()
  74. #
  75. # options = interface["default"].run() # Do I need this to extract basic cli? like an option "--interface=xxx"
  76. # if options.get('--interface'):
  77. # if interface[options.get('--interface')]:
  78. # options = interface[options.get('--interface')].run(options)
  79. # else:
  80. # options = interface["cli"].run(options)
  81. # options = interface["nfo"].run(options)
  82. #
  83. # def uploadToPlatforms(options):
  84. # platforms = loadPlugins("platform")
  85. # for platform in options.get('--platform'):
  86. # platforms[platform].run(options)
  87. # TODO: REMOVE ME
  88. main()