restoU fix

This commit is contained in:
Brieuc Dubois 2024-04-19 12:20:32 +02:00
parent eed1b36d3e
commit 4031d611bb
3 changed files with 17 additions and 5 deletions

View File

@ -18,9 +18,16 @@ async def extract_picture_url(url, base_url):
images = soup.find_all('img') images = soup.find_all('img')
for img in images: for a in soup.find_all('a'):
src = img.get('src') href = a.get('href')
if src and src.startswith(base_url): if not href or not href.startswith(base_url):
continue
for img in a.find_all('img'):
src = img.get('src')
if not src or not src.startswith(base_url):
continue
if src.startswith('//'): if src.startswith('//'):
return f"https:{src}" return f"https:{src}"
else: else:
@ -59,7 +66,7 @@ class UCLouvainRestoUBot(Plugin):
data = await download_image( data = await download_image(
await extract_picture_url( await extract_picture_url(
"https://uclouvain.be/fr/decouvrir/resto-u/le-galilee-self.html", "https://uclouvain.be/fr/decouvrir/resto-u/le-galilee-self.html",
"//cdn.uclouvain.be/groups/cms-editors-resto-u/menu" "//cdn.uclouvain.be/groups/cms-editors-resto-u/"
) )
) )
url = await self.client.upload_media(data, mime_type="application/json") url = await self.client.upload_media(data, mime_type="application/json")

@ -1 +1 @@
Subproject commit a2eff3236238fd1d0be818b81a0b05854761b02d Subproject commit e618a7fb0d38939c4556d9da55bfe268b7f80dc4

View File

@ -87,3 +87,8 @@ sections:
url: https://uclouvain.atlassian.net/jira/dashboards/10025 url: https://uclouvain.atlassian.net/jira/dashboards/10025
statusCheck: false statusCheck: false
id: 5_1631_jira id: 5_1631_jira
- title: Gestion accès externes
url: >-
https://sites.uclouvain.be/sgsi-apps/shib-accesressources/prod/index.php
statusCheck: false
id: 6_1631_gestionaccsexternes