I am currently writing the code for an reddit scraper. I wanted to use Sightengine for scanning for inappropriate content within the downloaded videos. I have problems communicating with the api (I cant fully describe it), however – this is the cmd output that I cant fix and am stuck at:
File "C:\Users\Toni\Desktop\Redditvidscraper\redditvidscraper.py", line 14, in <module>
client = sightengine.Client(sightengine_user, sightengine_secret)
AttributeError: module 'sightengine' has no attribute 'Client'
This is my current code:
import sightengine
import os
import requests
import praw
import cv2
import subprocess
# Sightengine API credentials
sightengine_user = "CENSORED"
sightengine_secret = "CENSORED"
# Authenticate with Sightengine API
client = sightengine.Client(sightengine_user, sightengine_secret)
#SKIPPED CODE ----------------------------#
# Check if the video is shorter than 60 seconds
if duration < 60:
print("mp4_lenght=shorter-60s_[codecontinued]")
# Apply workflow on the video
workflow_id = "CENSORED"
video_path = "video.mp4"
response = client.check('workflow', workflow_id, video_path)
print("started_for_searching_unwanted_content")
# Check if the video contains unwanted content
if response['status'] == 'success' and response['media']['status'] == 'success':
if response['media']['warnings']:
print("mp4_content=unwanted")
else:
print("mp4_content=wanted")
else:
print("Error: ", response['status'])
else:
print("mp4_lenght=longer-60s_[codestopped]")
exit()
I tried virtual environments, updating all kind of packages, downloading + setting up SSL and as far as I am concerned this code has no logical or syntax errors its just the communication with this api.
>Solution :
In the github repository for sightengine it says that you should do this to initialize the client:
from sightengine.client import SightengineClient
client = SightengineClient('{api_user}', '{api_secret}')
So in your case you would do this
from sightengine.client import SightengineClient
client = SightengineClient(sightengine_user, sightengine_secret)
It does seem that there was a lack of initialisation which caused the error. Good luck with your project.