response = amspy.get_url(access_token, joboutputassets_uri, False)
if (response.status_code == 200):
    resjson = response.json()
    face_asset_id = resjson['d']['results'][0]['Id']
    print_phase_message("GET Status..............................: " +
                        str(response.status_code))
    print_phase_message("Indexed Media Asset Id..................: " +
                        face_asset_id)
else:
    print_phase_message("GET Status..............................: " +
                        str(response.status_code) +
                        " - Media Job Output Asset: '" + job_id +
                        "' Getting ERROR." + str(response.content))

# Get Asset by using the list_media_asset method and the Asset ID
response = amspy.list_media_asset(access_token, face_asset_id)
if (response.status_code == 200):
    resjson = response.json()
    # Get the container name from the Uri
    outputAssetContainer = resjson['d']['Uri'].split('/')[3]
    print_phase_message(outputAssetContainer)

### Use the Azure Blob Blob Service library from the Azure Storage SDK to download just the output JSON file
block_blob_service = BlockBlobService(account_name=sto_account_name,
                                      account_key=sto_accountKey)
generator = block_blob_service.list_blobs(outputAssetContainer)
for blob in generator:
    print_phase_message(blob.name)
    if (blob.name.endswith(".json")):
        print_phase_message("\n\n##### Output Results ######")
        blobText = block_blob_service.get_blob_to_text(outputAssetContainer,
Example #2
0
response = amspy.get_url(access_token, joboutputassets_uri, False)
if (response.status_code == 200):
    resjson = response.json()
    thumbnail_asset_id = resjson['d']['results'][0]['Id']
    print_phase_message("GET Status..............................: " +
                        str(response.status_code))
    print_phase_message("Thumbnail Media Asset Id................: " +
                        thumbnail_asset_id)
else:
    print_phase_message("GET Status..............................: " +
                        str(response.status_code) +
                        " - Media Job Output Asset: '" + job_id +
                        "' Getting ERROR." + str(response.content))

# Get Asset by using the list_media_asset method and the Asset ID
response = amspy.list_media_asset(access_token, thumbnail_asset_id)
if (response.status_code == 200):
    resjson = response.json()
    # Get the container name from the Uri
    outputAssetContainer = resjson['d']['Uri'].split('/')[3]

### Use the Azure Blob Blob Service library from the Azure Storage SDK to download the Video Thumbnail
block_blob_service = BlockBlobService(account_name=sto_account_name,
                                      account_key=sto_accountKey)
generator = block_blob_service.list_blobs(outputAssetContainer)
for blob in generator:
    print_phase_message("Output File Name........................: " +
                        blob.name)
    block_blob_service.get_blob_to_path(outputAssetContainer, blob.name,
                                        "output/" + blob.name)
Example #3
0
response = amspy.get_url(access_token, joboutputassets_uri, False)
if (response.status_code == 200):
    resjson = response.json()
    output_asset_id = resjson['d']['results'][0]['Id']
    print_phase_message("GET Status..............................: " +
                        str(response.status_code))
    print_phase_message("Indexed output Media Asset Id..................: " +
                        output_asset_id)
else:
    print_phase_message("GET Status..............................: " +
                        str(response.status_code) +
                        " - Media Job Output Asset: '" + job_id +
                        "' Getting ERROR." + str(response.content))

# Get Asset by using the list_media_asset method and the Asset ID
response = amspy.list_media_asset(access_token, output_asset_id)
if (response.status_code == 200):
    resjson = response.json()
    # Get the container name from the Uri
    outputAssetContainer = resjson['d']['Uri'].split('/')[3]
    print(outputAssetContainer)
else:
    print("Not a 200: " + str(response.status_code))
    exit(-1)

### Use the Azure Blob Blob Service library from the Azure Storage SDK to download just the output WebVTT file
block_blob_service = BlockBlobService(account_name=sto_account_name,
                                      account_key=sto_accountKey)
generator = block_blob_service.list_blobs(outputAssetContainer)
for blob in generator:
    print_phase_message("Output File Name........................: " +
Example #4
0
response = amspy.get_url(access_token, joboutputassets_uri, False)
if (response.status_code == 200):
    resjson = response.json()
    motion_asset_id = resjson['d']['results'][0]['Id']
    print_phase_message("GET Status..............................: " +
                        str(response.status_code))
    print_phase_message("Motion Detection Output Asset Id........: " +
                        motion_asset_id)
else:
    print_phase_message("GET Status..............................: " +
                        str(response.status_code) +
                        " - Media Job Output Asset: '" + job_id +
                        "' Getting ERROR." + str(response.content))

# Get Asset by using the list_media_asset method and the Asset ID
response = amspy.list_media_asset(access_token, motion_asset_id)
if (response.status_code == 200):
    resjson = response.json()
    # Get the container name from the Uri
    outputAssetContainer = resjson['d']['Uri'].split('/')[3]
    print_phase_message("Output Asset Name.......................: " +
                        outputAssetContainer)

### Use the Azure Blob Blob Service library from the Azure Storage SDK to download the Motion Detection JSON
block_blob_service = BlockBlobService(account_name=sto_account_name,
                                      account_key=sto_accountKey)
generator = block_blob_service.list_blobs(outputAssetContainer)
for blob in generator:
    print_phase_message("Output File Name........................: " +
                        blob.name)
    if (blob.name.endswith(".json")):
Example #5
0
account_name = configData['accountName']
account_key = configData['accountKey']
sto_account_name = configData['sto_accountName']
sto_accountKey = configData['sto_accountKey']
log_name = configData['logName']
log_level = configData['logLevel']
purge_log = configData['purgeLog']

# Get a fresh API access token...
response = amspy.get_access_token(account_name, account_key)
resjson = response.json()
access_token = resjson["access_token"]

# Get Asset by using the list_media_asset method and the Asset ID
response = amspy.list_media_asset(access_token, OUTPUTASSETID)
if (response.status_code == 200):
    resjson = response.json()
    # Get the container name from the Uri
    outputAssetContainer = resjson['d']['Uri'].split('/')[3]
    print(outputAssetContainer)

### Use the Azure Blob Blob Service library from the Azure Storage SDK.
block_blob_service = BlockBlobService(account_name=sto_account_name,
                                      account_key=sto_accountKey)
generator = block_blob_service.list_blobs(outputAssetContainer)
for blob in generator:
    print(blob.name)
    if (blob.name.endswith(".vtt")):
        blobText = block_blob_service.get_blob_to_text(outputAssetContainer,
                                                       blob.name)
Example #6
0
    print("ERROR: Expecting config.json in current folder")
    sys.exit()

account_name = configData['accountName']
account_key = configData['accountKey']

# Get the access token...
response = amspy.get_access_token(account_name, account_key)
resjson = response.json()
access_token = resjson["access_token"]

#Initialization...
print("\n-----------------------= AMS Py =----------------------")
print("Simple Python Library for Azure Media Services REST API")
print("-------------------------------------------------------\n")

### list assets
print("\n001 >>> Listing Media Assets")
response = amspy.list_media_asset(access_token)
if (response.status_code == 200):
    resjson = response.json()
    print("POST Status.............................: " +
          str(response.status_code))
    for ma in resjson['d']['results']:
        print("Media Asset Name........................: " + ma['Id'])
        print("Media Asset Id..........................: " + ma['Name'])
else:
    print("POST Status.............................: " +
          str(response.status_code) + " - Media Asset Listing ERROR." +
          str(response.content))