|
@ -1,11 +1,15 @@ |
|
|
|
|
|
#!/usr/bin/python |
|
|
|
|
|
# coding: utf-8 |
|
|
|
|
|
|
|
|
|
|
|
import video |
|
|
|
|
|
|
|
|
from yapsy.PluginManager import PluginManager |
|
|
from yapsy.PluginManager import PluginManager |
|
|
import pluginInterfaces as pi |
|
|
import pluginInterfaces as pi |
|
|
import logging |
|
|
import logging |
|
|
|
|
|
|
|
|
# logging.basicConfig(level=logging.DEBUG) |
|
|
# logging.basicConfig(level=logging.DEBUG) |
|
|
|
|
|
|
|
|
def loadPlugins(type): |
|
|
|
|
|
# Load the plugins from the plugin directory. |
|
|
|
|
|
# TODO: subdirectories too? |
|
|
|
|
|
|
|
|
def loadPlugins(): |
|
|
manager = PluginManager() |
|
|
manager = PluginManager() |
|
|
manager.setPluginPlaces(["plugins"]) # TODO: Generate the absolute path |
|
|
manager.setPluginPlaces(["plugins"]) # TODO: Generate the absolute path |
|
|
|
|
|
|
|
@ -14,49 +18,55 @@ def loadPlugins(type): |
|
|
manager.setCategoriesFilter({ |
|
|
manager.setCategoriesFilter({ |
|
|
"Interface" : pi.IInterfacePlugin, |
|
|
"Interface" : pi.IInterfacePlugin, |
|
|
"Platform" : pi.IPlatformPlugin, |
|
|
"Platform" : pi.IPlatformPlugin, |
|
|
|
|
|
"Consumer" : pi.IConsumerPlugin, |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
manager.collectPlugins() |
|
|
manager.collectPlugins() |
|
|
|
|
|
return manager # TODO: Use the singleton PluginManager? |
|
|
|
|
|
|
|
|
# Loop round the plugins and print their names. |
|
|
|
|
|
print("debug") |
|
|
|
|
|
print(manager.getAllPlugins()) |
|
|
|
|
|
|
|
|
|
|
|
print("all plugins") |
|
|
|
|
|
for plugin in manager.getAllPlugins(): |
|
|
|
|
|
plugin.plugin_object.print_name() |
|
|
|
|
|
|
|
|
print("# Plugins") |
|
|
|
|
|
#def test_loadPlugins(arg): |
|
|
|
|
|
manager = loadPlugins() |
|
|
|
|
|
# Loop round the plugins and print their names. |
|
|
|
|
|
print("debug") |
|
|
|
|
|
print(manager.getAllPlugins()) |
|
|
|
|
|
|
|
|
print("Category: Interface") |
|
|
|
|
|
for plugin in manager.getPluginsOfCategory("Interface"): |
|
|
|
|
|
plugin.plugin_object.print_name() |
|
|
|
|
|
|
|
|
print("all plugins") |
|
|
|
|
|
for plugin in manager.getAllPlugins(): |
|
|
|
|
|
print(plugin.name) |
|
|
|
|
|
# plugin.plugin_object.print_name() |
|
|
|
|
|
|
|
|
print("Category: Platform") |
|
|
|
|
|
for plugin in manager.getPluginsOfCategory("Platform"): |
|
|
|
|
|
plugin.plugin_object.print_name() |
|
|
|
|
|
|
|
|
print("Category: Interface") |
|
|
|
|
|
for plugin in manager.getPluginsOfCategory("Interface"): |
|
|
|
|
|
print(plugin.name) |
|
|
|
|
|
# plugin.plugin_object.print_name() |
|
|
|
|
|
|
|
|
# discovered_plugins = { |
|
|
|
|
|
# name: importlib.import_module(name) |
|
|
|
|
|
# for finder, name, ispkg |
|
|
|
|
|
# in pkgutil.iter_modules(["/home/zykino/Documents/0DocPerso/Code/prismedia/plugins"]) |
|
|
|
|
|
# if name.startswith("prismedia_" + type + "_") |
|
|
|
|
|
# } |
|
|
|
|
|
|
|
|
print("Category: Platform") |
|
|
|
|
|
for plugin in manager.getPluginsOfCategory("Platform"): |
|
|
|
|
|
print(plugin.name) |
|
|
|
|
|
# plugin.plugin_object.print_name() |
|
|
|
|
|
|
|
|
#def test_loadPlugins(arg): |
|
|
|
|
|
platforms = loadPlugins("platform") |
|
|
|
|
|
print (platforms) |
|
|
|
|
|
|
|
|
|
|
|
def startInterface(): |
|
|
|
|
|
interface = loadPlugins("interface") |
|
|
|
|
|
|
|
|
|
|
|
options = interface["default"].run() |
|
|
|
|
|
if options.get('--interface'): |
|
|
|
|
|
if interface[options.get('--interface')]: |
|
|
|
|
|
options = interface[options.get('--interface')].run(options) |
|
|
|
|
|
else: |
|
|
|
|
|
options = interface["cli"].run(options) |
|
|
|
|
|
options = interface["nfo"].run(options) |
|
|
|
|
|
|
|
|
|
|
|
def uploadToPlatforms(options): |
|
|
|
|
|
platforms = loadPlugins("platform") |
|
|
|
|
|
for platform in options.get('--platform'): |
|
|
|
|
|
platforms[platform].run(options) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print() |
|
|
|
|
|
print("# Video") |
|
|
|
|
|
v = video.Video("/path/to/video") |
|
|
|
|
|
v.name = "vidéo" |
|
|
|
|
|
print(v.__dict__) |
|
|
|
|
|
print(v.thumbnail) |
|
|
|
|
|
|
|
|
|
|
|
# def startInterface(): |
|
|
|
|
|
# interface = loadPlugins() |
|
|
|
|
|
# |
|
|
|
|
|
# options = interface["default"].run() # Do I need this to extract basic cli? like an option "--interface=xxx" |
|
|
|
|
|
# if options.get('--interface'): |
|
|
|
|
|
# if interface[options.get('--interface')]: |
|
|
|
|
|
# options = interface[options.get('--interface')].run(options) |
|
|
|
|
|
# else: |
|
|
|
|
|
# options = interface["cli"].run(options) |
|
|
|
|
|
# options = interface["nfo"].run(options) |
|
|
|
|
|
# |
|
|
|
|
|
# def uploadToPlatforms(options): |
|
|
|
|
|
# platforms = loadPlugins("platform") |
|
|
|
|
|
# for platform in options.get('--platform'): |
|
|
|
|
|
# platforms[platform].run(options) |