import plivo
import requests
import os
AUTH_ID = "<auth_id>"
AUTH_TOKEN = "<auth_token>"
client = plivo.RestClient(AUTH_ID,AUTH_TOKEN)
response = client.recordings.list(
add_time__gt='2023-07-01 00:00:00',
add_time__lt='2023-07-30 00:00:00',
offset=0,
limit=5,
)
print(f"Found {len(response)} recordings.")
# Directory where the recordings will be saved
path = 'recordings'
os.makedirs(path, exist_ok=True)
for i, recording in enumerate(response):
url = recording['recording_url']
print(f"Downloading recording: {url}")
# Download the file
r = requests.get(url)
file_path = os.path.join(path, f'{recording["recording_id"]}.{recording["recording_format"]}')
with open(file_path, 'wb') as f:
f.write(r.content)
print(f"Downloaded file to: {file_path}")