Fix link template error and use indeterminate progress bar

This commit is contained in:
I-Al-Istannen 2021-05-18 22:40:28 +02:00
parent db1219d4a9
commit 1525aa15a6

View File

@ -634,14 +634,12 @@ class KitIliasCrawler(HttpCrawler):
if not dl:
return
async with self.download_bar(element_path, 2) as bar:
async with self.download_bar(element_path):
export_url = element.url.replace("cmd=calldirectlink", "cmd=exportHTML")
async with self.session.get(export_url) as response:
html_page: BeautifulSoup = soupify(await response.read())
real_url: str = html_page.select_one("a").get("href").strip()
bar.advance(1)
async with dl as sink:
content = _link_template_plain if self._link_file_use_plaintext else _link_template_rich
content = content.replace("{{link}}", real_url)
@ -649,7 +647,6 @@ class KitIliasCrawler(HttpCrawler):
content = content.replace("{{description}}", str(element.description))
content = content.replace("{{redirect_delay}}", str(self._link_file_redirect_delay))
sink.file.write(content.encode("utf-8"))
bar.advance(1)
sink.done()
@arepeat(3)