python视频网站分类_媒资分类_Python SDK_服务端SDK_视频点播 - 阿里云
初始化客戶端
使用前請(qǐng)先初始化客戶端,請(qǐng)參見
創(chuàng)建分類
調(diào)用AddCategory接口,完成創(chuàng)建分類功能。
接口參數(shù)和返回字段請(qǐng)參見from aliyunsdkvod.request.v20170321 import AddCategoryRequest
def add_category(clt, cateName, parentId=-1):
request = AddCategoryRequest.AddCategoryRequest()
request.set_CateName(cateName)
request.set_ParentId(parentId)
request.set_accept_format('JSON')
response = json.loads(clt.do_action_with_exception(request))
return response
try:
clt = init_vod_client('', '')
addRes = add_category(clt, 'Category Name')
print(json.dumps(addRes, ensure_ascii=False, indent=4))
except Exception as e:
print(e)
print(traceback.format_exc())
修改分類
調(diào)用UpdateCategory接口,完成修改分類功能。
接口參數(shù)和返回字段請(qǐng)參見from aliyunsdkvod.request.v20170321 import UpdateCategoryRequest
def update_category(clt, cateId, cateName):
request = UpdateCategoryRequest.UpdateCategoryRequest()
request.set_CateId(cateId)
request.set_CateName(cateName)
request.set_accept_format('JSON')
response = json.loads(clt.do_action_with_exception(request))
return response
try:
clt = init_vod_client('', '')
updateRes = update_category(clt, '', 'New Category Name')
print(json.dumps(updateRes, ensure_ascii=False, indent=4))
except Exception as e:
print(e)
print(traceback.format_exc())
刪除分類
調(diào)用DeleteCategory接口,完成刪除分類功能。
接口參數(shù)和返回字段請(qǐng)參見from aliyunsdkvod.request.v20170321 import UpdateCategoryRequest
# 刪除視頻分類,同時(shí)會(huì)刪除其下級(jí)分類(包括二級(jí)分類和三級(jí)分類),請(qǐng)慎重操作
def delete_category(clt, cateId):
request = DeleteCategoryRequest.DeleteCategoryRequest()
request.set_CateId(cateId)
request.set_accept_format('JSON')
response = json.loads(clt.do_action_with_exception(request))
return response
try:
clt = init_vod_client('', '')
delRes = delete_category(clt, '')
print(json.dumps(delRes, ensure_ascii=False, indent=4))
except Exception as e:
print(e)
print(traceback.format_exc())
查詢分類及其子分類
調(diào)用GetCategories接口,完成查詢分類及其子分類功能。
接口參數(shù)和返回字段請(qǐng)參見from aliyunsdkvod.request.v20170321 import GetCategoriesRequest
def get_categories(clt, cateId=-1, pageNo=1, pageSize=10):
request = GetCategoriesRequest.GetCategoriesRequest()
request.set_CateId(cateId)
request.set_PageNo(pageNo)
request.set_PageSize(pageSize)
request.set_accept_format('JSON')
response = json.loads(clt.do_action_with_exception(request))
return response
try:
clt = init_vod_client('', '')
getRes = get_categories(clt, '')
print(json.dumps(getRes, ensure_ascii=False, indent=4))
except Exception as e:
print(e)
print(traceback.format_exc())
總結(jié)
以上是生活随笔為你收集整理的python视频网站分类_媒资分类_Python SDK_服务端SDK_视频点播 - 阿里云的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: poi java 其他_让POI架起Ja
- 下一篇: 圆平移后的方程变化_平移法解题