mirror of
https://github.com/EstrellaXD/Auto_Bangumi.git
synced 2026-04-24 18:40:03 +08:00
Move rss_analyser.py to database
This commit is contained in:
@@ -115,7 +115,7 @@ class DataOperator(DataConnector):
|
||||
self._conn.commit()
|
||||
return self._cursor.rowcount == 1
|
||||
|
||||
def search(self, _id: int) -> BangumiData | None:
|
||||
def search_id(self, _id: int) -> BangumiData | None:
|
||||
self._cursor.execute('''
|
||||
SELECT * FROM bangumi WHERE id = :id
|
||||
''', {"id": _id})
|
||||
@@ -126,6 +126,17 @@ class DataOperator(DataConnector):
|
||||
dict_data = dict(zip(keys, values))
|
||||
return self.db_to_data(dict_data)
|
||||
|
||||
def search_official_title(self, official_title: str) -> BangumiData | None:
|
||||
self._cursor.execute('''
|
||||
SELECT * FROM bangumi WHERE official_title = :official_title
|
||||
''', {"official_title": official_title})
|
||||
values = self._cursor.fetchone()
|
||||
if values is None:
|
||||
return None
|
||||
keys = [x[0] for x in self._cursor.description]
|
||||
dict_data = dict(zip(keys, values))
|
||||
return self.db_to_data(dict_data)
|
||||
|
||||
def match_title(self, title: str) -> bool:
|
||||
# Select all title_raw
|
||||
self._cursor.execute('''
|
||||
@@ -138,6 +149,19 @@ class DataOperator(DataConnector):
|
||||
return True
|
||||
return False
|
||||
|
||||
def not_exist_titles(self, titles: list[str]) -> list[str]:
|
||||
# Select all title_raw
|
||||
self._cursor.execute('''
|
||||
SELECT title_raw FROM bangumi
|
||||
''')
|
||||
title_raws = [x[0] for x in self._cursor.fetchall()]
|
||||
# Match title
|
||||
for title_raw in title_raws:
|
||||
for title in titles:
|
||||
if title_raw in title:
|
||||
titles.remove(title)
|
||||
return titles
|
||||
|
||||
def gen_id(self) -> int:
|
||||
self._cursor.execute('''
|
||||
SELECT id FROM bangumi ORDER BY id DESC LIMIT 1
|
||||
|
||||
Reference in New Issue
Block a user