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.

68 lines
2.7 KiB

  1. import pluginInterfaces as pi
  2. import utils
  3. import configuration
  4. class Cli(pi.IInterfacePlugin):
  5. """
  6. This is the default interface plugin. It is used when no interface plugin is specified.
  7. Its core functionality is available as a function call to `prepare_options(video, options)` if you do not need the
  8. Cli object.
  9. This can be useful to let other plugins to rely on the defaults behaviors proposed by this one and extend it.
  10. """
  11. def prepare_options(self, video, options):
  12. prepare_options(video, options)
  13. def prepare_options(video, options):
  14. # TODO: Add the configuration file from the `--nfo` cli argument
  15. _store_docopt_to_configuration(video, options)
  16. _populate_configuration_into_video(video)
  17. def _store_docopt_to_configuration(options):
  18. items = {}
  19. for key, value in options:
  20. if key.startswith("--"):
  21. options.pop(key)
  22. items[key.strip("- ")] = value
  23. configuration.configuration_instance.config_parser.read_dict(items)
  24. def _populate_configuration_into_video(self, video):
  25. config = configuration.configuration_instance
  26. video.path = utils.getOption(config, "file", video.path)
  27. video.thumbnail = utils.getOption(config, "thumbnail", video.thumbnail)
  28. video.name = utils.getOption(config, "name", video.name)
  29. video.description = utils.getOption(config, "description", video.description)
  30. video.playlistName = utils.getOption(config, "playlist", video.playlistName)
  31. video.privacy = utils.getOption(config, "privacy", video.privacy).lower()
  32. video.category = utils.getOption(config, "category", video.category).lower()
  33. tags = utils.getOption(config, "tag", video.tags)
  34. if isinstance(tags, str):
  35. tags = tags.split(",")
  36. video.tags = tags
  37. video.language = utils.getOption(config, "language", video.language).lower()
  38. video.originalDate = utils.getOption(config, "original-date", video.originalDate)
  39. # TODO: set as an object: { "all": date1, "platformX": date2, … }?
  40. # Maybe the publishAt by platform is better placed in `self.platform`
  41. # And so publishAt would only contains the global date.
  42. video.publishAt = utils.getOption(config, "publish-at", video.publishAt)
  43. # TODO: Add a list of licences
  44. video.licence = utils.getOption(config, "licence", video.licence)
  45. video.disableComments = utils.getOption(config, "disable-comments", video.disableComments)
  46. video.nsfw = utils.getOption(config, "nsfw", video.nsfw)
  47. autoOriginalDate = utils.getOption(config, "auto-original-date", False)
  48. if autoOriginalDate:
  49. # TODO: Implement
  50. raise NotImplementedError("auto-original-date functionality is not yet implemented.")
  51. return video