Compare commits

...

3 commits

Author SHA1 Message Date
21bdcf3e17 More clearly delineate the different cases for the text label.
The preferences in order are: value passed by flag, value read from
config, and value read from stdin.
2025-12-24 12:02:09 -05:00
a3a970a22f Check to see any WADs were returned before trying to fetch them. 2025-12-24 11:59:26 -05:00
081b7e2dee Fix typo. 2025-12-24 11:58:51 -05:00
3 changed files with 25 additions and 12 deletions

View file

@ -12,7 +12,7 @@ class Extract(dcc.doom_base.Wad):
return parser
def take_action(self, parsed_args):
for w in self.load_order()
for w in self.load_order():
try:
# TODO: handle anything other than graphics.
wad = omg.WadIO(w)

View file

@ -4,6 +4,7 @@ import json
import pathlib
import shutil
import subprocess
import sys
import urllib.request
import zipfile
@ -40,6 +41,8 @@ class Fetch(dcc.config.Base):
"https://www.doomworld.com/idgames/api/" +
"api.php?action=search&query={}&out=json".format(wad)
)
if "content" not in reply:
sys.exit(f"No WAD named {wad} found on idgames.")
files = reply["content"]["file"]
if type(files) is dict: # One result.
return files["id"]

View file

@ -60,21 +60,19 @@ class Text(dcc.doom_base.WadMap):
def get_parser(self, prog_name):
parser = super().get_parser(prog_name)
parser.add_argument("--nomap", action="store_true")
parser.add_argument("--nomapname", action="store_true")
parser.add_argument("--mapname", "-m", default="")
parser.add_argument("--demotype", default="UV-Max Demo")
parser.add_argument("--stdin", "--stdin-only", action="store_true")
return parser
def take_action(self, parsed_args):
text = None
if not parsed_args.stdin:
map_names = self._config.get("map_names")
if map_names is not None:
text = map_names.get(f"map{parsed_args.map}")
if text is None:
text = input("Map Name? ")
if not parsed_args.nomap:
text = "MAP{}: {}".format(parsed_args.map, text)
text = "{}\n{}".format(text, parsed_args.demotype)
text = ""
if not parsed_args.nomapname:
if not parsed_args.nomap:
text = f"MAP{parsed_args.map}: "
text += self.map_name(parsed_args.mapname, parsed_args.map)
text += "\n"
text = "{}{}".format(text, parsed_args.demotype)
with wand.image.Image(
height=self.thumbnail_height,
width=self.thumbnail_width
@ -85,3 +83,15 @@ class Text(dcc.doom_base.WadMap):
img.trim()
img.reset_coords()
img.save(filename=self.text_thumb_path())
def map_name(self, mapname, mapnum):
if mapname != "":
return mapname
map_names = self._config.get("map_names")
if map_names is not None:
text = map_names.get(f"map{mapnum}")
if text != "":
return text
return input("Map Name? ")