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.

87 lines
2.9KB

  1. # -*- coding: UTF-8 -*-
  2. """
  3. # Class UploadVideoRequest
  4. #
  5. # Aliyun VoD's Upload Video Request class, which wraps parameters to upload a video into VoD.
  6. # Users could pass parameters to AliyunVodUploader, including File Path,Title,etc. via an UploadVideoRequest instance.
  7. # For more details, please check out the VoD API document: https://help.aliyun.com/document_detail/55407.html
  8. """
  9. from vodsdk.AliyunVodUtils import *
  10. class UploadVideoRequest:
  11. def __init__(self, filePath, title=None, fileExt=None):
  12. """
  13. constructor for UploadVideoRequest
  14. :param filePath: string, 文件的绝对路径,或者网络文件的URL,必须含有扩展名
  15. :param title: string, 视频标题,最长128字节,不传则使用文件名为标题
  16. :return
  17. """
  18. self.filePath = None
  19. self.fileName = None
  20. self.mediaExt = None
  21. self.title = None
  22. self.setFilePath(filePath, title, fileExt)
  23. self.cateId = None
  24. self.tags = None
  25. self.description = None
  26. self.coverURL = None
  27. self.templateGroupId = None
  28. self.isShowWatermark = None
  29. self.userData = None
  30. self.storageLocation = None
  31. self.uploadId = None
  32. self.appId = None
  33. self.workflowId = None
  34. def setFilePath(self, filePath, title=None, fileExt=None):
  35. if fileExt is None:
  36. fileExt = AliyunVodUtils.getFileExtension(filePath)
  37. if not fileExt:
  38. raise AliyunVodException('ParameterError', 'InvalidParameter', 'filePath has no Extension')
  39. fileExt = fileExt.lstrip('.')
  40. self.mediaExt = fileExt
  41. self.filePath = AliyunVodUtils.toUnicode(filePath)
  42. briefPath, briefName = AliyunVodUtils.getFileBriefPath(self.filePath)
  43. self.fileName = briefPath
  44. if fileExt and (not self.fileName.endswith('.' + fileExt)):
  45. self.fileName = self.fileName + '.' + fileExt
  46. if title:
  47. self.title = title
  48. else:
  49. if self.title is None:
  50. self.title = briefName
  51. def setCateId(self, cateId):
  52. self.cateId = cateId
  53. def setTags(self, tags):
  54. self.tags = tags
  55. def setDescription(self, description):
  56. self.description = description
  57. def setCoverURL(self, coverURL):
  58. self.coverURL = coverURL
  59. def setTemplateGroupId(self, templateGroupId):
  60. self.templateGroupId = templateGroupId
  61. # 关闭水印,仅用于配置全局水印且转码模板开启水印后,单次上传时关闭水印
  62. def shutdownWatermark(self):
  63. self.isShowWatermark = False
  64. # 设置上传ID,可用于关联导入视频
  65. def setUploadId(self, uploadId):
  66. self.uploadId = uploadId
  67. def setAppId(self, appId):
  68. self.appId = appId
  69. def setWorkflowId(self, workflowId):
  70. self.workflowId = workflowId