我有一个在Ubuntu上运行的python脚本。我想在情感方面找到一份工作。我还需要在mongodb中保存json响应。我在定义api时遇到了麻烦(我尝试了Emotionapi,但我必须定义emotionapi并且不知道如何)并找出如何在mongodb中保存json响应。以下是我的代码。请帮忙。谢谢。
import affectiva
import requests
import json
import youtube_dl
username = 'xxx@xxxx.com'
passwd = 'xxxx'
r = requests.get('https://index.affectiva.com/', auth=(username, passwd))
response_data = r.json
response_text = r.text
print("response: %s" % str(response_data))
print("text: %s" % response_text)
api = ?(username,passwd)
# Upload a file for Processing
filename = 'https://youtu.be/zlg8QmkHPy0'
video = open(filename)
print("filename: %s" % filename)
job_url = api.create_job(filename)['self']
# Get face detection and emotion results
#job_status = api.query_job(job_url)['status']
if status == 'done':
metrics_json = api.results(job_url)
print(metrics_json)
auth=(username,passwd)
headers={"Accept":"application/json"}
uri = 'https://index.affectiva.com/entries/8766564287617093404/representations/1867118/media'
#https://index.affectiva.com/jobs/1819405085186621725
print(requests.get(uri, auth=auth, headers=headers).json())