diff --git a/PFERD/crawl/ilias/file_templates.py b/PFERD/crawl/ilias/file_templates.py index 1385ba4..6f2b1cd 100644 --- a/PFERD/crawl/ilias/file_templates.py +++ b/PFERD/crawl/ilias/file_templates.py @@ -112,6 +112,17 @@ class Links(Enum): return None raise ValueError("Missing switch case") + def extension(self) -> Optional[str]: + if self == self.FANCY: + return ".html" + elif self == self.PLAIN: + return ".txt" + elif self == self.INTERNET_SHORTCUT: + return ".url" + elif self == self.IGNORE: + return None + raise ValueError("Missing switch case") + @staticmethod def from_string(string: str) -> "Links": try: diff --git a/PFERD/crawl/ilias/kit_ilias_web_crawler.py b/PFERD/crawl/ilias/kit_ilias_web_crawler.py index 283289e..318fa5e 100644 --- a/PFERD/crawl/ilias/kit_ilias_web_crawler.py +++ b/PFERD/crawl/ilias/kit_ilias_web_crawler.py @@ -304,12 +304,14 @@ class KitIliasWebCrawler(HttpCrawler): log.explain(f"Links type is {self._links}") link_template_maybe = self._links.template() - if not link_template_maybe: + link_extension = self._links.extension() + if not link_template_maybe or not link_extension: log.explain("Answer: No") return else: log.explain("Answer: Yes") link_template = link_template_maybe + element_path = element_path.with_name(element_path.name + link_extension) maybe_dl = await self.download(element_path, mtime=element.mtime) if not maybe_dl: