Skip to content

Commit

Permalink
Fixed Error fetching dpc data: 'vigilance'
Browse files Browse the repository at this point in the history
Fixed the regex to extrapolate vigilance id.
  • Loading branch information
caiosweet committed Oct 9, 2023
1 parent 5c575fd commit 18c304a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions custom_components/dpc/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
from __future__ import annotations

import asyncio
from datetime import date, datetime, time, timedelta
import json
import re
import socket
from datetime import date, datetime, time, timedelta

import aiohttp
import async_timeout
Expand Down Expand Up @@ -153,7 +153,7 @@
},
}

REGEX_DPC_ID = re.compile(r'href=[\'"]?([^\'" >]+\/)([0-9]+.[0-9]+).zip', re.IGNORECASE)
REGEX_DPC_ID = re.compile(r'([0-9]{8})(.json)', re.IGNORECASE)
REGEX_DPC_ID_DATETIME = re.compile(r'[0-9]{8}_[0-9]{4}', re.IGNORECASE)
TIMEOUT = 30

Expand Down Expand Up @@ -306,7 +306,7 @@ async def get_id_from_site(self, bulletin: str) -> str | None:
resp = await self.api_fetch(url)
html = resp.get(url, "")
if VIGILANCE in bulletin:
id_pub = [match[1] for match in REGEX_DPC_ID.findall(html)]
id_pub = [match[0] for match in REGEX_DPC_ID.findall(html)]
else:
id_pub = REGEX_DPC_ID_DATETIME.findall(html)
if id_pub:
Expand Down
2 changes: 1 addition & 1 deletion custom_components/dpc/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
ISSUE_URL = "https://github.com/caiosweet/Home-Assistant-custom-components-DPC-Alert/issues"
NAME = "Dipartimento Protezione Civile"
MANUFACTURER = "Italian Government"
VERSION = "2022.3.0"
VERSION = "2023.10.0"

# Config
CONF_MUNICIPALITY = "municipality"
Expand Down
2 changes: 1 addition & 1 deletion custom_components/dpc/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/caiosweet/Home-Assistant-custom-components-DPC-Alert/issues",
"requirements": [],
"version": "2022.3.0"
"version": "2023.10.0"
}

0 comments on commit 18c304a

Please sign in to comment.