mirror of
https://github.com/Garmelon/PFERD.git
synced 2023-12-21 10:23:01 +01:00
Add extension to link files
This commit is contained in:
parent
69cb2a7734
commit
ffda4e43df
@ -112,6 +112,17 @@ class Links(Enum):
|
|||||||
return None
|
return None
|
||||||
raise ValueError("Missing switch case")
|
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
|
@staticmethod
|
||||||
def from_string(string: str) -> "Links":
|
def from_string(string: str) -> "Links":
|
||||||
try:
|
try:
|
||||||
|
@ -304,12 +304,14 @@ class KitIliasWebCrawler(HttpCrawler):
|
|||||||
log.explain(f"Links type is {self._links}")
|
log.explain(f"Links type is {self._links}")
|
||||||
|
|
||||||
link_template_maybe = self._links.template()
|
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")
|
log.explain("Answer: No")
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
log.explain("Answer: Yes")
|
log.explain("Answer: Yes")
|
||||||
link_template = link_template_maybe
|
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)
|
maybe_dl = await self.download(element_path, mtime=element.mtime)
|
||||||
if not maybe_dl:
|
if not maybe_dl:
|
||||||
|
Loading…
Reference in New Issue
Block a user