Basic Usage
Core Functionality
Authenticate
The first step is to initialize the SDK client with the credentials that have been provided to you:
# AUTHENTICATE CLIENT
client = pex.PrivateSearchClient("CLIENT_ID", "CLIENT_SECRET")
Generate Fingerprint
First, generate a fingerprint from the media file you. You can either generate a fingerprint to ingest into your custom database or you can generate a fingerprint to initiate a search with.
# CREATE AUDIO FINGERPRINT FROM MEDIA FILE
ft = client.fingerprint_file("/path/to/file.mp3", pex.FingerprintType.AUDIO)
# CREATE MELODY FINGERPRINT FROM MEDIA FILE
ft = client.fingerprint_file("/path/to/file.mp3", pex.FingerprintType.MELODY)
# CREATE VIDEO FINGERPRINT FROM MEDIA FILE
ft = client.fingerprint_file("/path/to/file.mp3", pex.FingerprintType.VIDEO)
# CREATE AUDIO FINGERPRINT FROM BYTE BUFFER HOLDING A MEDIA FILE
ft = client.fingerprint_buffer([]byte, pex.FingerprintType.AUDIO)
# CREATE MELODY FINGERPRINT FROM BYTE BUFFER HOLDING A MEDIA FILE
ft = client.fingerprint_buffer([]byte, pex.FingerprintType.MELODY)
# CREATE VIDEO FINGERPRINT FROM BYTE BUFFER HOLDING A MEDIA FILE
ft = client.fingerprint_buffer([]byte, pex.FingerprintType.VIDEO)
Searching Functionality
Initiate Search
Once the fingerprint has been generated, you are ready to initiate a search:
# BUILD CUSTOM DATABASE SEARCH REQUEST
req = pex.PrivateSearchRequest(fingerprint=ft)
# START SEARCH
future = client.start_search(req)
Retrieve Search Results
Once a search is complete, you can retrieve the results of the search:
# RETRIEVE SEARCH RESULTS
result = future.get()
Interpret Search Results
To view details on what's contained in a search response, please see the following section: Search Response
Catalog Management
Add Fingerprint to Custom Database
Now that the fingerprint has been generated, you can add that fingerprint file to your custom database. You can associate a "custom_id" string of your choosing for each fingerprint (to help you uniquely identify each fingerprint that is in your database):
# ADD FINGERPRINT CUSTOM DATABASE
client.ingest("custom_id", ft)
Archive Fingerprint from your Custom Database
If you would like to remove an asset from your Custom Database so that it can no longer be matched against, you can do so with this command:
# ARCHIVE FINGERPRINT
client.archive("custom_id")
Lists Assets in your Custom Database
If you would like to view what assets are currently in your Custom Database, you can do so with the Lister functionality:
lister = client.list_entries(pex.ListEntriesRequest())
// To limit the number of entries:
// lister = client.list_entries(pex.ListEntriesRequest(limit=5))
while lister.has_next_page:
entries = lister.list()
for entry in entries:
print(entry)
Last updated