Optimize downloading content from server.

sqlite
VikingKong 3 years ago
parent 1cc83ddd2d
commit ac2c76541f

@ -30,7 +30,7 @@ class Fetcher:
if number == 0: if number == 0:
response = httpx.get(self.URL+"/reader/api/0/stream/contents?n=1000"+"&s="+category, headers=self.headers) response = httpx.get(self.URL+"/reader/api/0/stream/contents?n=1000"+"&s="+category, headers=self.headers)
else: 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) + category, headers=self.headers)
return response.json()["items"] return response.json()["items"]

@ -13,6 +13,7 @@ class Cache:
def __init__(self, api): def __init__(self, api):
self.conn = None self.conn = None
self.api = api self.api = api
file_path = os.path.expanduser("~") + '/.config/inomnibus/cache.db'
create_categories = """create table if not exists categories ( create_categories = """create table if not exists categories (
id text primary key, id text primary key,
name text not null, name text not null,
@ -61,7 +62,7 @@ class Cache:
) )
""" """
try: 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_categories)
self.conn.cursor().execute(create_feeds) self.conn.cursor().execute(create_feeds)
self.conn.cursor().execute(create_articles) self.conn.cursor().execute(create_articles)
@ -238,7 +239,7 @@ class Cache:
row[0], row[0],
count=str(row[2]), count=str(row[2]),
timestamp=timestamp, timestamp=timestamp,
number=row[3]) number=str(row[3]))
for article in articles: for article in articles:
articleObj = Article(article) articleObj = Article(article)
cur.execute("""insert into articles(id,title,timestamp,date,content,url,is_read,origin,category_id) cur.execute("""insert into articles(id,title,timestamp,date,content,url,is_read,origin,category_id)

Loading…
Cancel
Save