python Dynamic Ingest的Python脚本
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python Dynamic Ingest的Python脚本相关的知识,希望对你有一定的参考价值。
#!/usr/bin/env python
import sys
import requests
import json
import argparse
pub_id = "***ACCOUNT ID HERE****"
client_id = "***CLIENT ID HERE****"
client_secret = "***CLIENT SECRET HERE****"
access_token_url = "https://oauth.brightcove.com/v3/access_token"
profiles_base_url = "http://ingestion.api.brightcove.com/v1/accounts/{pubid}/profiles"
def get_access_token():
access_token = None
r = requests.post(access_token_url, params="grant_type=client_credentials", auth=(client_id, client_secret), verify=False)
if r.status_code == 200:
access_token = r.json().get('access_token')
print(access_token)
return access_token
def create_video():
access_token = get_access_token()
headers = { 'Authorization': 'Bearer ' + access_token, "Content-Type": "application/json" }
url = ("https://cms.api.brightcove.com/v1/accounts/{pubid}/videos/").format(pubid=pub_id)
data = '{"name": "***VIDEO TITLE HERE***"}'
r = requests.post(url, headers=headers, data=data)
return r.json()
def submit_pbi(video_id):
access_token = get_access_token()
print access_token
headers = { 'Authorization': 'Bearer ' + access_token, "Content-Type": "application/json" }
url = ("https://ingest.api.brightcove.com/v1/accounts/{pubid}/videos/{videoid}/ingest-requests").format(pubid=pub_id, videoid=video_id)
print url
data = '''{
"master": { "url": "****SOURCE VIDEO URL HERE***" },
}'''
r = requests.post(url, headers=headers, data=data)
print r.headers
return r.json()
v = create_video()
print v
print submit_pbi(v['id'])
以上是关于python Dynamic Ingest的Python脚本的主要内容,如果未能解决你的问题,请参考以下文章
Elasticsearch 集群的哪个节点(master、data、ingest)从 logstash 收集数据?
ES 检索 wordpdf 文档插件 ingest attachment 的管道配置和文档结构映射
雪花 - 雪管天蓝色 blob - auto_ingest 不起作用
ES 检索 wordpdf 文档插件 ingest attachment 的管道配置和文档结构映射
插件 [ingest-geoip] 是为 Elasticsearch 6.2.4 版构建的,但 6.5.0 版正在运行
Elasticsearch:Ingest Pipeline 实践