diff --git a/doomcc/fetch.py b/doomcc/fetch.py index 3e5e411..9d2417c 100644 --- a/doomcc/fetch.py +++ b/doomcc/fetch.py @@ -29,9 +29,16 @@ class Fetch(doomcc.config.Base): ) wad = reply["content"]["filename"][0:-4] + pwadpath = self.pwads.joinpath(wad) with urllib.request.urlopen(rpath) as response: z = zipfile.ZipFile(io.BytesIO(response.read())) - z.extractall(path=self.pwads.joinpath(wad)) + z.extractall(path=pwadpath) + + contents = list(pwadpath.glob('*')) + if len(contents) == 1 and contents[0].is_dir(): + for wc in contents[0].glob('*'): + wc.rename(pwadpath.joinpath(wc.name)) + contents[0].rmdir() # TODO: explicit error handling. Let users choose when >1 result. def search_idgames(self, wad):