|
@ -1,17 +1,42 @@ |
|
|
#!/usr/bin/python |
|
|
#!/usr/bin/python |
|
|
# coding: utf-8 |
|
|
# coding: utf-8 |
|
|
|
|
|
|
|
|
|
|
|
""" |
|
|
|
|
|
prismedia - tool to upload videos to Peertube and Youtube |
|
|
|
|
|
|
|
|
|
|
|
Usage: |
|
|
|
|
|
prismedia [--interface=INTERFACE [--help]] [--platforms=PLATFORMS] [--consumers=CONSUMERS] |
|
|
|
|
|
prismedia --list-plugins |
|
|
|
|
|
prismedia -h | --help |
|
|
|
|
|
prismedia --version |
|
|
|
|
|
|
|
|
|
|
|
Options: |
|
|
|
|
|
-i --interface=INTERFACE Interface plugin to use. Select the interface you want to use (only one) [default: cli] |
|
|
|
|
|
-p --platforms=PLATFORMS Platforms plugins to use. Usually one platform plugin upload to one platform website (comma separated list) [default: all] |
|
|
|
|
|
-c --consumers=CONSUMERS Consumers plugins to use. They are executed after an upload has been done (comma separated list) [default: all] |
|
|
|
|
|
|
|
|
|
|
|
--list-plugins List all the plugins currently installed by category. |
|
|
|
|
|
|
|
|
|
|
|
-h --help Show this help. |
|
|
|
|
|
-V --version Show version. |
|
|
|
|
|
""" |
|
|
|
|
|
|
|
|
import video |
|
|
import video |
|
|
|
|
|
|
|
|
from yapsy.PluginManager import PluginManager |
|
|
|
|
|
|
|
|
from docopt import docopt |
|
|
|
|
|
from yapsy.PluginManager import PluginManagerSingleton |
|
|
import pluginInterfaces as pi |
|
|
import pluginInterfaces as pi |
|
|
|
|
|
import os |
|
|
import logging |
|
|
import logging |
|
|
|
|
|
|
|
|
# logging.basicConfig(level=logging.DEBUG) |
|
|
# logging.basicConfig(level=logging.DEBUG) |
|
|
|
|
|
|
|
|
|
|
|
VERSION = "prismedia v1.0.0" |
|
|
|
|
|
|
|
|
def loadPlugins(): |
|
|
def loadPlugins(): |
|
|
manager = PluginManager() |
|
|
|
|
|
manager.setPluginPlaces(["plugins"]) # TODO: Generate the absolute path |
|
|
|
|
|
|
|
|
manager = PluginManagerSingleton.get() |
|
|
|
|
|
manager.setPluginPlaces([os.path.dirname(os.path.abspath(__file__)) + "/plugins"]) |
|
|
|
|
|
print(manager.getPluginLocator().plugins_places) |
|
|
|
|
|
|
|
|
# Define the various categories corresponding to the different |
|
|
# Define the various categories corresponding to the different |
|
|
# kinds of plugins you have defined |
|
|
# kinds of plugins you have defined |
|
@ -22,38 +47,50 @@ def loadPlugins(): |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
manager.collectPlugins() |
|
|
manager.collectPlugins() |
|
|
return manager # TODO: Use the singleton PluginManager? |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def listPlugins(): |
|
|
|
|
|
manager = PluginManagerSingleton.get() |
|
|
|
|
|
|
|
|
|
|
|
print("Category: Interface") |
|
|
|
|
|
for plugin in manager.getPluginsOfCategory("Interface"): |
|
|
|
|
|
print(plugin.name) |
|
|
|
|
|
|
|
|
|
|
|
print("Category: Platform") |
|
|
|
|
|
for plugin in manager.getPluginsOfCategory("Platform"): |
|
|
|
|
|
print(plugin.name) |
|
|
|
|
|
|
|
|
print("# Plugins") |
|
|
|
|
|
#def test_loadPlugins(arg): |
|
|
|
|
|
manager = loadPlugins() |
|
|
|
|
|
# Loop round the plugins and print their names. |
|
|
|
|
|
print("debug") |
|
|
|
|
|
print(manager.getAllPlugins()) |
|
|
|
|
|
|
|
|
print("Category: Consumer") |
|
|
|
|
|
for plugin in manager.getPluginsOfCategory("Consumer"): |
|
|
|
|
|
print(plugin.name) |
|
|
|
|
|
|
|
|
print("all plugins") |
|
|
|
|
|
for plugin in manager.getAllPlugins(): |
|
|
|
|
|
print(plugin.name) |
|
|
|
|
|
# plugin.plugin_object.print_name() |
|
|
|
|
|
|
|
|
def main(): |
|
|
|
|
|
manager = loadPlugins() |
|
|
|
|
|
|
|
|
print("Category: Interface") |
|
|
|
|
|
for plugin in manager.getPluginsOfCategory("Interface"): |
|
|
|
|
|
print(plugin.name) |
|
|
|
|
|
# plugin.plugin_object.print_name() |
|
|
|
|
|
|
|
|
options = docopt(__doc__, version=VERSION) |
|
|
|
|
|
print(options) |
|
|
|
|
|
|
|
|
print("Category: Platform") |
|
|
|
|
|
for plugin in manager.getPluginsOfCategory("Platform"): |
|
|
|
|
|
print(plugin.name) |
|
|
|
|
|
# plugin.plugin_object.print_name() |
|
|
|
|
|
|
|
|
if options.get('--list-plugins'): |
|
|
|
|
|
listPlugins() |
|
|
|
|
|
exit(0) |
|
|
|
|
|
|
|
|
|
|
|
print() |
|
|
|
|
|
print("# Plugins") |
|
|
|
|
|
#def test_loadPlugins(arg): |
|
|
|
|
|
# Loop round the plugins and print their names. |
|
|
|
|
|
print("debug") |
|
|
|
|
|
print(manager.getAllPlugins()) |
|
|
|
|
|
|
|
|
print() |
|
|
|
|
|
print("# Video") |
|
|
|
|
|
v = video.Video("/path/to/video") |
|
|
|
|
|
v.name = "vidéo" |
|
|
|
|
|
print(v.__dict__) |
|
|
|
|
|
print(v.thumbnail) |
|
|
|
|
|
|
|
|
print("all plugins") |
|
|
|
|
|
for plugin in manager.getAllPlugins(): |
|
|
|
|
|
print(plugin.name) |
|
|
|
|
|
# plugin.plugin_object.print_name() |
|
|
|
|
|
|
|
|
|
|
|
print() |
|
|
|
|
|
print("# Video") |
|
|
|
|
|
v = video.Video("/path/to/video") |
|
|
|
|
|
v.name = "vidéo" |
|
|
|
|
|
print(v.__dict__) |
|
|
|
|
|
print(v.thumbnail) |
|
|
|
|
|
|
|
|
# def startInterface(): |
|
|
# def startInterface(): |
|
|
# interface = loadPlugins() |
|
|
# interface = loadPlugins() |
|
@ -70,3 +107,6 @@ print(v.thumbnail) |
|
|
# platforms = loadPlugins("platform") |
|
|
# platforms = loadPlugins("platform") |
|
|
# for platform in options.get('--platform'): |
|
|
# for platform in options.get('--platform'): |
|
|
# platforms[platform].run(options) |
|
|
# platforms[platform].run(options) |
|
|
|
|
|
|
|
|
|
|
|
# TODO: REMOVE ME |
|
|
|
|
|
main() |