Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Python Sightengine (API) – 'sightengine' has no attribute 'Client' Error

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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)
1 comments

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading