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.

72 lines
1.9 KiB

  1. from enum import Enum
  2. from yapsy.IPlugin import IPlugin
  3. class PluginTypes(Enum):
  4. """Plugin Types possibles to instantiate in this program."""
  5. ALL = "All"
  6. INTERFACE = "Interface"
  7. PLATFORM = "Platform"
  8. CONSUMER = "Consumer"
  9. class IPrismediaBasePlugin(IPlugin):
  10. """
  11. Base for prismedias plugin.
  12. """
  13. def prepare_options(self, video, options):
  14. """
  15. Return a falsy value to exit the program.
  16. - `video`: video object to be uploaded
  17. - `options`: a dictionary of options to be used by Prismedia and other plugins
  18. """
  19. raise NotImplementedError("`prepare_options` must be reimplemented by %s" % self)
  20. ###
  21. # Interface
  22. ###
  23. class IInterfacePlugin(IPrismediaBasePlugin):
  24. """
  25. Interface for the Interface plugin category.
  26. """
  27. # TODO: Add callback for communicating upload’s progress to the user
  28. ###
  29. # Platform
  30. ###
  31. class IPlatformPlugin(IPrismediaBasePlugin):
  32. """
  33. Interface for the Platform plugin category.
  34. """
  35. def heartbeat(self):
  36. """
  37. If needed for your platform, use a bit of the api so the platform is aware the keys are still in use.
  38. """
  39. raise NotImplementedError("`heartbeat` must be reimplemented by %s" % self)
  40. def upload(self, video, options):
  41. """
  42. The upload function
  43. """
  44. raise NotImplementedError("`upload` must be reimplemented by %s" % self)
  45. ###
  46. # Consumer
  47. ###
  48. class IConsumerPlugin(IPrismediaBasePlugin):
  49. """
  50. Interface for the Consumer plugin category.
  51. """
  52. def finished(self, video, options):
  53. """
  54. What to do once the uploads are done.
  55. - `video` is an object containing the video details. The `platforms` key contain a list of the platforms the video has been uploaded to and the status
  56. """
  57. raise NotImplementedError("`finished` must be reimplemented by %s" % self)