Skip to content

Commit

Permalink
Fix: fixed week id
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonKohli committed Nov 25, 2023
1 parent 4991519 commit f33dc8d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
31 changes: 25 additions & 6 deletions azubiheftApi/azubiheftApi.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,31 @@ def isLoggedIn(self) -> bool:

def getReportWeekId(self, date: datetime) -> str:
if(self.isLoggedIn()):
url = "https://www.azubiheft.de/Azubi/Wochenansicht.aspx?T=" + \
TimeHelper.dateTimeToString(date)
reportHtml = self.session.get(url).text
soup = BeautifulSoup(reportHtml, 'html.parser')
id = soup.find(id="lblNachweisNr")["data-br-nr"]
return id
print("Debug: Inside getReportWeekId")
url = "https://www.azubiheft.de/Azubi/Ausbildungsnachweise.aspx"
print("Debug: URL:", url)
overviewHtml = self.session.get(url).text
soup = BeautifulSoup(overviewHtml, 'html.parser')
weekDivs = soup.find_all("div", class_="mo NBox")

# Calculate the calendar week number
calendar_week = date.isocalendar()[1]
year = date.isocalendar()[0]

for div in weekDivs:
kwDiv = div.find("div", class_="sKW")
yearDiv = div.find("div", class_="KW").find_all("div")[2]

if kwDiv and yearDiv:
kw = int(kwDiv.get_text(strip=True))
kwYear = int(yearDiv.get_text(strip=True))

if kw == calendar_week and kwYear == year:
weekId = div['onclick'].split("'")[1].split('=')[1]
print("Debug: Report ID:", weekId)
return weekId

raise ValueError("No report found for the specified week")
else:
raise NotLoggedInError("not logged in. Login first")

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="azubiheftApi",
version="0.0.5",
version="0.0.6",
author="Leon Kohlhaussen",
author_email="kohli.leon@gmail.com",
description="Azubiheft.de custom api",
Expand Down

0 comments on commit f33dc8d

Please sign in to comment.