mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-10-26 19:01:39 -04:00
Updating zim downloader with better error.
This commit is contained in:
parent
b98ded62e2
commit
8909d28a6b
1 changed files with 10 additions and 7 deletions
|
|
@ -15,16 +15,19 @@ logger = logger.getChild(__name__)
|
|||
|
||||
|
||||
async def fetch_hrefs(url: str) -> List[str]:
|
||||
async with aiohttp_get(url, timeout=20) as response:
|
||||
status = response.status
|
||||
content = await response.content.read()
|
||||
if status != HTTPStatus.OK:
|
||||
raise RuntimeError(f'Failed to fetch file catalog')
|
||||
try:
|
||||
async with aiohttp_get(url, timeout=20) as response:
|
||||
status = response.status
|
||||
content = await response.content.read()
|
||||
if status != HTTPStatus.OK:
|
||||
raise RuntimeError(f'Failed to fetch Zim file catalog: {url}')
|
||||
except TimeoutError:
|
||||
raise TimeoutError(f'Timeout while fetching Zim file catalog: {url}')
|
||||
|
||||
soup = get_html_soup(content)
|
||||
downloads = list()
|
||||
for a_ in soup.find_all('a'):
|
||||
downloads.append(a_['href'])
|
||||
for a in soup.find_all('a'):
|
||||
downloads.append(a['href'])
|
||||
return downloads
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue