|
|
@ -2,18 +2,18 @@ |
|
|
|
# coding: utf-8 |
|
|
|
|
|
|
|
# NOTE: Since we use config file to set some defaults values, it is not possible to use the standard syntax with brackets, we use parenthesis instead. |
|
|
|
# If we were to use them we would overide configuration file values with default values of cli. |
|
|
|
# If we were to use them we would override configuration file values with default values of cli. |
|
|
|
# TODO: change `youtube-at` and `peertube-at` that are not easely expendable as options in my opinion |
|
|
|
""" |
|
|
|
prismedia - tool to upload videos to different platforms (historicaly Peertube and Youtube) |
|
|
|
|
|
|
|
Usage: |
|
|
|
prismedia [options] --file=<file> | <interface> |
|
|
|
prismedia --list-plugins | --hearthbeat |
|
|
|
prismedia [options] --file=<file> | [<interface> [<parameters>...]] |
|
|
|
prismedia --hearthbeat |
|
|
|
prismedia -h | --help | -V | --version |
|
|
|
|
|
|
|
Options: |
|
|
|
-f, --file=STRING Path to the video file to upload in mp4. This is the only mandatory option. |
|
|
|
-f, --file=STRING Path to the video file to upload in mp4. This is the only mandatory option except if you provide the name of a plugin interface (see <interface>). |
|
|
|
--thumbnail=STRING Path to a file to use as a thumbnail for the video. |
|
|
|
--name=NAME Name of the video to upload. (default to video filename) |
|
|
|
-d, --description=STRING Description of the video. (default: default description) |
|
|
@ -53,11 +53,11 @@ Options: |
|
|
|
|
|
|
|
--hearthbeat Use some credits to show some activity for you apikey so the platform know it is used and would not inactivate your keys. |
|
|
|
|
|
|
|
-h, --help Show this help. |
|
|
|
-h, --help Show this help. Note that calling `help` without the `--` calls a plugin showing a different help for the plugins. |
|
|
|
-V, --version Show the version. |
|
|
|
|
|
|
|
Plugins options: |
|
|
|
<interface> Interface plugin to use. Select the interface you want to use. By default the interface is the command line. |
|
|
|
<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. |
|
|
@ -118,41 +118,46 @@ import logging |
|
|
|
VERSION = "prismedia v1.0.0-plugins-alpha" |
|
|
|
|
|
|
|
def loadPlugins(basePluginsPath): |
|
|
|
manager = PluginManagerSingleton.get() |
|
|
|
manager.setPluginPlaces(basePluginsPath) |
|
|
|
pluginManager = PluginManagerSingleton.get() |
|
|
|
pluginManager.setPluginPlaces(basePluginsPath) |
|
|
|
|
|
|
|
# Define the various categories corresponding to the different |
|
|
|
# kinds of plugins you have defined |
|
|
|
manager.setCategoriesFilter({ |
|
|
|
pluginManager.setCategoriesFilter({ |
|
|
|
pi.PluginTypes.DEFAULT : pi.IPlugin, |
|
|
|
pi.PluginTypes.INTERFACE : pi.IInterfacePlugin, |
|
|
|
pi.PluginTypes.PLATFORM : pi.IPlatformPlugin, |
|
|
|
pi.PluginTypes.CONSUMER : pi.IConsumerPlugin, |
|
|
|
}) |
|
|
|
|
|
|
|
manager.collectPlugins() |
|
|
|
pluginManager.collectPlugins() |
|
|
|
|
|
|
|
|
|
|
|
def main(): |
|
|
|
basePluginsPath = [os.path.dirname(os.path.abspath(__file__)) + "/plugins"] |
|
|
|
loadPlugins(basePluginsPath) |
|
|
|
manager = PluginManagerSingleton.get() |
|
|
|
pluginManager = PluginManagerSingleton.get() |
|
|
|
|
|
|
|
# TODO: add the arguments’s verification (copy/adapt the Schema table) |
|
|
|
options = docopt(__doc__, version=VERSION) |
|
|
|
|
|
|
|
# Helper functionnalities help the user but do not upload anything |
|
|
|
if cli.helperFunctionnality(options): |
|
|
|
print(options) |
|
|
|
exit(0) # TODO: Magic error code |
|
|
|
if not cli.helperFunctionnality(options): |
|
|
|
exit(0) # TODO: Magic exit code |
|
|
|
|
|
|
|
video = cli.parseOptions(options) |
|
|
|
videos = [video] |
|
|
|
if options["<interface>"]: |
|
|
|
pass # TODO: call the interface the user asked for |
|
|
|
interface = pluginManager.getPluginByName(options["<interface>"], pi.PluginTypes.INTERFACE) |
|
|
|
if not interface.plugin_object.prepareOptions(videos, options): |
|
|
|
exit(0) # TODO: Magic exit code |
|
|
|
|
|
|
|
if video.path is None: |
|
|
|
# TODO: log instead to error ? critical ? |
|
|
|
print("No valid path to a video file has been provided.") |
|
|
|
exit(1) # TODO: Magic error code |
|
|
|
# TODO: Loop through videos and platforms |
|
|
|
for v in videos: |
|
|
|
if v.path == "": |
|
|
|
# TODO: log instead to error ? critical ? |
|
|
|
print("No valid path to a video file has been provided.") |
|
|
|
continue |
|
|
|
|
|
|
|
print(options) |
|
|
|
|
|
|
@ -161,10 +166,10 @@ def main(): |
|
|
|
#def test_loadPlugins(arg): |
|
|
|
# Loop round the plugins and print their names. |
|
|
|
print("debug") |
|
|
|
print(manager.getAllPlugins()) |
|
|
|
print(pluginManager.getAllPlugins()) |
|
|
|
|
|
|
|
print("all plugins") |
|
|
|
for plugin in manager.getAllPlugins(): |
|
|
|
for plugin in pluginManager.getAllPlugins(): |
|
|
|
print(plugin.name) |
|
|
|
# plugin.plugin_object.print_name() |
|
|
|
|
|
|
|