Change default cover.
[librarian.git] / src / librarian / covers / widgets / background.py
index a6c7205..7836b5c 100644 (file)
@@ -1,4 +1,5 @@
 import io
 import io
+import time
 from urllib.request import urlopen
 import PIL.Image
 from .base import Widget
 from urllib.request import urlopen
 import PIL.Image
 from .base import Widget
@@ -8,6 +9,7 @@ class Background(Widget):
     transparency = False
 
     def setup(self):
     transparency = False
 
     def setup(self):
+        self.img = None
         if self.cover.book_info.cover_url:
             while True:
                 try:
         if self.cover.book_info.cover_url:
             while True:
                 try:
@@ -33,6 +35,8 @@ class Background(Widget):
             self.img = img
 
     def build(self, w, h):
             self.img = img
 
     def build(self, w, h):
+        if not self.img:
+            return
         kwadrat = round(max(w, h))
         img = self.img
         img = self.img.resize((kwadrat, kwadrat))
         kwadrat = round(max(w, h))
         img = self.img
         img = self.img.resize((kwadrat, kwadrat))