From 7efce97499999af8013efc48f7470ac810142d0f Mon Sep 17 00:00:00 2001 From: AustrianToast Date: Sat, 20 Jul 2024 21:34:35 +0200 Subject: [PATCH] use sqlite in memory --- gallery-dl/gallery-dl.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/gallery-dl/gallery-dl.py b/gallery-dl/gallery-dl.py index 37db6da..aa9cda2 100644 --- a/gallery-dl/gallery-dl.py +++ b/gallery-dl/gallery-dl.py @@ -1,7 +1,8 @@ import subprocess import sqlite3 -conn = sqlite3.connect("Hentai.sqlite3") +# conn = sqlite3.connect("Hentai.sqlite3") +conn = sqlite3.connect(":memory:") conn.executescript(""" DROP TABLE IF EXISTS artist; DROP TABLE IF EXISTS website; @@ -32,10 +33,13 @@ conn.executescript(""" def insert_into_db(website_name, url, artist): conn.execute(f"INSERT INTO website(name) VALUES('{website_name}')") conn.execute(f"INSERT INTO artist(name) VALUES('{artist}')") + sql = f"SELECT id FROM artist WHERE name like '{artist}'" artist_id = conn.execute(sql).fetchone()[0] + sql = f"SELECT id FROM website WHERE name like '{website_name}'" website_id = conn.execute(sql).fetchone()[0] + values = f"'{url}', '{website_id}', '{artist_id}'" sql = f"INSERT INTO links(url, website_id, artist_id) VALUES({values})" conn.execute(sql) @@ -45,6 +49,8 @@ def import_website(website_name): file_name = f"downloaded_{website_name.lower()}.txt" file_contents = open(file_name).readlines() for line in file_contents: + if line.startswith("#"): + continue url = line.split("# ")[0].rstrip() artist = line.split("# ")[1].rstrip("\n") insert_into_db(website_name, url, artist) @@ -74,8 +80,8 @@ def galleryDl(url, website_name, artist_name): # This will not work with Rule34 as is # Rule34 will need it's artists to be added like the others -import_website("Kemono") -conn.commit() +import_website("Coomer") +# conn.commit() db_contents = read_db() conn.close()