Added 'smart list' using array

This commit is contained in:
FrederikBaerentsen 2022-06-07 09:41:45 +02:00
parent a25dff10ec
commit 7700601288

View File

@ -48,6 +48,7 @@ def fromsearch(root_url, url, content_base_path, content_relative_path):
def fromdir(root_url, url, content_base_path, content_relative_path): def fromdir(root_url, url, content_base_path, content_relative_path):
searchArr=["Girl","Bat","Part One"]
path = os.path.join(content_base_path, content_relative_path) path = os.path.join(content_base_path, content_relative_path)
#print(path) #print(path)
c = Catalog( c = Catalog(
@ -70,13 +71,16 @@ def fromdir(root_url, url, content_base_path, content_relative_path):
if c.url.endswith("/catalog"): if c.url.endswith("/catalog"):
link2 = Link(
href=quote(f"/catalog/search"), for i in searchArr:
rel="subsection",
rpath=path, link2 = Link(
type="application/atom+xml;profile=opds-catalog;kind=acquisition", href=quote(f"/catalog/search["+i+"]"),
) rel="subsection",
c.add_entry(Entry(title="Search",id=uuid4(),links=[link2])) rpath=path,
type="application/atom+xml;profile=opds-catalog;kind=acquisition",
)
c.add_entry(Entry(title="Search["+i+"]",id=uuid4(),links=[link2]))
if not "search" in c.url: if not "search" in c.url:
onlyfiles = [f for f in os.listdir(path) if os.path.isfile(os.path.join(path, f))] onlyfiles = [f for f in os.listdir(path) if os.path.isfile(os.path.join(path, f))]
@ -92,30 +96,34 @@ def fromdir(root_url, url, content_base_path, content_relative_path):
#fixed issue with multiple . in filename #fixed issue with multiple . in filename
#print(c.render()) #print(c.render())
else: else:
search="Man" print(searchArr)
conn = sqlite3.connect('app.db') for i in searchArr:
sql="SELECT * from COMICS where SERIES like '%" + search+ "%' or Title like '%" + search+ "%';" if quote(f""+i) in c.url:
print(i)
conn = sqlite3.connect('app.db')
s = conn.execute(sql) sql="SELECT * from COMICS where SERIES like '%" + i+ "%' or Title like '%" + i+ "%';"
list=[] print(sql)
for r in s: s = conn.execute(sql)
#print(r) list=[]
tUrl=f""+r[7].replace("/home/drudoo/ComicsTest/Comics/","/content/") for r in s:
tTitle=r[6] #print(r)
link3 = Link( tUrl=f""+r[7].replace("/home/drudoo/ComicsTest/Comics/","/content/")
#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"), tTitle=r[6]
href=quote(tUrl), link3 = Link(
rel="http://opds-spec.org/acquisition", #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"),
rpath=path, href=quote(tUrl),
type="application/x-cbz", rel="http://opds-spec.org/acquisition",
) rpath=path,
c.add_entry( type="application/x-cbz",
Entry(
title=tTitle,
id=uuid4(),
links=[link3]
) )
) c.add_entry(
Entry(
title=tTitle,
id=uuid4(),
links=[link3]
)
)
return c return c