work #25

Merged
paradizelost merged 2 commits from work into main 2024-11-25 23:56:56 -06:00

View File

@ -17,14 +17,13 @@ class libaccount(dict):
def toJson(self):
return json.dumps(self,default=lambda o: o.__dict__)
class book():
def __init__(self,itemid,renewalcount,checkoutdate,duedate,vendor,resourceid,resourceinstanceid,title,materialtype,coverurl,person,authsession,renewresult,overdue,isbn):
def __init__(self,itemid,renewalcount,checkoutdate,duedate,vendor,resourceid,title,materialtype,coverurl,person,authsession,renewresult,overdue,isbn):
self.id=itemid
self.renewalcount=renewalcount
self.checkoutdate=checkoutdate
self.duedate=duedate
self.vendor=vendor
self.resourceid=resourceid
self.resourceinstanceid=resourceinstanceid
self.title=title
self.materialtype=materialtype
self.coverurl=coverurl
@ -138,6 +137,10 @@ for myaccount in accounts:
myisbn = mybook['resource']['coverUrl']['small'].split('=')[1].split("/")[0]
except:
myisbn=''
try:
mycoverurl = mybook['resource']['coverUrl']['small']
except:
mycoverurl = ''
duedate = datetime.datetime.strptime(mybook['dueDate'].split('T')[0],'%Y-%m-%d').date()
if datetime.date.today() > duedate:
overdue=True
@ -151,10 +154,9 @@ for myaccount in accounts:
duedate,
mybook['vendor'],
mybook['resource']['id'],
mybook['resource']['instanceId'],
mybook['resource']['title'],
mybook['resource']['materialType'],
mybook['resource']['coverUrl']['small'],
mycoverurl,
account.name,
session,
'None',
@ -167,7 +169,6 @@ for myaccount in accounts:
mediatypes.append(thisbook.materialtype)
except Exception as e:
print(e,mybook)
allbooks.append(thisbook)
for book in allbooks:
#print(datetime.date.today(),book.duedate)
@ -188,8 +189,7 @@ TD {border-width: 1px; padding: 3px; border-style: solid; border-color: black;}
tableend="</table> </body></html>"
timezone = ZoneInfo("America/Chicago")
returntable="Last Updated" + str(datetime.datetime.now(timezone))
returntable+='<br>Click <a href="https://librarynotice.hamik.net">Here</a> to be able to refresh the list.'
returntable+='<br>Click for the <a href="https://librarynotice.hamik.net/returnlist.html">return list</a>'
returntable+='<br>Click <a href="https://librarynotice.hamik.net">Here</a> to visit the site.'
returntable += """<form action="https://librarynotice.hamik.net/refresh.php">
<input type="submit" value="Refresh Items">
</form>
@ -277,8 +277,6 @@ else:
for item in returnlist:
returntable += "<TR><TD>" + item.person + td + item.materialtype + td + str(item.renewalcount) + td + str(item.checkoutdate) + td + str(item.duedate) + td + item.title + td + item.isbn + td +'<img src="'+ item.coverurl+'">' +"</td></tr>\n"
returntable += tableend
with open("/var/www/html/returnlist.html","w",encoding='utf-8') as outhtml:
outhtml.write(returntable)
htmltable = returntable
with open("/var/www/html/index.html","w",encoding='utf-8') as outhtml:
outhtml.write(htmltable)