Skip to content

Commit

Permalink
https://github.com/nomnoms12/saucenao_api/pull/20
Browse files Browse the repository at this point in the history
  • Loading branch information
RideOnRhythm committed Sep 3, 2023
1 parent c412164 commit 4747f21
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions saucenao_api/saucenao_api.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import io
from typing import Optional, BinaryIO

import requests
Expand Down Expand Up @@ -44,6 +45,16 @@ def __init__(self,
self.params = params

def from_file(self, file: BinaryIO) -> SauceResponse:
# when input is an _io.BufferedReader. seek it in 0
if type(file) == _io.BufferedReader:
file.seek(0)
pass
if type(file) == bytes:
pass
# when input is an image file path. read it in binary mode
if type(file) == str:
with open(file, "rb", ) as f:
file = f.read()
return self._search(self.params, {'file': file})

def from_url(self, url: str) -> SauceResponse:
Expand Down

0 comments on commit 4747f21

Please sign in to comment.