@@ -37,7 +37,7 @@ class Check(object):
3737 def __init__ (self , api_user , api_secret , * args ):
3838 self .api_user = api_user
3939 self .api_secret = api_secret
40- self .endpoint = 'https://api.sightengine.com/'
40+ self .endpoint = 'https://api.sightengine.com/1.0/ '
4141 self .modelsType = ''
4242
4343 if len (args ) > 1 :
@@ -47,36 +47,26 @@ def __init__(self, api_user, api_secret, *args):
4747 else :
4848 self .modelsType = args [0 ]
4949
50- def image (self , image ):
51- numberOfModels = self .modelsType . count ( "," )
50+ def set_url (self , imageUrl ):
51+ r = requests . get ( self .endpoint + 'check.json' , params = { 'models' : self . modelsType , 'url' : imageUrl , 'api_user' : self . api_user , 'api_secret' : self . api_secret }, headers = headers )
5252
53- if numberOfModels > 0 :
54- url = self . endpoint + '1.0/check.json'
53+ output = json . loads ( r . text )
54+ return output
5555
56- if isinstance (image , bytes ):
57- r = requests .post (url , files = {'media' : BytesIO (image )}, data = {'models' : self .modelsType ,'api_user' : self .api_user , 'api_secret' : self .api_secret }, headers = headers )
58- elif image .lower ().startswith (('http://' , 'https://' )):
59- r = requests .get (url , params = {'models' : self .modelsType , 'url' : image , 'api_user' : self .api_user , 'api_secret' : self .api_secret }, headers = headers )
60- else :
61- r = requests .post (url , files = {'media' : open (image , 'rb' )}, data = {'models' : self .modelsType ,'api_user' : self .api_user , 'api_secret' : self .api_secret }, headers = headers )
56+ def set_file (self , file ):
57+ r = requests .post (self .endpoint + 'check.json' , files = {'media' : open (file , 'rb' )}, data = {'models' : self .modelsType , 'api_user' : self .api_user ,'api_secret' : self .api_secret }, headers = headers )
6258
63- output = json .loads (r .text )
64- return output
65- else :
66- url = self .endpoint + '1.0' + '/' + self .modelsType + '.json'
59+ output = json .loads (r .text )
60+ return output
6761
68- if isinstance (image , bytes ):
69- r = requests .post (url , files = {'media' : BytesIO (image )}, data = {'api_user' : self .api_user ,'api_secret' : self .api_secret }, headers = headers )
70- elif image .lower ().startswith (('http://' , 'https://' )):
71- r = requests .get (url , params = {'url' : image , 'api_user' : self .api_user , 'api_secret' : self .api_secret }, headers = headers )
72- else :
73- r = requests .post (url , files = {'media' : open (image , 'rb' )}, data = {'api_user' : self .api_user ,'api_secret' : self .api_secret }, headers = headers )
62+ def set_bytes (self , binaryImage ):
63+ r = requests .post (self .endpoint + 'check.json' , files = {'media' : BytesIO (binaryImage )}, data = {'models' : self .modelsType , 'api_user' : self .api_user , 'api_secret' : self .api_secret }, headers = headers )
7464
75- output = json .loads (r .text )
76- return output
65+ output = json .loads (r .text )
66+ return output
7767
7868 def video (self , videoUrl , callbackUrl ):
79- url = self .endpoint + '1.0/ video/moderation.json?stream_url=' + videoUrl + '&callback_url=' + callbackUrl + '&api_user=' + self .api_user + '&api_secret=' + self .api_secret
69+ url = self .endpoint + 'video/moderation.json?stream_url=' + videoUrl + '&callback_url=' + callbackUrl + '&api_user=' + self .api_user + '&api_secret=' + self .api_secret
8070 r = requests .get (url , headers = headers )
8171
8272 output = json .loads (r .text )
0 commit comments