|
|
@ -0,0 +1,78 @@ |
|
|
|
import pluginInterfaces as pi |
|
|
|
import video as vid |
|
|
|
|
|
|
|
from yapsy.PluginManager import PluginManagerSingleton |
|
|
|
|
|
|
|
def helperFunctionnality(options): |
|
|
|
optionName = "--list-plugins" |
|
|
|
if options.get(optionName): |
|
|
|
_listPlugins() |
|
|
|
return True |
|
|
|
else: |
|
|
|
options.pop(optionName) |
|
|
|
|
|
|
|
optionName = "--hearthbeat" |
|
|
|
if options.get(optionName): |
|
|
|
for plugin in manager.getPluginsOfCategory(pi.PluginTypes.PLATFORM): |
|
|
|
plugin.plugin_object.hearthbeat() |
|
|
|
return True |
|
|
|
else: |
|
|
|
options.pop(optionName) |
|
|
|
|
|
|
|
return False |
|
|
|
|
|
|
|
|
|
|
|
def parseOptions(options): |
|
|
|
video = vid.Video() |
|
|
|
|
|
|
|
video.path = _getOption(options, "--file", video.path) |
|
|
|
video.thumbnail = _getOption(options, "--thumbnail", video.thumbnail) |
|
|
|
video.name = _getOption(options, "--name", video.name) |
|
|
|
video.description = _getOption(options, "--description", video.description) |
|
|
|
video.playlistName = _getOption(options, "--playlist", video.playlistName) |
|
|
|
video.privacy = _getOption(options, "--privacy", video.privacy) |
|
|
|
video.category = _getOption(options, "--category", video.category) |
|
|
|
video.tags = _getOption(options, "--tag", video.tags) |
|
|
|
video.language = _getOption(options, "--language", video.language) |
|
|
|
video.originalDate = _getOption(options, "--original-date", video.originalDate) |
|
|
|
# TODO: set as an object: { "all": date1, "platformX": date2, …}? |
|
|
|
# Maybe the publishAt by platform is better placed in `self.platform` |
|
|
|
# And so publishAt would only contains the global date. |
|
|
|
video.publishAt = _getOption(options, "--publish-at", video.publishAt) |
|
|
|
# TODO: Add a list of licences |
|
|
|
video.licence = _getOption(options, "--licence", video.licence) |
|
|
|
video.disableComments = _getOption(options, "--disable-comments", video.disableComments) |
|
|
|
video.nsfw = _getOption(options, "--nsfw", video.nsfw) |
|
|
|
|
|
|
|
autoOriginalDate = _getOption(options, "--auto-original-date", False) |
|
|
|
if autoOriginalDate: |
|
|
|
raise Exception("Unimplemented!") |
|
|
|
|
|
|
|
return video |
|
|
|
|
|
|
|
|
|
|
|
def _getOption(options, optionName, defaultValue = None): |
|
|
|
value = options.get(optionName) |
|
|
|
options.pop(optionName) |
|
|
|
|
|
|
|
if value is None: |
|
|
|
return defaultValue |
|
|
|
return value |
|
|
|
|
|
|
|
|
|
|
|
def _listPlugins(): |
|
|
|
manager = PluginManagerSingleton.get() |
|
|
|
|
|
|
|
print("The plugins are stored in the following folders:", manager.getPluginLocator().plugins_places) |
|
|
|
|
|
|
|
print("Category:", pi.PluginTypes.INTERFACE.value) |
|
|
|
for plugin in manager.getPluginsOfCategory(pi.PluginTypes.INTERFACE): |
|
|
|
print("\t" + plugin.name) |
|
|
|
|
|
|
|
print("Category:", pi.PluginTypes.PLATFORM.value) |
|
|
|
for plugin in manager.getPluginsOfCategory(pi.PluginTypes.PLATFORM): |
|
|
|
print("\t" + plugin.name) |
|
|
|
|
|
|
|
print("Category:", pi.PluginTypes.CONSUMER.value) |
|
|
|
for plugin in manager.getPluginsOfCategory(pi.PluginTypes.CONSUMER): |
|
|
|
print("\t" + plugin.name) |