@ -60,7 +60,6 @@ Plugins options:
< interface > Interface plugin to use to provide the video to upload . Select the interface you want to use . If `--file` is provided instead the interface will be the command line .
- - platform = STRING Platforms plugins to use . Usually one platform plugin upload to one platform website ( comma separated list ) ( default : all )
- - consumer = STRING 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 .
Logging options :
- - log = STRING Log level , between debug , info , warning , error , critical . Ignored if - - quiet is set ( default to info )
@ -124,7 +123,7 @@ def loadPlugins(basePluginsPath):
# Define the various categories corresponding to the different
# kinds of plugins you have defined
pluginManager . setCategoriesFilter ( {
pi . PluginTypes . DEFAULT : pi . IPlugin ,
pi . PluginTypes . ALL : pi . IPrismediaBase Plugin ,
pi . PluginTypes . INTERFACE : pi . IInterfacePlugin ,
pi . PluginTypes . PLATFORM : pi . IPlatformPlugin ,
pi . PluginTypes . CONSUMER : pi . IConsumerPlugin ,
@ -143,58 +142,55 @@ def main():
# Helper functionnalities help the user but do not upload anything
if not cli . helperFunctionnality ( options ) :
exit ( 0 ) # TODO: Magic exit code
exit ( os . EX_OK )
video = cli . parseOptions ( options )
videos = [ video ]
if options [ " <interface> " ] :
interface = pluginManager . getPluginByName ( options [ " <interface> " ] , pi . PluginTypes . INTERFACE )
if not interface . plugin_object . prepareOptions ( videos , options ) :
exit ( 0 ) # TODO: Magic exit code
# TODO: Loop through videos and platforms
for v in videos :
if v . path == " " :
if not interface . plugin_object . prepareOptions ( video , options ) :
# The plugin asked to stop execution.
exit ( os . EX_OK )
if options [ " --platform " ] :
platforms = pluginManager . getPluginsOf ( categories = pi . PluginTypes . PLATFORM , name = [ options [ " --platform " ] . split ( " , " ) ] )
else :
platforms = pluginManager . getPluginsOfCategory ( pi . PluginTypes . PLATFORM )
if options [ " --consumer " ] :
consumers = pluginManager . getPluginsOf ( categories = pi . PluginTypes . CONSUMER , name = [ options [ " --consumer " ] . split ( " , " ) ] )
else :
consumers = pluginManager . getPluginsOfCategory ( pi . PluginTypes . CONSUMER )
# Let each plugin check its options before starting any upload
for plugin in [ * platforms , * consumers ] :
print ( " DEBUG: " , plugin . name )
# TODO: Check this is needed or not: in case of no plugin or wrong name maybe the list is empty instead of there being a None value
if plugin is None :
# TODO: log instead to error ? critical ?
print ( " No valid path to a video file has been provided. " )
continue
print ( options )
print ( )
print ( " # Plugins " )
#def test_loadPlugins(arg):
# Loop round the plugins and print their names.
print ( " debug " )
print ( pluginManager . getAllPlugins ( ) )
print ( " all plugins " )
for plugin in pluginManager . getAllPlugins ( ) :
print ( plugin . name )
# plugin.plugin_object.print_name()
print ( )
print ( " # Video " )
v = vid . 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)
# TODO: REMOVE ME
print ( " No plugin installed name ` " + plugin . name + " `. " )
exit ( os . EX_USAGE )
if not plugin . plugin_object . prepareOptions ( video , options ) :
# A plugin found ill formed options, it should have logged the precises infos
print ( plugin . name + " found a malformed option. " )
exit ( os . EX_CONFIG )
if video . path == " " :
# TODO: log instead to error ? critical ?
print ( " No valid path to a video file has been provided. " )
exit ( os . EX_USAGE )
print ( " All options validated, starting uploads onto platforms " )
for platform in platforms :
print ( " Uploading to: " + platform . name )
platform . plugin_object . upload ( video )
print ( " All uploads have been done, calling consumers plugins " )
for consumer in consumers :
print ( " Calling consumer: " + platform . name )
consumer . plugin_object . finished ( video )
main ( )