def get_by_cookie(self, cookie): with self.db.connect() as connection: c = connection.cursor() return c.execute(Base.source("sql/user_by_cookie.sql"), { 'cookie': cookie }).fetchone()
def manga(self) -> dict: if not self._MANGA: with self.connection as c: return c.execute(Base.source("sql/get_manga_by_hash.sql"), { "hash": self.hash }).fetchone() return self._MANGA
def get_queued_by_hash(self, uhash): with self.db.connect() as connection: c = connection.cursor() return c.execute(Base.source("sql/url_exists.sql"), { "hash": uhash }).fetchone()
def get_manga_chapt(self, mhash, chash): with self.db.connect() as connection: return connection.cursor().execute( Base.source("sql/get_chapter.sql"), { "mhash": mhash, "chash": chash }).fetchone()
def create_tables(self): connection = self.db.connect() c = connection.cursor() c.executescript(Base.source("sql/create_tables.sql")) connection.commit() connection.close()
def set_readed(self, uiid, ciid, piid): with self.connection as c: c.execute(Base.source("sql/set_page_readed.sql"), { "miid": self.miid, "pgid": piid, "uiid": uiid, "ciid": ciid })
def authors(self) -> list: if not self._AUTHORS: with self.connection as c: t = c.execute(Base.source("sql/select_authors_by_miid.sql"), { "miid": self.miid }).fetchall() self._AUTHORS = list(map(lambda x: x["value"], t)) return self._AUTHORS
def genres(self) -> list: if not self._GENRES: with self.connection as c: t = c.execute(Base.source("sql/select_genres_by_miid.sql"), { "miid": self.miid }).fetchall() self._GENRES = list(map(lambda x: x["value"], t)) return self._GENRES
def get_readed_count(self, ciid, uiid): if not uiid: return 0 with self.connection as c: return c.execute(Base.source("sql/select_readed_count.sql"), { "miid": self.miid, "ciid": ciid, "uiid": uiid }).fetchone().get("readed", 0)
def get_readed(self, ciid, uiid): if not uiid: return [] with self.connection as c: readed = c.execute(Base.source("sql/select_readed.sql"), { "miid": self.miid, "ciid": ciid, "uiid": uiid }).fetchall() return list(map(lambda x: x["pageid"], readed))
def authorize(self, uiid, cookie, ip): with self.db.connect() as connection: c = connection.cursor() c.execute(Base.source("sql/authorize.sql"), (uiid, ip, cookie)) connection.commit()
def get_manga_by_hash(self, mhash): with self.db.connect() as connection: c = connection.cursor() return c.execute(Base.source("sql/get_manga_by_hash.sql"), { "hash": mhash }).fetchone()
def get_queued(self): with self.db.connect() as connection: c = connection.cursor() return c.execute(Base.source("sql/qupload.sql")).fetchall() or []
def get_chapter(self, chash): with self.connection as c: return c.execute(Base.source("sql/get_chapter.sql"), { "mhash": self.mhash, "chash": chash }).fetchone()
def add_url(self, uiid, url): with self.db.connect() as connection: c = connection.cursor() c.execute(Base.source("sql/add_url.sql"), (uiid, url, aux.sha1(url)))