예제 #1
0
# init the argument parsing
parser = argparse.ArgumentParser(prog=sys.argv[0])
parser.add_argument('--list', action='store_true', default=False, help='List all repositories or files in account or repository')
parser.add_argument('--add', action='store_true', default=False, help='Add a repository or file to account or repository')
parser.add_argument('--delete', action='store_true', default=False, help='Delete a repository or file in account or repository')
parser.add_argument('--repo', metavar='<repository name>', type=str, help='Name of repository')
parser.add_argument('--file', metavar='<filename>', type=str, help='File name')
parser.add_argument('--config', metavar='<config filename>', type=str, help='Name and path of account config information file')
parser.add_argument('--account', metavar='<Brightcove Account ID>', type=str, help='Brightcove Account ID to use (if different from ID in config)')

# parse the args
args = parser.parse_args()

# get account info from config file
try:
    account_id, client_id, client_secret, _ = load_account_info(args.config)
except Exception as e:
    print(e)
    sys.exit(2)

# if account ID was provided override the one from config
account_id = args.account or account_id

# create a Delivery System API instance
ds = DeliverySystem(OAuth(account_id=account_id,client_id=client_id, client_secret=client_secret))

# delete one or all subscriptions
if args.delete:
    # delete a file in a repo?
    if args.repo and args.file:
        if args.file=='all':
#!/usr/bin/env python3
import sys
from brightcove.PlayerManagement import PlayerManagement
from brightcove.OAuth import OAuth
from brightcove.utils import load_account_info

# edit details as required
account_id = ''
client_id = ''
client_secret = ''

# get account info from config file
if client_id==account_id==client_secret=='':
	try:
		account_id, client_id, client_secret, _ = load_account_info()
	except Exception as e:
		print(e)
		sys.exit(2)

# create a Player Management API instance
pms = PlayerManagement( OAuth(account_id=account_id,client_id=client_id, client_secret=client_secret) )

# define the default JSON Body
json_body = { 'video_cloud': { 'base_url': 'https://edge-elb.api.brightcove.com/playback/v1/' } }

# list of accounts that need patching
account_list = [ account_id ]

# process all accounts in the accounts list
for account in account_list:
	print(f'Processing players in account ID {account}:')