本文为您提供了服务端 Python SDK 的媒资管理模块的接口调用示例。
接口请求参数和返回参数说明详见获取媒资信息。
# coding:utf-8 from __future__ import print_function from volcengine.vod.models.request.request_vod_pb2 import * from volcengine.vod.VodService import VodService if __name__ == '__main__': # Create a VOD instance in the specified region. # vod_service = VodService('cn-north-1') vod_service = VodService() # Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65646. # The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. # During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. # 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)
接口请求参数和返回参数说明详见更新媒资信息。
# coding:utf-8 from __future__ import print_function from volcengine.vod.models.request.request_vod_pb2 import * from volcengine.vod.VodService import VodService if __name__ == '__main__': # Create a VOD instance in the specified region. # vod_service = VodService('cn-north-1') vod_service = VodService() # Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65646. # The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. # During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. # vod_service.set_ak('your ak') # vod_service.set_sk('your sk') try: req4 = VodUpdateMediaInfoRequest() req4.Vid = 'vid' req4.Title.value = 'title' req4.Description.value = 'description' req4.Tags.value = 'tag1,tag2' req4.ClassificationId.value = 0 resp4 = vod_service.update_media_info(req4) except Exception: raise else: print(resp4) if resp4.ResponseMetadata.Error.Code == '': print('update media info success') else: print(resp4.ResponseMetadata.Error)
接口请求参数和返回参数说明详见修改媒资发布状态。
# coding:utf-8 from __future__ import print_function from volcengine.vod.models.request.request_vod_pb2 import * from volcengine.vod.VodService import VodService if __name__ == '__main__': # Create a VOD instance in the specified region. # vod_service = VodService('cn-north-1') vod_service = VodService() # Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65646. # The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. # During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. # vod_service.set_ak('your ak') # vod_service.set_sk('your sk') try: vid = 'vid' status = 'Unpublished' req3 = VodUpdateMediaPublishStatusRequest() req3.Vid = vid req3.Status = status resp3 = vod_service.update_media_publish_status(req3) except Exception: raise else: print(resp3) if resp3.ResponseMetadata.Error.Code == '': print('update media publish status success') else: print(resp3.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 * if __name__ == '__main__': # Create a VOD instance in the specified region. # vod_service = VodService('cn-north-1') vod_service = VodService() # Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65646. # The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. # During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. # vod_service.set_ak('your ak') # vod_service.set_sk('your sk') try: vids = "vid1,vid2" req13 = VodUpdateMediaStorageClassRequest() req13.Vids = vids req13.FileIds = fileIds req13.StorageClass = "your storage class" req13.CallbackArgs = "your callbackargs" resp13 = vod_service.update_media_storage_class(req13) except Exception: raise else: print(resp13) if resp13.ResponseMetadata.Error.Code == '': print(resp13.Result) else: print(resp13.ResponseMetadata.Error)
接口请求参数和返回参数详见OpenAPI:获取封面候选结果。
# coding:utf-8 from __future__ import print_function from volcengine.vod.models.request.request_vod_pb2 import * from volcengine.vod.VodService import VodService if __name__ == '__main__': # Create a VOD instance in the specified region. # vod_service = VodService('cn-north-1') vod_service = VodService() # Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65646. # The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. # During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. # vod_service.set_ak('your ak') # vod_service.set_sk('your sk') try: vids = 'vid1,vid2' req2 = VodGetRecommendedPosterRequest() req2.Vids = vids resp2 = vod_service.get_recommended_poster(req2) except Exception: raise else: print(resp2) if resp2.ResponseMetadata.Error.Code == '': print(resp2.Result) else: print(resp2.ResponseMetadata.Error)
接口请求参数和返回参数说明详见删除完整媒资。
# coding:utf-8 from __future__ import print_function from volcengine.vod.models.request.request_vod_pb2 import * from volcengine.vod.VodService import VodService if __name__ == '__main__': # Create a VOD instance in the specified region. # vod_service = VodService('cn-north-1') vod_service = VodService() # Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65646. # The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. # During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. # vod_service.set_ak('your ak') # vod_service.set_sk('your sk') try: vids = 'vid1,vid2' callBackArgs = 'CallBackArgs' req5 = VodDeleteMediaRequest() req5.Vids = vids req5.CallbackArgs = callBackArgs resp5 = vod_service.delete_media(req5) except Exception: raise else: print(resp5) if resp5.ResponseMetadata.Error.Code == '': print('delete media info success') else: print(resp5.ResponseMetadata.Error)
接口请求参数和返回参数详见OpenAPI:删除媒体处理输出文件。
# coding:utf-8 from __future__ import print_function from volcengine.vod.models.request.request_vod_pb2 import * from volcengine.vod.VodService import VodService if __name__ == '__main__': # Create a VOD instance in the specified region. # vod_service = VodService('cn-north-1') vod_service = VodService() # Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65646. # The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. # During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. # vod_service.set_ak('your ak') # vod_service.set_sk('your sk') try: vid = 'vid' fileIds = 'fileId1,fileId2' callBackArgs = 'CallBackArgs' req6 = VodDeleteTranscodesRequest() req6.Vid = vid req6.FileIds = fileIds req6.CallbackArgs = callBackArgs resp6 = vod_service.delete_transcodes(req6) except Exception: raise else: print(resp6) if resp6.ResponseMetadata.Error.Code == '': print('delete transcodes info success') else: print(resp6.ResponseMetadata.Error)
接口请求参数和返回参数详见OpenAPI:获取音视频信息。
# coding:utf-8 from __future__ import print_function from volcengine.vod.models.request.request_vod_pb2 import * from volcengine.vod.VodService import VodService if __name__ == '__main__': # Create a VOD instance in the specified region. # vod_service = VodService('cn-north-1') vod_service = VodService() # Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65646. # The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. # During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. # vod_service.set_ak('your ak') # vod_service.set_sk('your sk') try: req7 = VodGetMediaListRequest() req7.SpaceName = 'your space name' req7.Vid = 'your vid' req7.Status = 'Published' #Published/Unpublished req7.Order = 'Desc' #Desc/Asc req7.StartTime = '1999-01-01T00:00:00Z' req7.EndTime = '2021-04-01T00:00:00Z' req7.Offset = '0' req7.PageSize = '10' req7.ClassificationId = 1 resp7 = vod_service.get_media_list(req7) except Exception: raise else: print(resp7) if resp7.ResponseMetadata.Error.Code == '': print(resp7.Result) else: print(resp7.ResponseMetadata.Error)
接口请求参数和返回参数详见OpenAPI:获取字幕文件。
# coding:utf-8 from __future__ import print_function from volcengine.vod.models.request.request_vod_pb2 import * from volcengine.vod.VodService import VodService if __name__ == '__main__': # Create a VOD instance in the specified region. # vod_service = VodService('cn-north-1') vod_service = VodService() # Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65646. # The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. # During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. # 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: print(resp8) if resp8.ResponseMetadata.Error.Code == '': print('get subtitle info list success') else: print(resp8.ResponseMetadata.Error)
接口请求参数和返回参数详见OpenAPI:修改字幕发布状态。
# coding:utf-8 from __future__ import print_function from volcengine.vod.models.request.request_vod_pb2 import * from volcengine.vod.VodService import VodService if __name__ == '__main__': # Create a VOD instance in the specified region. # vod_service = VodService('cn-north-1') vod_service = VodService() # Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65646. # The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. # During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. # vod_service.set_ak('your ak') # vod_service.set_sk('your sk') try: req9 = VodUpdateSubtitleStatusRequest() req9.Vid = 'vid' req9.FileIds = 'fileId1,fileId2' req9.Formats = 'format1,format2' req9.Languages = 'language1,language2' req9.Status = 'Published' #Published/Unpublished resp9 = vod_service.update_subtitle_status(req9) except Exception: raise else: print(resp9) if resp9.ResponseMetadata.Error.Code == '': print('update subtitle status success') else: print(resp9.ResponseMetadata.Error)
接口请求参数和返回参数详见OpenAPI:更新字幕信息。
# coding:utf-8 from __future__ import print_function from volcengine.vod.models.request.request_vod_pb2 import * from volcengine.vod.VodService import VodService if __name__ == '__main__': # Create a VOD instance in the specified region. # vod_service = VodService('cn-north-1') vod_service = VodService() # Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65646. # The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. # During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. # vod_service.set_ak('your ak') # vod_service.set_sk('your sk') try: req10 = VodUpdateSubtitleInfoRequest() req10.Vid = 'vid' req10.FileId = 'fileIds' req10.Format = 'format' req10.Language = 'language' req10.Title.value = 'title' req10.Tag.value = 'tag' resp10 = vod_service.update_subtitle_info(req10) except Exception: raise else: print(resp10) if resp10.ResponseMetadata.Error.Code == '': print('update subtitle info success') else: print(resp10.ResponseMetadata.Error)
接口请求参数和返回参数说明详见获取截图结果。
# coding:utf-8 from __future__ import print_function from volcengine.vod.models.request.request_vod_pb2 import * from volcengine.vod.VodService import VodService if __name__ == '__main__': # Create a VOD instance in the specified region. # vod_service = VodService('cn-north-1') vod_service = VodService() # Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65646. # The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. # During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. # vod_service.set_ak('your ak') # vod_service.set_sk('your sk') try: req12 = VodListSnapshotsRequest() req12.Vid = "your vid" resp12 = vod_service.list_snapshots(req12) except Exception: raise else: print(resp12) if resp12.ResponseMetadata.Error.Code == '': print(resp12.Result) else: print(resp12.ResponseMetadata.Error)
接口请求参数和返回参数说明详见创建视频分类。
# coding:utf-8 from __future__ import print_function from volcengine.vod.models.request.request_vod_pb2 import * from volcengine.vod.VodService import VodService if __name__ == '__main__': # Create a VOD instance in the specified region. # vod_service = VodService('cn-north-1') vod_service = VodService() # Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65646. # The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. # During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. # vod_service.set_ak('your ak') # vod_service.set_sk('your sk') try: req8 = VodCreateVideoClassificationRequest() req8.SpaceName = 'your space' req8.Level = 1 req8.ParentId = 0 req8.Classification = 'your classification' resp8 = vod_service.create_video_classification(req8) except Exception: raise else: print(resp8) if resp8.ResponseMetadata.Error.Code == '': print(resp8.Result) else: print(resp8.ResponseMetadata.Error)
接口请求参数和返回参数说明详见查询视频分类。
# coding:utf-8 from __future__ import print_function from volcengine.vod.models.request.request_vod_pb2 import * from volcengine.vod.VodService import VodService if __name__ == '__main__': # Create a VOD instance in the specified region. # vod_service = VodService('cn-north-1') vod_service = VodService() # Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65646. # The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. # During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. # vod_service.set_ak('your ak') # vod_service.set_sk('your sk') try: req11 = VodListVideoClassificationsRequest() req11.SpaceName = 'your space' req11.ClassificationId = 0 resp11 = vod_service.list_video_classifications(req11) except Exception: raise else: print(resp11) if resp11.ResponseMetadata.Error.Code == '': print(resp11.Result) else: print(resp11.ResponseMetadata.Error)
接口请求参数和返回参数说明详见更新视频分类。
# coding:utf-8 from __future__ import print_function from volcengine.vod.models.request.request_vod_pb2 import * from volcengine.vod.VodService import VodService if __name__ == '__main__': # Create a VOD instance in the specified region. # vod_service = VodService('cn-north-1') vod_service = VodService() # Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65646. # The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. # During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. # vod_service.set_ak('your ak') # vod_service.set_sk('your sk') try: req9 = VodUpdateVideoClassificationRequest() req9.SpaceName = 'your space' req9.ClassificationId = 0 req9.Classification = 'your classification' resp9 = vod_service.update_video_classification(req9) except Exception: raise else: print(resp9) if resp9.ResponseMetadata.Error.Code == '': print(resp9.Result) else: print(resp9.ResponseMetadata.Error)
接口请求参数和返回参数说明详见删除视频分类。
# coding:utf-8 from __future__ import print_function from volcengine.vod.models.request.request_vod_pb2 import * from volcengine.vod.VodService import VodService if __name__ == '__main__': # Create a VOD instance in the specified region. # vod_service = VodService('cn-north-1') vod_service = VodService() # Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65646. # The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. # During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. # vod_service.set_ak('your ak') # vod_service.set_sk('your sk') try: req10 = VodDeleteVideoClassificationRequest() req10.SpaceName = 'your space' req10.ClassificationId = 0 resp10 = vod_service.delete_video_classification(req10) except Exception: raise else: print(resp10) if resp10.ResponseMetadata.Error.Code == '': print(resp10.Result) else: print(resp10.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 VodListFileMetaInfosByFileNamesRequest if __name__ == '__main__': # Create a VOD instance in the specified region. # vod_service = VodService('cn-north-1') vod_service = VodService() # Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65646. # The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. # During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. # vod_service.set_ak('your ak') # vod_service.set_sk('your sk') try: req = VodListFileMetaInfosByFileNamesRequest() req.SpaceName = 'spacename' req.BucketName = 'bucketname' req.FileNameEncodeds = 'a/b/c/d.jpg' resp = vod_service.list_file_meta_infos_by_file_names(req) except Exception: raise else: print(resp) if resp.ResponseMetadata.Error.Code == '': print(resp.Result) 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 VodGetFileInfosRequest if __name__ == '__main__': # Create a VOD instance in the specified region. # vod_service = VodService('cn-north-1') vod_service = VodService() # Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65646. # The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. # During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. # vod_service.set_ak('your ak') # vod_service.set_sk('your sk') try: req20 = VodGetFileInfosRequest() req20.SpaceName = "SpaceName" # url encode req20.EncodedFileNames = "EncodedFileNames" # non-required param req20.BucketName = "BucketName" req20.NeedDownloadUrl = True req20.DownloadUrlNetworkType = "NetworkType" req20.DownloadUrlExpire = 3600 resp = vod_service.get_file_infos(req20) except Exception: raise else: print(resp) if resp.ResponseMetadata.Error.Code == '': print(resp.Result) else: print(resp.ResponseMetadata.Error) print('*' * 100)