Skip to content

Commit 3b0e971

Browse files
authored
Merge pull request #81 from filips123/fix-parsing-substitutions
2 parents d66df33 + 3f56dfc commit 3b0e971

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

API/gimvicurnik/updaters/eclassroom.py

+25-5
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,24 @@ def _get_internal_urls(self) -> Iterator[DocumentInfo]:
113113

114114
url = self.normalize_url(module["contents"][0]["fileurl"])
115115

116+
modified = (
117+
datetime.fromtimestamp(module["contents"][0]["timemodified"], tz=timezone.utc)
118+
if module["contents"][0]["timemodified"]
119+
else None
120+
)
121+
122+
created = (
123+
datetime.fromtimestamp(module["contents"][0]["timecreated"], tz=timezone.utc)
124+
if module["contents"][0]["timecreated"]
125+
else modified
126+
)
127+
116128
yield DocumentInfo(
117129
url=url,
118130
type=self._get_document_type(url),
119131
title=module["name"],
120-
created=datetime.fromtimestamp(module["contents"][0]["timecreated"], tz=timezone.utc),
121-
modified=datetime.fromtimestamp(module["contents"][0]["timemodified"], tz=timezone.utc),
132+
created=created,
133+
modified=modified,
122134
extension=os.path.splitext(urlparse(url).path)[1][1:],
123135
)
124136

@@ -153,12 +165,18 @@ def _get_external_urls(self) -> Iterator[DocumentInfo]:
153165

154166
url = self.normalize_url(content["externalurl"])
155167

168+
modified = (
169+
datetime.fromtimestamp(content["timemodified"], tz=timezone.utc)
170+
if content["timemodified"]
171+
else None
172+
)
173+
156174
yield DocumentInfo(
157175
url=url,
158176
type=self._get_document_type(url),
159177
title=content["name"],
160-
created=datetime.fromtimestamp(content["timemodified"], tz=timezone.utc),
161-
modified=datetime.fromtimestamp(content["timemodified"], tz=timezone.utc),
178+
created=modified,
179+
modified=modified,
162180
extension=os.path.splitext(urlparse(url).path)[1][1:],
163181
)
164182

@@ -182,6 +200,8 @@ def normalize_url(self, url: str) -> str:
182200
url.replace(self.config.pluginFileWebserviceUrl, self.config.pluginFileNormalUrl)
183201
.replace("?forcedownload=1", "")
184202
.replace("?dl=0", "?raw=1")
203+
.replace("&dl=0", "&raw=1")
204+
.replace("?rlkey=", "?raw=1&rlkey=")
185205
)
186206

187207
def tokenize_url(self, url: str) -> str:
@@ -438,7 +458,7 @@ def _parse_substitutions(self, tables: Tables, effective: date) -> None:
438458
elif row == header_reservations:
439459
parser_type = ParserType.RESERVATIONS
440460
continue
441-
elif "Oddelek" in row[0] or "Razred" in row[0] or "dijaki" in row[0]:
461+
elif "Oddelek" in row[0] or "Razred" in row[0] or "dijaki" in row[0] or "RAZREDNIK" in row[1]:
442462
parser_type = ParserType.UNKNOWN
443463
continue
444464

API/gimvicurnik/utils/pdf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
def keep_visible_lines(obj: dict[str, Any]) -> bool:
1515
if obj["object_type"] == "rect":
16-
visible: bool = obj["non_stroking_color"] == [0, 0, 0]
16+
visible: bool = obj["non_stroking_color"] == (0, 0, 0)
1717
return visible
1818
return True
1919

0 commit comments

Comments
 (0)