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.

78 lines
2.8 KiB

  1. import pluginInterfaces as pi
  2. import video as vid
  3. from yapsy.PluginManager import PluginManagerSingleton
  4. def helperFunctionnality(options):
  5. optionName = "--list-plugins"
  6. if options.get(optionName):
  7. _listPlugins()
  8. return True
  9. else:
  10. options.pop(optionName)
  11. optionName = "--hearthbeat"
  12. if options.get(optionName):
  13. for plugin in manager.getPluginsOfCategory(pi.PluginTypes.PLATFORM):
  14. plugin.plugin_object.hearthbeat()
  15. return True
  16. else:
  17. options.pop(optionName)
  18. return False
  19. def parseOptions(options):
  20. video = vid.Video()
  21. video.path = _getOption(options, "--file", video.path)
  22. video.thumbnail = _getOption(options, "--thumbnail", video.thumbnail)
  23. video.name = _getOption(options, "--name", video.name)
  24. video.description = _getOption(options, "--description", video.description)
  25. video.playlistName = _getOption(options, "--playlist", video.playlistName)
  26. video.privacy = _getOption(options, "--privacy", video.privacy)
  27. video.category = _getOption(options, "--category", video.category)
  28. video.tags = _getOption(options, "--tag", video.tags)
  29. video.language = _getOption(options, "--language", video.language)
  30. video.originalDate = _getOption(options, "--original-date", video.originalDate)
  31. # TODO: set as an object: { "all": date1, "platformX": date2, …}?
  32. # Maybe the publishAt by platform is better placed in `self.platform`
  33. # And so publishAt would only contains the global date.
  34. video.publishAt = _getOption(options, "--publish-at", video.publishAt)
  35. # TODO: Add a list of licences
  36. video.licence = _getOption(options, "--licence", video.licence)
  37. video.disableComments = _getOption(options, "--disable-comments", video.disableComments)
  38. video.nsfw = _getOption(options, "--nsfw", video.nsfw)
  39. autoOriginalDate = _getOption(options, "--auto-original-date", False)
  40. if autoOriginalDate:
  41. raise Exception("Unimplemented!")
  42. return video
  43. def _getOption(options, optionName, defaultValue = None):
  44. value = options.get(optionName)
  45. options.pop(optionName)
  46. if value is None:
  47. return defaultValue
  48. return value
  49. def _listPlugins():
  50. manager = PluginManagerSingleton.get()
  51. print("The plugins are stored in the following folders:", manager.getPluginLocator().plugins_places)
  52. print("Category:", pi.PluginTypes.INTERFACE.value)
  53. for plugin in manager.getPluginsOfCategory(pi.PluginTypes.INTERFACE):
  54. print("\t" + plugin.name)
  55. print("Category:", pi.PluginTypes.PLATFORM.value)
  56. for plugin in manager.getPluginsOfCategory(pi.PluginTypes.PLATFORM):
  57. print("\t" + plugin.name)
  58. print("Category:", pi.PluginTypes.CONSUMER.value)
  59. for plugin in manager.getPluginsOfCategory(pi.PluginTypes.CONSUMER):
  60. print("\t" + plugin.name)