aboutsummaryrefslogtreecommitdiff
path: root/libraries/base.py
blob: 74394bee04af1062aa48abb34e1e19b35195b91f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python3
# File: libraries/base.py
# Author: bgstack15
# Startdate: 2024-07-06-7 08:08
# SPDX-License-Identifier: GPL-3.0-only
# Title: Library Plugin example
# Project: library_info
# Purpose: base class for library plugins
# History:
# Usage:
# Reference:
# Improve:
# Dependencies:
#    dep-devuan: python3-bs4

# For a real library you will need this entry too:
#from .base import *
import requests, json, dateutil, base64, os
from bs4 import BeautifulSoup

class BaseLibrary:

   def __init__(self, username = None, password = None, baseurl = None):
      self.username = username
      self.password = password
      self.baseurl = baseurl
      # will need cookies or session manager here.

   def get_checkouts(self):
      """ STUB """
      sample = {
         "title": "sample book 1",
         "format": "book",
         "picture": "DUMMYIMAGEprobablybase64ed",
         "barcode": 912738490172349,
         "duedate": "2024-07-12",
         "possible_renewal_date": "2024-07-11",
         "times_renewed": 0,
         "checkout_date": "2024-07-02"
      }
      return [sample]

   def get_class_name(self):
      """ Leave this function as is. It will return the filename. """
      return os.path.basename(__file__).replace(".py","")

   def login(self):
      """
      This is where the login interaction should happen.
      """
bgstack15