Skip to content

Commit

Permalink
Reflect updated site structure
Browse files Browse the repository at this point in the history
  • Loading branch information
khw2ok committed Aug 7, 2024
1 parent 5a27cba commit 3a31560
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
13 changes: 8 additions & 5 deletions comcigan/async_school.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ def trim(lis):
del lis[-1]
return lis

def prefix(n):
return str(n)[:2] if len(str(n)) == 5 else str(n)[:1]


URL = "http://222.106.100.23:4082"

Expand All @@ -36,7 +39,7 @@ class CONSTANT:
__slots__ = ("PREFIX", "orgnum", "daynum", "thnum", "sbnum", "BASEURL", "SEARCHURL")

async def refresh(self):
comci_resp = await AsyncRequest(f"{URL}/st")
comci_resp = await AsyncRequest(f"{URL}/st", "euc-kr")

comcigan_html = BeautifulSoup(comci_resp, "lxml")
script = comcigan_html.find_all("script")[1].contents[0]
Expand Down Expand Up @@ -120,11 +123,11 @@ async def refresh(self):
[
[
(
subjects[int(str(x)[-2:])],
long_subjects[int(str(x)[-2:])],
subjects[int(prefix(x))],
long_subjects[int(prefix(x))],
""
if int(str(x)[:-2]) >= len(teachers)
else teachers[int(str(x)[:-2])],
if int(str(x)[-2:]) >= len(teachers)
else teachers[int(str(x)[-2:])],
)
for x in filter(lambda x: str(x)[:-2], trim(oneday[1:]))
]
Expand Down
10 changes: 6 additions & 4 deletions comcigan/school.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ def trim(lis):
del lis[-1]
return lis

def prefix(n):
return str(n)[:2] if len(str(n)) == 5 else str(n)[:1]

URL = "http://222.106.100.23:4082"

Expand Down Expand Up @@ -95,11 +97,11 @@ def refresh(self):
[
[
(
subjects[int(str(x)[-2:])],
long_subjects[int(str(x)[-2:])],
subjects[int(prefix(x))],
long_subjects[int(prefix(x))],
""
if int(str(x)[:-2]) >= len(teachers)
else teachers[int(str(x)[:-2])],
if int(str(x)[-2:]) >= len(teachers)
else teachers[int(str(x)[-2:])],
)
for x in filter(lambda x: str(x)[:-2], trim(oneday[1:]))
]
Expand Down

0 comments on commit 3a31560

Please sign in to comment.