|
|
@ -49,17 +49,17 @@ class DataBase:
|
|
|
|
"""Create a table in the DB."""
|
|
|
|
"""Create a table in the DB."""
|
|
|
|
connect = sqlite3.connect(self.PATH)
|
|
|
|
connect = sqlite3.connect(self.PATH)
|
|
|
|
cursor = connect.cursor()
|
|
|
|
cursor = connect.cursor()
|
|
|
|
cursor.execute(f'CREATE TABLE IF NOT EXISTS {table}(id INTEGER PRIMARY KEY, Url TEXT, Title TEXT, Status TEXT);')
|
|
|
|
cursor.execute(f'CREATE TABLE IF NOT EXISTS {table}(id INTEGER PRIMARY KEY, Url TEXT, Title TEXT, Status TEXT, PosterPath TEXT);')
|
|
|
|
connect.commit()
|
|
|
|
connect.commit()
|
|
|
|
cursor.close()
|
|
|
|
cursor.close()
|
|
|
|
connect.close()
|
|
|
|
connect.close()
|
|
|
|
|
|
|
|
|
|
|
|
def add_anime(self, url, title, status):
|
|
|
|
def add_anime(self, url, title, status, poster_path=""):
|
|
|
|
"""Add entry of a content."""
|
|
|
|
"""Add entry of a content."""
|
|
|
|
connect = sqlite3.connect(self.PATH)
|
|
|
|
connect = sqlite3.connect(self.PATH)
|
|
|
|
cursor = connect.cursor()
|
|
|
|
cursor = connect.cursor()
|
|
|
|
data = [url, title, status]
|
|
|
|
data = [url, title, status, poster_path]
|
|
|
|
cursor.execute(f'INSERT INTO {self.TABLE}(Url, Title, Status) VALUES(?,?,?)', data)
|
|
|
|
cursor.execute(f'INSERT INTO {self.TABLE}(Url, Title, Status, PosterPath) VALUES(?,?,?,?)', data)
|
|
|
|
connect.commit()
|
|
|
|
connect.commit()
|
|
|
|
cursor.close()
|
|
|
|
cursor.close()
|
|
|
|
connect.close()
|
|
|
|
connect.close()
|
|
|
@ -86,7 +86,7 @@ class DataBase:
|
|
|
|
connect.close()
|
|
|
|
connect.close()
|
|
|
|
return data
|
|
|
|
return data
|
|
|
|
|
|
|
|
|
|
|
|
def add_anime_if(self, url, title, status):
|
|
|
|
def add_anime_if(self, url, title, status, poster_path=""):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Return 0 if not exists.
|
|
|
|
Return 0 if not exists.
|
|
|
|
Return 1 if the same as the entry in the DB.
|
|
|
|
Return 1 if the same as the entry in the DB.
|
|
|
@ -95,10 +95,10 @@ class DataBase:
|
|
|
|
data = self.get_entry(url)
|
|
|
|
data = self.get_entry(url)
|
|
|
|
# If not exists
|
|
|
|
# If not exists
|
|
|
|
if data == []:
|
|
|
|
if data == []:
|
|
|
|
self.add_anime(url, title, status)
|
|
|
|
self.add_anime(url, title, status, poster_path)
|
|
|
|
return 0
|
|
|
|
return 0
|
|
|
|
# If the same
|
|
|
|
# If the same
|
|
|
|
if data[0][1:] == (url, title, status):
|
|
|
|
if data[0][1:] == (url, title, status, poster_path):
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
# If the status is newer than the entry status.
|
|
|
|
# If the status is newer than the entry status.
|
|
|
|
if data[0][3] != status:
|
|
|
|
if data[0][3] != status:
|
|
|
|