def upload_tob(self, space_name, file_path): if not os.path.isfile(file_path): raise Exception("no such file on file path") check_sum = hex(VodService.crc32(file_path))[2:] apply_req = VodApplyUploadInfoRequest() apply_req.SpaceName = space_name resp = self.apply_upload_info(apply_req) if resp.ResponseMetadata.Error.Code != '': print(resp.ResponseMetadata.RequestId) raise Exception(resp.ResponseMetadata.Error) # # TODO 1G以上文件增加Header upload_address = resp.Result.Data.UploadAddress oid = upload_address.StoreInfos[0].StoreUri session_key = upload_address.SessionKey auth = upload_address.StoreInfos[0].Auth host = upload_address.UploadHosts[0] url = 'http://{}/{}'.format(host, oid) headers = {'Content-CRC32': check_sum, 'Authorization': auth} start = time.time() upload_status = False for i in range(3): upload_status, resp = self.put(url, file_path, headers) if upload_status: break else: print(resp) if not upload_status: raise Exception("upload error") cost = (time.time() - start) * 1000 file_size = os.path.getsize(file_path) avg_speed = float(file_size) / float(cost) return oid, session_key, avg_speed
# coding:utf-8 from __future__ import print_function from volcengine.vod.VodService import VodService from volcengine.vod.models.request.request_vod_pb2 import VodGetSubtitleInfoListRequest if __name__ == '__main__': vod_service = VodService() # call below method if you dont set ak and sk in $HOME/.vcloud/config # vod_service.set_ak('your ak') # vod_service.set_sk('your sk') try: req11 = VodGetSubtitleInfoListRequest() req11.Vid = 'vid' token = vod_service.get_subtitle_auth_token(req11, 60) except Exception: raise else: print(token) print('*' * 100)
# coding:utf-8 from __future__ import print_function from volcengine.vod.VodService import VodService from volcengine.vod.models.request.request_vod_pb2 import VodGetPlayInfoRequest if __name__ == '__main__': vod_service = VodService() # call below method if you dont set ak and sk in $HOME/.vcloud/config # vod_service.set_ak('ak') # vod_service.set_sk('sk') try: vid = 'your vid' req = VodGetPlayInfoRequest() req.Vid = vid req.Ssl = '1' req.UnionInfo = 'your unionInfo' resp = vod_service.get_play_info(req) except Exception: raise else: print(resp) if resp.ResponseMetadata.Error.Code == '': print(resp.Result.PlayInfoList[0].MainPlayUrl) else: print(resp.ResponseMetadata.Error) print('*' * 100)
# coding:utf-8 from __future__ import print_function from volcengine.vod.VodService import VodService from volcengine.vod.models.request.request_vod_pb2 import VodQueryUploadTaskInfoRequest if __name__ == '__main__': vod_service = VodService() # call below method if you dont set ak and sk in $HOME/.vcloud/config vod_service.set_ak('your ak') vod_service.set_sk('your sk') jobId = 'url jobId' jobIds = [jobId] comma = ',' s = comma.join(jobIds) req = VodQueryUploadTaskInfoRequest() req.JobIds = s try: resp = vod_service.query_upload_task_info(req) except Exception: raise else: print(resp) if resp.ResponseMetadata.Error.Code == '': print(resp.Result.Data) print(resp.Result.Data.MediaInfoList[0].State) else:
# coding:utf-8 from __future__ import print_function from volcengine.vod.VodService import VodService from volcengine.vod.models.business.vod_workflow_pb2 import WorkflowParams from volcengine.vod.models.request.request_vod_pb2 import VodStartWorkflowRequest if __name__ == '__main__': vod_service = VodService() # call below method if you dont set ak and sk in $HOME/.vcloud/config vod_service.set_ak('your ak') vod_service.set_sk('your sk') try: req = VodStartWorkflowRequest() req.Vid = 'your vid' req.TemplateId = 'your template id' req.Input.MergeFrom(WorkflowParams()) req.Priority = 0 req.CallbackArgs = 'your callback args' resp = vod_service.start_workflow(req) except Exception: raise else: print(resp) if resp.ResponseMetadata.Error.Code == '': print(resp.Result) else: print(resp.ResponseMetadata.Error)
# coding:utf-8 from __future__ import print_function from volcengine.vod.VodService import VodService from volcengine.vod.models.request.request_vod_pb2 import VodGetPrivateDrmPlayAuthRequest if __name__ == '__main__': vod_service = VodService() # call below method if you dont set ak and sk in $HOME/.vcloud/config vod_service.set_ak('your ak') vod_service.set_sk('your sk') try: vid = 'your vid' req = VodGetPrivateDrmPlayAuthRequest() req.Vid = vid req.DrmType = 'your drm type' req.PlayAuthIds = 'a,b,c (your PlayAuthIds)' req.UnionInfo = 'your unionInfo' resp = vod_service.get_private_drm_play_auth(req) except Exception: raise else: print(resp) print('*' * 100)
# coding:utf-8 from __future__ import print_function from volcengine.vod.VodService import VodService if __name__ == '__main__': vod_service = VodService() # call below method if you dont set ak and sk in $HOME/.vcloud/config vod_service.set_ak('your ak') vod_service.set_sk('your sk') try: expireSeconds = 60000 resp = vod_service.get_sha1_hls_drm_auth_token(expireSeconds) except Exception: raise else: print(resp) print('*' * 100)
# coding:utf-8 from __future__ import print_function import json from volcengine.util.Functions import Function from volcengine.vod.VodService import VodService from volcengine.vod.models.request.request_vod_pb2 import VodUploadMediaRequest if __name__ == '__main__': vod_service = VodService() # call below method if you dont set ak and sk in $HOME/.vcloud/config vod_service.set_ak('your ak') vod_service.set_sk('your sk') space_name = 'your space name' file_path = 'your file path' get_meta_function = Function.get_meta_func() snapshot_function = Function.get_snapshot_func(2.3) try: req = VodUploadMediaRequest() req.SpaceName = space_name req.FilePath = file_path req.Functions = json.dumps([get_meta_function, snapshot_function]) req.CallbackArgs = '' resp = vod_service.upload_media(req) except Exception:
# coding:utf-8 from __future__ import print_function from volcengine.vod.VodService import VodService if __name__ == '__main__': vod_service = VodService() # call below method if you dont set ak and sk in $HOME/.vcloud/config vod_service.set_ak('your ak') vod_service.set_sk('your sk') sts2 = vod_service.get_upload_sts2_with_expired_time(60 * 60) print(sts2) sts2 = vod_service.get_upload_sts2() print(sts2)
# coding:utf-8 from __future__ import print_function from volcengine.vod.VodService import VodService from volcengine.vod.models.request.request_vod_pb2 import VodApplyUploadInfoRequest if __name__ == '__main__': vod_service = VodService() # call below method if you dont set ak and sk in $HOME/.vcloud/config vod_service.set_ak('your ak') vod_service.set_sk('your sk') space_name = 'your space' try: req = VodApplyUploadInfoRequest() req.SpaceName = space_name resp = vod_service.apply_upload_info(req) except Exception: raise else: print(resp) if resp.ResponseMetadata.Error.Code == '': print(resp.Result.Data) print(resp.Result.Data.UploadAddress.StoreInfos[0].StoreUri) print(resp.Result.Data.UploadAddress.StoreInfos[0].Auth) print(resp.Result.Data.UploadAddress.UploadHosts[0]) print(resp.Result.Data.UploadAddress.SessionKey) else:
# coding:utf-8 from __future__ import print_function from volcengine.vod.VodService import VodService from volcengine.vod.models.request.request_vod_pb2 import * if __name__ == '__main__': vod_service = VodService() # call below method if you dont set ak and sk in $HOME/.vcloud/config # vod_service.set_ak('your ak') # vod_service.set_sk('your sk') try: req8 = VodGetSubtitleInfoListRequest() req8.Vid = 'vid' req8.FileIds = 'fileIds' req8.Formats = 'format' req8.Languages = 'language' req8.LanguageIds = 'languageIds' req8.SubtitleIds = 'subtitleIds' req8.Status = 'Published' #Published/Unpublished req8.Title = 'title' req8.Tag = 'tag' req8.Ssl = 'ssl' req8.Offset = 'offset' req8.PageSize = 'pageSize' resp8 = vod_service.get_subtitle_info_list(req8) except Exception: raise else:
# coding:utf-8 from __future__ import print_function import json from volcengine.util.Functions import Function from volcengine.vod.VodService import VodService from volcengine.const.Const import * from volcengine.vod.models.request.request_vod_pb2 import VodUploadMaterialRequest if __name__ == '__main__': vod_service = VodService() # call below method if you dont set ak and sk in $HOME/.vcloud/config vod_service.set_ak('your ak') vod_service.set_sk('your sk') space_name = 'your space name' file_path = 'your file path' get_meta_function = Function.get_meta_func() snapshot_function = Function.get_snapshot_func(2.3) add_option_function = Function.get_add_option_info_func(title='素材测试视频', tags='test', description='素材测试,视频文件', category=CATEGORY_VIDEO, record_type=2, format_input='MP4') try: req = VodUploadMaterialRequest() req.FileType = FILE_TYPE_MEDIA req.SpaceName = space_name req.FilePath = file_path req.Functions = json.dumps([get_meta_function, snapshot_function, add_option_function])
# coding:utf-8 from __future__ import print_function from volcengine.vod.VodService import VodService from volcengine.vod.models.request.request_vod_pb2 import VodGetPlayInfoRequest if __name__ == '__main__': vod_service = VodService() # call below method if you dont set ak and sk in $HOME/.vcloud/config vod_service.set_ak('your ak') vod_service.set_sk('your sk') try: vid = 'your vid' req = VodGetPlayInfoRequest() req.Vid = vid expire = 60 # seconds resp = vod_service.get_play_auth_token(req, expire) except Exception: raise else: print(resp) print('*' * 100)
# coding:utf-8 from __future__ import print_function from volcengine.vod.VodService import VodService from volcengine.vod.models.request.request_vod_pb2 import VodGetMediaInfosRequest, VodGetRecommendedPosterRequest, \ VodUpdateMediaPublishStatusRequest, VodUpdateMediaInfoRequest, VodDeleteMediaRequest, VodDeleteTranscodesRequest, \ VodGetSubtitleInfoListRequest, VodUpdateSubtitleStatusRequest, VodUpdateSubtitleInfoRequest, VodGetMediaListRequest if __name__ == '__main__': vod_service = VodService() # call below method if you dont set ak and sk in $HOME/.vcloud/config # vod_service.set_ak('your ak') # vod_service.set_sk('your sk') try: vids = 'vid1,vid2' req = VodGetMediaInfosRequest() req.Vids = vids resp = vod_service.get_media_infos(req) except Exception: raise else: print(resp) if resp.ResponseMetadata.Error.Code == '': print(resp.Result) else: print(resp.ResponseMetadata.Error) print('*' * 100) try: vids = 'vid1,vid2'