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"):
for i in searchArr:
link2 = Link( link2 = Link(
href=quote(f"/catalog/search"), href=quote(f"/catalog/search["+i+"]"),
rel="subsection", rel="subsection",
rpath=path, rpath=path,
type="application/atom+xml;profile=opds-catalog;kind=acquisition", type="application/atom+xml;profile=opds-catalog;kind=acquisition",
) )
c.add_entry(Entry(title="Search",id=uuid4(),links=[link2])) 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,10 +96,14 @@ 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)
for i in searchArr:
if quote(f""+i) in c.url:
print(i)
conn = sqlite3.connect('app.db') conn = sqlite3.connect('app.db')
sql="SELECT * from COMICS where SERIES like '%" + search+ "%' or Title like '%" + search+ "%';"
sql="SELECT * from COMICS where SERIES like '%" + i+ "%' or Title like '%" + i+ "%';"
print(sql)
s = conn.execute(sql) s = conn.execute(sql)
list=[] list=[]
for r in s: for r in s: