added windows fixes
This commit is contained in:
parent
59256c35ac
commit
89e68e3f8e
@ -4,6 +4,8 @@ from werkzeug.security import generate_password_hash
|
||||
#CONTENT_BASE_DIR = os.getenv("CONTENT_BASE_DIR", "/library") #docker
|
||||
#CONTENT_BASE_DIR = os.getenv("CONTENT_BASE_DIR", "/home/drudoo/ComicsTest/Comics") #linux
|
||||
CONTENT_BASE_DIR = os.getenv("CONTENT_BASE_DIR", "/Comics/ComicRack") #windows
|
||||
WIN_DRIVE_LETTER = 'B'
|
||||
DEFAULT_SEARCH_NUMBER = 10
|
||||
|
||||
|
||||
TEENYOPDS_ADMIN_PASSWORD = os.getenv("TEENYOPDS_ADMIN_PASSWORD", None)
|
||||
|
27
main.py
27
main.py
@ -31,6 +31,7 @@ def verify_password(username, password):
|
||||
|
||||
@app.route("/")
|
||||
def startpage():
|
||||
#result = "Hello, World!"
|
||||
conn = sqlite3.connect('app.db')
|
||||
cursor = conn.cursor()
|
||||
cursor.execute("select * from comics;")
|
||||
@ -50,7 +51,7 @@ def import2sql():
|
||||
importcount = 0
|
||||
skippedcount = 0
|
||||
errorcount = 0
|
||||
|
||||
comics_with_errors = []
|
||||
start_time = timeit.default_timer()
|
||||
for root, dirs, files in os.walk(os.path.abspath(config.CONTENT_BASE_DIR)):
|
||||
for file in files:
|
||||
@ -83,8 +84,14 @@ def import2sql():
|
||||
#sql="INSERT OR REPLACE INTO COMICS (CVDB,ISSUE,SERIES,VOLUME, PUBLISHER, TITLE, FILE,PATH,UPDATED) VALUES ("+CVDB[0]+",'"+ISSUE+"','"+SERIES+"','"+VOLUME+"','"+PUBLISHER+"','"+TITLE+"','"+file+"','" + f + "','" + UPDATED + "')"
|
||||
#print(sql,file=sys.stdout)
|
||||
#conn.execute(sql);
|
||||
query = "SELECT UPDATED FROM COMICS WHERE CVDB = '" + str(CVDB[0]) + "';"
|
||||
savedmodtime = conn.execute(query).fetchone()[0]
|
||||
|
||||
# CREATE TABLE IF MISSING
|
||||
# create table COMICS (CVDB, ISSUE, SERIES,VOLUME,PUBLISHER,TITLE,FILE,PATH,UPDATED,PRIMARY KEY(CVDB))
|
||||
try:
|
||||
query = "SELECT UPDATED FROM COMICS WHERE CVDB = '" + str(CVDB[0]) + "';"
|
||||
savedmodtime = conn.execute(query).fetchone()[0]
|
||||
except:
|
||||
savedmodtime = 0
|
||||
#print(savedmodtime)
|
||||
#print(float(savedmodtime))
|
||||
#print(type(savedmodtime))
|
||||
@ -92,24 +99,25 @@ def import2sql():
|
||||
if savedmodtime < filemodtime:
|
||||
#print(str(savedmodtime) + " is less than " + str(filemodtime))
|
||||
|
||||
print(str(CVDB[0]) + " - s: " + str(savedmodtime))
|
||||
print(str(CVDB[0]) + " - f: " + str(filemodtime))
|
||||
#print(str(CVDB[0]) + " - s: " + str(savedmodtime))
|
||||
#print(str(CVDB[0]) + " - f: " + str(filemodtime))
|
||||
conn.execute("INSERT OR REPLACE INTO COMICS (CVDB,ISSUE,SERIES,VOLUME, PUBLISHER, TITLE, FILE,PATH,UPDATED) VALUES (?,?,?,?,?,?,?,?,?)", (CVDB[0], ISSUE, SERIES, VOLUME, PUBLISHER, TITLE, file, f, UPDATED))
|
||||
conn.commit()
|
||||
print("Adding: " + str(CVDB[0]))
|
||||
#print("Adding: " + str(CVDB[0]))
|
||||
importcount = importcount + 1
|
||||
else:
|
||||
# print("Skipping: " + str(CVDB[0]))
|
||||
skippedcount = skippedcount + 1
|
||||
except:
|
||||
errorcount = errorcount + 1
|
||||
print(f,file=sys.stdout)
|
||||
comics_with_errors.append(f)
|
||||
#print(f,file=sys.stdout)
|
||||
|
||||
conn.close()
|
||||
elapsed = timeit.default_timer() - start_time
|
||||
elapsed_time = "IMPORTED IN: " + str(round(elapsed,2)) + "s"
|
||||
print(elapsed_time)
|
||||
return elapsed_time + "<br>Comics: " + str(comiccount) + "<br>Imported: " + str(importcount) + "<br>Skipped: " + str(skippedcount) + "<br>Errors: " + str(errorcount)
|
||||
import_stats = elapsed_time + "<br>Comics: " + str(comiccount) + "<br>Imported: " + str(importcount) + "<br>Skipped: " + str(skippedcount) + "<br>Errors: " + str(errorcount)
|
||||
return import_stats #+ "<br>" + ['<li>' + x + '</li>' for x in comics_with_errors]
|
||||
|
||||
@app.route("/content/<path:path>")
|
||||
@auth.login_required
|
||||
@ -118,6 +126,7 @@ def send_content(path):
|
||||
return send_from_directory(config.CONTENT_BASE_DIR, path)
|
||||
|
||||
@app.route("/catalog")
|
||||
@app.route("/catalog/")
|
||||
@app.route("/catalog/<path:path>")
|
||||
@auth.login_required
|
||||
def catalog(path=""):
|
||||
|
@ -5,7 +5,7 @@ from jinja2 import Environment, FileSystemLoader, select_autoescape
|
||||
from .entry import Entry
|
||||
from .link import Link
|
||||
import sqlite3,json
|
||||
|
||||
import config
|
||||
|
||||
class Catalog(object):
|
||||
def __init__(
|
||||
@ -79,6 +79,8 @@ def fromdir(root_url, url, content_base_path, content_relative_path):
|
||||
print(searchArr)
|
||||
######################
|
||||
|
||||
|
||||
|
||||
|
||||
if not "search" in c.url:
|
||||
onlydirs = [
|
||||
@ -87,7 +89,7 @@ def fromdir(root_url, url, content_base_path, content_relative_path):
|
||||
#print(onlydirs)
|
||||
for dirname in onlydirs:
|
||||
link = Link(
|
||||
href=quote(f"/catalog/{content_relative_path}/{dirname}"),
|
||||
href=quote(f"/catalog/{content_relative_path}/{dirname}").replace('//','/'), #windows fix
|
||||
rel="subsection",
|
||||
rpath=path,
|
||||
type="application/atom+xml;profile=opds-catalog;kind=acquisition",
|
||||
@ -105,7 +107,7 @@ def fromdir(root_url, url, content_base_path, content_relative_path):
|
||||
rpath=path,
|
||||
type="application/atom+xml;profile=opds-catalog;kind=acquisition",
|
||||
)
|
||||
c.add_entry(Entry(title="Search["+i+"]",id=uuid4(),links=[link2]))
|
||||
c.add_entry(Entry(title="["+i+"]",id=uuid4(),links=[link2]))
|
||||
|
||||
if not "search" in c.url:
|
||||
onlyfiles = [f for f in os.listdir(path) if os.path.isfile(os.path.join(path, f))]
|
||||
@ -135,7 +137,7 @@ def fromdir(root_url, url, content_base_path, content_relative_path):
|
||||
#print(data)
|
||||
for e in data:
|
||||
for key, value in e.items():
|
||||
#print(key)
|
||||
print(key)
|
||||
if key == i:
|
||||
query="SELECT * FROM COMICS where "
|
||||
for i in value:
|
||||
@ -144,11 +146,11 @@ def fromdir(root_url, url, content_base_path, content_relative_path):
|
||||
if j == 'SQL':
|
||||
query = query + k
|
||||
if k != '' and j != "SQL":
|
||||
# print(j,k)
|
||||
print(j,k)
|
||||
if not first:
|
||||
query = query + "and "
|
||||
if type(k) == list:
|
||||
# print(k)
|
||||
print(k)
|
||||
if j == "series" or j == "title":
|
||||
firstS = True
|
||||
query = query + "("
|
||||
@ -174,8 +176,12 @@ def fromdir(root_url, url, content_base_path, content_relative_path):
|
||||
query = query + j + " like '%" + k + "%' "
|
||||
if first:
|
||||
first = False
|
||||
query = query + " order by series asc, cast(issue as unsigned) asc;"
|
||||
print("----> " + query)
|
||||
query = query + " order by series asc, cast(issue as unsigned) asc "
|
||||
if config.DEFAULT_SEARCH_NUMBER != 0:
|
||||
query = query + "LIMIT " + str(config.DEFAULT_SEARCH_NUMBER) + ";"
|
||||
else:
|
||||
query = query + ";"
|
||||
print("----> " + query)
|
||||
|
||||
sql = query
|
||||
#sql="SELECT * from COMICS where SERIES like '%" + i+ "%' or Title like '%" + i+ "%';"
|
||||
@ -184,7 +190,8 @@ def fromdir(root_url, url, content_base_path, content_relative_path):
|
||||
#list=[]
|
||||
for r in s:
|
||||
#print(r)
|
||||
tUrl=f""+r[7].replace("/home/drudoo/ComicsTest/Comics/","/content/")
|
||||
tUrl=f""+r[7].replace('\\','/').replace(config.WIN_DRIVE_LETTER + ':','').replace(config.CONTENT_BASE_DIR,"/content")
|
||||
print(tUrl)
|
||||
tTitle=r[6]
|
||||
link3 = Link(
|
||||
#href=quote(f"/content/DC Comics/Earth Cities/Gotham City/Batgirl/Annual/(2012) Batgirl Annual/Batgirl Annual #001 - The Blood That Moves Us [December, 2012].cbz"),
|
||||
@ -193,6 +200,7 @@ def fromdir(root_url, url, content_base_path, content_relative_path):
|
||||
rpath=path,
|
||||
type="application/x-cbz",
|
||||
)
|
||||
print(link3.href)
|
||||
c.add_entry(
|
||||
Entry(
|
||||
title=tTitle,
|
||||
|
11
test.json
11
test.json
@ -28,14 +28,13 @@
|
||||
"issue": ""
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
},{
|
||||
"DC (BAT)": [
|
||||
{
|
||||
"title": "",
|
||||
"volume": "",
|
||||
"publisher": "DC Comics",
|
||||
"series": "Bat",
|
||||
"series": "%bat%",
|
||||
"issue": ""
|
||||
}
|
||||
]
|
||||
@ -49,8 +48,7 @@
|
||||
"issue": ""
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
},{
|
||||
"Girl": [
|
||||
{
|
||||
"title": ["girl","man","World"],
|
||||
@ -60,8 +58,7 @@
|
||||
"issue": ""
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
},{
|
||||
"number 1": [
|
||||
{
|
||||
"title": "",
|
||||
|
Loading…
Reference in New Issue
Block a user