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.

114 lines
3.3 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(basePluginsPath):
  27. manager = PluginManagerSingleton.get()
  28. manager.setPluginPlaces(basePluginsPath)
  29. # Define the various categories corresponding to the different
  30. # kinds of plugins you have defined
  31. manager.setCategoriesFilter({
  32. "Interface" : pi.IInterfacePlugin,
  33. "Platform" : pi.IPlatformPlugin,
  34. "Consumer" : pi.IConsumerPlugin,
  35. })
  36. manager.collectPlugins()
  37. def listPlugins():
  38. manager = PluginManagerSingleton.get()
  39. print("The plugins are stored in the following folders:", manager.getPluginLocator().plugins_places)
  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. basePluginsPath = [os.path.dirname(os.path.abspath(__file__)) + "/plugins"]
  51. manager = loadPlugins(basePluginsPath)
  52. options = docopt(__doc__, version=VERSION)
  53. print(options)
  54. if options.get('--list-plugins'):
  55. listPlugins()
  56. exit(0)
  57. print()
  58. print("# Plugins")
  59. #def test_loadPlugins(arg):
  60. # Loop round the plugins and print their names.
  61. print("debug")
  62. print(manager.getAllPlugins())
  63. print("all plugins")
  64. for plugin in manager.getAllPlugins():
  65. print(plugin.name)
  66. # plugin.plugin_object.print_name()
  67. print()
  68. print("# Video")
  69. v = video.Video("/path/to/video")
  70. v.name = "vidéo"
  71. print(v.__dict__)
  72. print(v.thumbnail)
  73. # def startInterface():
  74. # interface = loadPlugins()
  75. #
  76. # options = interface["default"].run() # Do I need this to extract basic cli? like an option "--interface=xxx"
  77. # if options.get('--interface'):
  78. # if interface[options.get('--interface')]:
  79. # options = interface[options.get('--interface')].run(options)
  80. # else:
  81. # options = interface["cli"].run(options)
  82. # options = interface["nfo"].run(options)
  83. #
  84. # def uploadToPlatforms(options):
  85. # platforms = loadPlugins("platform")
  86. # for platform in options.get('--platform'):
  87. # platforms[platform].run(options)
  88. # TODO: REMOVE ME
  89. main()