some progress
This commit is contained in:
@ -7,28 +7,28 @@ import shutil
|
||||
# conn = sqlite3.connect("Hentai.sqlite3")
|
||||
conn = sqlite3.connect(":memory:")
|
||||
conn.executescript("""
|
||||
DROP TABLE IF EXISTS artist;
|
||||
DROP TABLE IF EXISTS website;
|
||||
DROP TABLE IF EXISTS artists;
|
||||
DROP TABLE IF EXISTS websites;
|
||||
DROP TABLE IF EXISTS links;
|
||||
""")
|
||||
conn.executescript("""
|
||||
CREATE TABLE IF NOT EXISTS artist (
|
||||
id integer NOT NULL CONSTRAINT artist_pk PRIMARY KEY AUTOINCREMENT,
|
||||
CREATE TABLE IF NOT EXISTS artists (
|
||||
id integer NOT NULL CONSTRAINT artists_pk PRIMARY KEY AUTOINCREMENT,
|
||||
name text NOT NULL
|
||||
);
|
||||
CREATE TABLE IF NOT EXISTS website (
|
||||
id integer NOT NULL CONSTRAINT website_pk PRIMARY KEY AUTOINCREMENT,
|
||||
CREATE TABLE IF NOT EXISTS websites (
|
||||
id integer NOT NULL CONSTRAINT websites_pk PRIMARY KEY AUTOINCREMENT,
|
||||
name text NOT NULL
|
||||
);
|
||||
CREATE TABLE IF NOT EXISTS links (
|
||||
id integer NOT NULL CONSTRAINT links_pk PRIMARY KEY AUTOINCREMENT,
|
||||
url text NOT NULL,
|
||||
website_id integer NOT NULL,
|
||||
artist_id integer NOT NULL,
|
||||
CONSTRAINT links_artist FOREIGN KEY (artist_id)
|
||||
REFERENCES artist (id),
|
||||
CONSTRAINT links_website FOREIGN KEY (website_id)
|
||||
REFERENCES website (id)
|
||||
websites_id integer NOT NULL,
|
||||
artists_id integer NOT NULL,
|
||||
CONSTRAINT links_artists FOREIGN KEY (artists_id)
|
||||
REFERENCES artists (id),
|
||||
CONSTRAINT links_websites FOREIGN KEY (websites_id)
|
||||
REFERENCES websites (id)
|
||||
);
|
||||
""")
|
||||
|
||||
@ -72,17 +72,17 @@ def name_needed(url, artist):
|
||||
|
||||
|
||||
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}')")
|
||||
conn.execute(f"INSERT INTO websites(name) VALUES('{website_name}')")
|
||||
conn.execute(f"INSERT INTO artists(name) VALUES('{artist}')")
|
||||
|
||||
sql = f"SELECT id FROM artist WHERE name like '{artist}'"
|
||||
sql = f"SELECT id FROM artists WHERE name like '{artist}'"
|
||||
artist_id = conn.execute(sql).fetchone()[0]
|
||||
|
||||
sql = f"SELECT id FROM website WHERE name like '{website_name}'"
|
||||
sql = f"SELECT id FROM websites 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})"
|
||||
sql = f"INSERT INTO links(url, websites_id, artists_id) VALUES({values})"
|
||||
conn.execute(sql)
|
||||
|
||||
|
||||
@ -98,7 +98,6 @@ def import_website(website_name):
|
||||
artist = line.split("# ")[1].rstrip()
|
||||
name_needed(url, artist)
|
||||
insert_into_db(website_name, url, artist)
|
||||
break # do only on for now
|
||||
|
||||
|
||||
def read_db():
|
||||
@ -108,15 +107,16 @@ def read_db():
|
||||
w.name,
|
||||
a.name
|
||||
FROM links l
|
||||
INNER JOIN website w ON l.website_id = w.id
|
||||
INNER JOIN artist a ON l.artist_id = a.id
|
||||
INNER JOIN websites w ON l.websites_id = w.id
|
||||
INNER JOIN artists a ON l.artists_id = a.id
|
||||
""")
|
||||
return result.fetchall()
|
||||
|
||||
|
||||
def galleryDl(url, website_name, artist_name):
|
||||
directory = f"--directory Artists/{artist_name}/{website_name}"
|
||||
command = f"gallery-dl --config gallery-dl/config.json {directory} {url}"
|
||||
base_command = "gallery-dl --config gallery-dl/config.json "
|
||||
directory = f"--directory Artists/{artist_name}/{website_name} "
|
||||
command = base_command + directory + url
|
||||
print(f"command: {command}")
|
||||
return
|
||||
process = subprocess.run(command, shell=True)
|
||||
@ -128,8 +128,12 @@ def galleryDl(url, website_name, artist_name):
|
||||
import_website("Rule34")
|
||||
# conn.commit()
|
||||
db_contents = read_db()
|
||||
artist_count = conn.execute("select count(id) from artists")
|
||||
print(artist_count.fetchall())
|
||||
conn.close()
|
||||
# exit(0)
|
||||
|
||||
for row in db_contents:
|
||||
print(row)
|
||||
# galleryDl(row[0], row[1], row[2])
|
||||
galleryDl(row[0], row[1], row[2])
|
||||
break
|
||||
|
Reference in New Issue
Block a user