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

#!/usr/bin/python
# 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
from docopt import docopt
from yapsy.PluginManager import PluginManagerSingleton
import pluginInterfaces as pi
import os
import logging
# logging.basicConfig(level=logging.DEBUG)
VERSION = "prismedia v1.0.0"
def loadPlugins(basePluginsPath):
manager = PluginManagerSingleton.get()
manager.setPluginPlaces(basePluginsPath)
# Define the various categories corresponding to the different
# kinds of plugins you have defined
manager.setCategoriesFilter({
"Interface" : pi.IInterfacePlugin,
"Platform" : pi.IPlatformPlugin,
"Consumer" : pi.IConsumerPlugin,
})
manager.collectPlugins()
def listPlugins():
manager = PluginManagerSingleton.get()
print("The plugins are stored in the following folders:", manager.getPluginLocator().plugins_places)
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("Category: Consumer")
for plugin in manager.getPluginsOfCategory("Consumer"):
print(plugin.name)
def main():
basePluginsPath = [os.path.dirname(os.path.abspath(__file__)) + "/plugins"]
manager = loadPlugins(basePluginsPath)
options = docopt(__doc__, version=VERSION)
print(options)
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("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():
# 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
main()