From ac2c76541fc24c2924ce89fe52b2920c0381ec35 Mon Sep 17 00:00:00 2001 From: VikingKong Date: Fri, 17 Mar 2023 00:20:59 +0300 Subject: [PATCH] Optimize downloading content from server. --- API.py | 2 +- Cache.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/API.py b/API.py index 74ac5b5..a0585da 100644 --- a/API.py +++ b/API.py @@ -30,7 +30,7 @@ class Fetcher: if number == 0: response = httpx.get(self.URL+"/reader/api/0/stream/contents?n=1000"+"&s="+category, headers=self.headers) else: - response = httpx.get(self.URL+"/reader/api/0/stream/contents?ot="+timestamp+"&s=" + response = httpx.get(self.URL+"/reader/api/0/stream/contents?n="+count+"&s=" + category, headers=self.headers) return response.json()["items"] diff --git a/Cache.py b/Cache.py index bd713b9..fd1be90 100644 --- a/Cache.py +++ b/Cache.py @@ -13,6 +13,7 @@ class Cache: def __init__(self, api): self.conn = None self.api = api + file_path = os.path.expanduser("~") + '/.config/inomnibus/cache.db' create_categories = """create table if not exists categories ( id text primary key, name text not null, @@ -61,7 +62,7 @@ class Cache: ) """ try: - self.conn = sqlite3.connect(os.path.expanduser("~") + '/.config/inomnibus/cache.db') + self.conn = sqlite3.connect(file_path) self.conn.cursor().execute(create_categories) self.conn.cursor().execute(create_feeds) self.conn.cursor().execute(create_articles) @@ -238,7 +239,7 @@ class Cache: row[0], count=str(row[2]), timestamp=timestamp, - number=row[3]) + number=str(row[3])) for article in articles: articleObj = Article(article) cur.execute("""insert into articles(id,title,timestamp,date,content,url,is_read,origin,category_id)