|
|
|
@ -74,7 +74,10 @@ class DataBase:
|
|
|
|
|
connect.close()
|
|
|
|
|
|
|
|
|
|
def get_entry(self, url):
|
|
|
|
|
"""Returns the entry if exists. Otherwise, return []."""
|
|
|
|
|
"""
|
|
|
|
|
Returns the enties as an list of tuples if exists.
|
|
|
|
|
Otherwise, return [].
|
|
|
|
|
"""
|
|
|
|
|
connect = sqlite3.connect(self.PATH)
|
|
|
|
|
cursor = connect.cursor()
|
|
|
|
|
cursor.execute(f"SELECT * FROM {self.TABLE} WHERE Url = '{url}';")
|
|
|
|
@ -82,3 +85,22 @@ class DataBase:
|
|
|
|
|
cursor.close()
|
|
|
|
|
connect.close()
|
|
|
|
|
return data
|
|
|
|
|
|
|
|
|
|
def add_anime_if(self, url, title, status):
|
|
|
|
|
"""
|
|
|
|
|
Return 0 if not exists.
|
|
|
|
|
Return 1 if the same as the entry in the DB.
|
|
|
|
|
Return -1 if the status is newer than the entry status.
|
|
|
|
|
"""
|
|
|
|
|
data = self.get_entry(url)
|
|
|
|
|
# If not exists
|
|
|
|
|
if data == []:
|
|
|
|
|
self.add_anime(url, title, status)
|
|
|
|
|
return 0
|
|
|
|
|
# If the same
|
|
|
|
|
if data[0][1:] == (url, title, status):
|
|
|
|
|
return 1
|
|
|
|
|
# If the status is newer than the entry status.
|
|
|
|
|
if data[0][3] != status:
|
|
|
|
|
self.update_anime_status(url, status)
|
|
|
|
|
return -1
|
|
|
|
|