Sample Code
The following is some sample code that provides examples on performing Search: Custom Database functions:
Performing a search against your Custom Database
#!/usr/bin/env python3
import json
import pex
CLIENT_ID = "#YOUR_CLIENT_ID_HERE"
CLIENT_SECRET = "#YOUR_CLIENT_SECRET_HERE"
INPUT_FILE = "/path/to/file.mp3"
def main():
# Initialize and authenticate the client
client = pex.PrivateSearchClient(CLIENT_ID, CLIENT_SECRET)
# Create an audio fingerprint from input file
ft = client.fingerprint_file(INPUT_FILE, pex.FingerprintType.AUDIO)
# Build a search request
req = pex.PrivateSearchRequest(fingerprint=ft)
# Perform the search against your custom database
result = do_lookup(client, req)
# Print the result
print(json.dumps(result, indent=2))
def do_lookup(client, req):
while True:
try:
# Start the search
future = client.start_search(req)
# Return the result
return future.get()
except pex.Error as err:
# Raise the error if it's not retryable
if not err.is_retryable:
raise err
# Log the error
print(err)
print("retrying lookup...")
# Sleep for 1s or use exponential backoff
time.sleep(1)
# Retry the lookup
continue
if __name__ == '__main__':
main()Ingesting an Asset into your Custom Database
Archiving an Asset in your Custom Database
Listing Assets in your Custom Database
Last updated