mirror of
https://github.com/nathom/streamrip.git
synced 2025-05-22 03:05:26 -04:00
Check database when searching
Signed-off-by: nathom <nathanthomas707@gmail.com>
This commit is contained in:
parent
2b68b96204
commit
4abe96825f
2 changed files with 25 additions and 3 deletions
11
rip/db.py
11
rip/db.py
|
@ -73,7 +73,16 @@ class Database:
|
|||
return bool(conn.execute(command, tuple(items.values())).fetchone()[0])
|
||||
|
||||
def __contains__(self, keys: dict) -> bool:
|
||||
return self.contains(**keys)
|
||||
if isinstance(keys, dict):
|
||||
return self.contains(**keys)
|
||||
|
||||
if isinstance(keys, str) and len(self.structure) == 1:
|
||||
only_key = tuple(self.structure.keys())[0]
|
||||
query = {only_key: keys}
|
||||
logger.debug("Searching for %s in database", query)
|
||||
return self.contains(**query)
|
||||
|
||||
raise TypeError(keys)
|
||||
|
||||
def add(self, items: List[str]):
|
||||
"""Add a row to the table.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue