Media Resource
Media allows you to retrieve all the files available in api.audio for your organization.
Media Methods
⬆️upload()
upload()
Upload files to our databases.
Parameters:
file_path
*Required (string) - Relative path to the audio file. Note that we only support wav and mp3 files, it is recommended that you upload your files in 44.1 kHz wav.tags
(string) - Comma separated tags you want to add to your uploaded file. This will make retrieval easier.
Example:
response = apiaudio.Media.upload(
file_path="./my_file.mp3",
tags="tag1,tag2,tag3"
)
⬇️list()
list()
List all files within an org
Parameters:
mediaId
(string) - If passed, will only return that file, or an empty object if it does not exist.tags
(string) - Comma separated tags you want to add to your uploaded file. If passed, will return all files that at least contain those tags.downloadUrl
(boolean) - if True, a presigned url is added to each item on the array. This is slow for large amount of files (around 1s each).public
(boolean): If True, the media files listed will be the public media files provided by api.audio. Default is False.
Examples:
# lists all files
files = apiaudio.Media.list()
# lists files with tag="tag1"
files = apiaudio.Media.list(tags="tag1")
# lists file with specific id
files = apiaudio.Media.list(mediaId="some_mediaId")
# lists files with tag="tag1" and with a downloadurl
files = apiaudio.Media.list(tags="tag1", downloadUrl=True)
⬇️list_tags()
list_tags()
This returns a list with all unique user defined tags.
Parameters:
No parameters required
tags = apiaudio.Media.list_tags()
print(tags)
⬇️get_download_url()
get_download_url()
This method returns a presigned url for downloading a specific audio file
Parameters:
mediaId
*Required (string) - media id for the file to be downloaded
Example:
url = apiaudio.Media.get_download_url(mediaId="some-mediaId")
print(url)
⬇️download()
download()
This method downloads a specific audio file
Parameters:
mediaId
*Required (string) - media id for the file to be downloadeddestination
(string) - path to the directory where the file will be downloaded. Default is "."
apiaudio.Media.download(
mediaId="some_mediaId",
destination="/my_destination_folder"
)
⬇️delete()
delete()
This method deletes a file from our database
Parameters:
mediaId
* [Required] (string) - The mediaId of the file you want to delete.
Example:
apiaudio.Media.delete(
mediaId="a45ef2"
)
Updated over 2 years ago