Fixes some bugs with non-code file handling in the new setup

This commit is contained in:
2025-12-02 10:27:00 -07:00
parent 703a2b781e
commit d7cdd28f96
4 changed files with 11 additions and 12 deletions

View File

@@ -1,6 +0,0 @@
requests
beautifulsoup4
lxml
pillow
atproto
pycryptodome

View File

@@ -352,7 +352,7 @@ class AssetRepo(ABC):
iterator = range(len(self.image_urls))
for name in iterator:
logging.info(" Downloading repository %s resource %s", repr(self), name)
image_path = NamedTemporaryFile(mode='wb', suffix=str(name.replace('/', '-')), prefix=str(self), delete = False)
image_path = NamedTemporaryFile(mode='wb', suffix=str(name).replace('/', '-'), prefix=str(self), delete = False)
result = requests.get(self.image_urls[name], headers=self.download_headers)
result.raise_for_status()
# Handles necessary transformations for a URL (i.e., redirections)

View File

@@ -24,6 +24,7 @@ import json
import re
from urllib.parse import urlparse
from importlib import resources
from pathlib import Path
from tempfile import NamedTemporaryFile
@@ -139,9 +140,10 @@ class ExistentialComicStrip(ComicStrip):
safety_size = 24
caption_size = 15
f_size = (1000, 1500)
title_font = ImageFont.truetype(Path(Path(__file__).parent, "Lucida Sans Bold.ttf"), title_size)
safety_font = ImageFont.truetype(Path(Path(__file__).parent, "Lucida Sans Bold.ttf"), safety_size)
caption_font = ImageFont.truetype(Path(Path(__file__).parent, "Lucida Sans.ttf"), caption_size)
with resources.path("comic_download", "Lucida Sans Bold.ttf") as luc_sans_bold, resources.path("comic_download", "Lucida Sans.ttf") as luc_sans:
title_font = ImageFont.truetype(Path(Path(__file__).parent, "Lucida Sans Bold.ttf"), title_size)
safety_font = ImageFont.truetype(Path(Path(__file__).parent, "Lucida Sans Bold.ttf"), safety_size)
caption_font = ImageFont.truetype(Path(Path(__file__).parent, "Lucida Sans.ttf"), caption_size)
title_box = title_font.getbbox(self.title)
title_box = (title_box[2] - title_box[0], title_box[3] - title_box[1])
caption_spacing = 4

View File

@@ -24,6 +24,7 @@ import textwrap
from zipfile import ZipFile
from urllib.parse import urlparse
from importlib import resources
from pathlib import Path
from tempfile import NamedTemporaryFile
@@ -110,8 +111,10 @@ class XKCDComicStrip(ComicStrip):
f_width = 780
title_size = 21
caption_size = 12
title_font = ImageFont.truetype(Path(Path(__file__).parent, "Lucida Sans Bold.ttf"), title_size, layout_engine=ImageFont.Layout.RAQM)
caption_font = ImageFont.truetype(Path(Path(__file__).parent, "Lucida Sans.ttf"), caption_size)
with resources.path("comic_download", "Lucida Sans Bold.ttf") as luc_sans_bold, resources.path("comic_download", "Lucida Sans.ttf") as luc_sans:
title_font = ImageFont.truetype(Path(Path(__file__).parent, "Lucida Sans Bold.ttf"), title_size, layout_engine=ImageFont.Layout.RAQM)
caption_font = ImageFont.truetype(Path(Path(__file__).parent, "Lucida Sans.ttf"), caption_size)
title_box = title_font.getbbox(self.title)
title_box = (title_box[2] - title_box[0], title_box[3] - title_box[1])