-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Feature : Deepfake #280
Conversation
|
||
score = 1 - extract(original_response,["type","deepfake"],None) | ||
if score is None: | ||
raise ProviderException(response.json()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it better to raise an exception wih the same message as for the deepfake video:
raise ProviderException("Deepfake score not found in response.")
"api_user": self.api_settings["api_user"], | ||
"api_secret": self.api_settings["api_key"]} | ||
|
||
response = requests.get( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
usually I like to try surround the requests call with a try/catch bloc in case of some exceptions like Timeout or ConnectionError, and than in case of an exception, raise a ProviderException. Same for the deepfake video
params=payload, | ||
) | ||
|
||
print(response.json()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe removing also the print
|
||
payload = { | ||
"models": "deepfake", | ||
"api_user": self.api_settings["api_user"], | ||
"api_secret": self.api_settings["api_key"], | ||
"callback_url": self.webhook_url, | ||
} | ||
|
||
if file: | ||
with open(file, 'rb') as video_file: | ||
files = {'media': video_file} | ||
|
||
response = requests.post( | ||
f"{self.api_url}/video/check.json", | ||
files=files, | ||
data=payload, | ||
) | ||
elif file_url: | ||
payload['stream_url'] = file_url | ||
|
||
response = requests.get( | ||
f"{self.api_url}/video/check.json", | ||
params=payload, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can here maybe construct the requests parameters dynamically and than do only one request call depending on the method (get or post) using:
requests.request(method, url, **kwargs)
Here also adding a try/catch block
No description provided.