Exemple #1
0
    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()
Exemple #2
0
 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
Exemple #3
0
    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()
Exemple #4
0
 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()
Exemple #5
0
    def create_tables(self):
        connection = self.db.connect()

        c = connection.cursor()
        c.executescript(Base.source("sql/create_tables.sql"))

        connection.commit()
        connection.close()
Exemple #6
0
 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
         })
Exemple #7
0
    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
Exemple #8
0
    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
Exemple #9
0
    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)
Exemple #10
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))
Exemple #11
0
 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()
Exemple #12
0
 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()
Exemple #13
0
    def get_queued(self):

        with self.db.connect() as connection:
            c = connection.cursor()
            return c.execute(Base.source("sql/qupload.sql")).fetchall() or []
Exemple #14
0
 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()
Exemple #15
0
    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)))