From e626629c37d5f320d29b19914c509ab7d0fd043f Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Fri, 18 Oct 2024 04:37:18 +0200 Subject: [PATCH] made sure that streaming and power sockets are handled more properly in the NAT parser --- data/external/models/nat.py | 5 +- data/external/results/rooms_nat.json | 215 +++++++-------------------- data/external/scrapers/nat.py | 17 +++ 3 files changed, 75 insertions(+), 162 deletions(-) diff --git a/data/external/models/nat.py b/data/external/models/nat.py index df7aa063e..bd01e4a70 100644 --- a/data/external/models/nat.py +++ b/data/external/models/nat.py @@ -67,8 +67,6 @@ class Room(PydanticConfiguration): schedule_url: str | None seatings: list[SeatingPlan] seats: int | None - steckdosen: TranslatableStr | None - streaming: str | None teaching: bool # semi-random sets of ids # pylint: disable-next=invalid-name @@ -79,7 +77,10 @@ class Room(PydanticConfiguration): room_identifier: str | None campus_id: str | None building_code: str + steckdosen: TranslatableStr | None = None org_id: int | None = None + streaming_webcam: bool = False + streaming_tumlive: bool = False @classmethod def load_all(cls) -> dict[str, "Room"]: diff --git a/data/external/results/rooms_nat.json b/data/external/results/rooms_nat.json index e6ab45426..02e93fe2a 100644 --- a/data/external/results/rooms_nat.json +++ b/data/external/results/rooms_nat.json @@ -79,7 +79,7 @@ "de": "Keine Steckdosen im Bereich der Sitzreihen", "en": "No sockets in the area of the rows of seats" }, - "streaming": "USB.H\u00f6rsaal.Webcam", + "streaming_webcam": true, "teaching": true }, "0101.02.189": { @@ -162,7 +162,7 @@ "de": "Keine Steckdosen im Bereich der Sitzreihen", "en": "No sockets in the area of the rows of seats" }, - "streaming": "USB.H\u00f6rsaal.Webcam", + "streaming_webcam": true, "teaching": true }, "0101.02.190": { @@ -245,7 +245,7 @@ "de": "Keine Steckdosen im Bereich der Sitzreihen", "en": "No sockets in the area of the rows of seats" }, - "streaming": "USB.H\u00f6rsaal.Webcam", + "streaming_webcam": true, "teaching": true }, "0101.Z1.070": { @@ -328,7 +328,6 @@ "de": "Keine Steckdosen im Bereich der Sitzreihen", "en": "No sockets in the area of the rows of seats" }, - "streaming": null, "teaching": true }, "0101.Z1.080": { @@ -411,7 +410,6 @@ "de": "Keine Steckdosen im Bereich der Sitzreihen", "en": "No sockets in the area of the rows of seats" }, - "streaming": null, "teaching": true }, "0101.Z1.090": { @@ -494,7 +492,6 @@ "de": "Keine Steckdosen im Bereich der Sitzreihen", "en": "No sockets in the area of the rows of seats" }, - "streaming": null, "teaching": true }, "0101.Z1.095": { @@ -577,7 +574,6 @@ "de": "Keine Steckdosen im Bereich der Sitzreihen", "en": "No sockets in the area of the rows of seats" }, - "streaming": null, "teaching": true }, "0501.01.100": { @@ -660,7 +656,7 @@ "de": "Eine Doppelsteckdose beim Beamer", "en": "One double socket at the beamer" }, - "streaming": "USB.H\u00f6rsaal.Webcam", + "streaming_webcam": true, "teaching": true }, "0501.01.180": { @@ -743,7 +739,7 @@ "de": "Eine Doppelsteckdose beim Beamer", "en": "One double socket at the beamer" }, - "streaming": "USB.H\u00f6rsaal.Webcam", + "streaming_webcam": true, "teaching": true }, "0501.02.100": { @@ -818,7 +814,7 @@ "de": "Drei Doppelsteckdosen an der R\u00fcckwand (Fensterseite) und je zwei bei den Tafeln", "en": "Three double sockets at the back wall (window side) and two each at the blackboards" }, - "streaming": "USB.H\u00f6rsaal.Webcam", + "streaming_webcam": true, "teaching": true }, "0502.01.200": { @@ -901,7 +897,7 @@ "de": "Einzelne (insgesamt 10) Steckdosen im Bereich der Sitzreihen", "en": "Single (10 in total) sockets in the area of the rows of seats" }, - "streaming": "USB.H\u00f6rsaal.Webcam", + "streaming_webcam": true, "teaching": true }, "0502.01.260": { @@ -980,8 +976,6 @@ } ], "seats": 130, - "steckdosen": null, - "streaming": null, "teaching": true }, "0502.EG.220": { @@ -1060,8 +1054,6 @@ } ], "seats": 175, - "steckdosen": null, - "streaming": null, "teaching": true }, "0503.02.300": { @@ -1144,7 +1136,7 @@ "de": "Einzelne (insgesamt vier Doppelsteckdosen) im Bereich der Sitzreihen unten", "en": "Single (total of four double sockets) in the area of the rows of seats at the bottom" }, - "streaming": "USB.H\u00f6rsaal.Webcam", + "streaming_webcam": true, "teaching": true }, "0503.02.370": { @@ -1223,8 +1215,6 @@ } ], "seats": 115, - "steckdosen": null, - "streaming": null, "teaching": true }, "0503.EG.360": { @@ -1310,7 +1300,7 @@ "de": "Es sind in jeder Reihe jeweils in der MItte des Blocks links/rechts zwei Steckdosen vorhanden", "en": "There are two sockets in the middle of each row on the left/right side of the block" }, - "streaming": "USB.H\u00f6rsaal.Webcam", + "streaming_webcam": true, "teaching": true }, "0504.01.400": { @@ -1381,8 +1371,6 @@ } ], "seats": 56, - "steckdosen": null, - "streaming": null, "teaching": true }, "0504.01.402": { @@ -1453,8 +1441,6 @@ } ], "seats": 107, - "steckdosen": null, - "streaming": null, "teaching": true }, "0505.EG.534": { @@ -1525,8 +1511,6 @@ } ], "seats": 66, - "steckdosen": null, - "streaming": null, "teaching": true }, "0505.EG.540": { @@ -1597,8 +1581,6 @@ } ], "seats": 66, - "steckdosen": null, - "streaming": null, "teaching": true }, "0506.01.601": { @@ -1669,8 +1651,6 @@ } ], "seats": 85, - "steckdosen": null, - "streaming": null, "teaching": true }, "0506.02.607": { @@ -1733,8 +1713,6 @@ } ], "seats": 25, - "steckdosen": null, - "streaming": null, "teaching": true }, "0506.EG.601": { @@ -1805,8 +1783,6 @@ } ], "seats": 101, - "steckdosen": null, - "streaming": null, "teaching": true }, "0506.EG.602": { @@ -1896,8 +1872,7 @@ } ], "seats": 198, - "steckdosen": null, - "streaming": "USB.H\u00f6rsaal.Webcam", + "streaming_webcam": true, "teaching": true }, "0506.EG.606": { @@ -1987,8 +1962,6 @@ } ], "seats": 198, - "steckdosen": null, - "streaming": null, "teaching": true }, "0506.Z1.670": { @@ -2059,8 +2032,6 @@ } ], "seats": 101, - "steckdosen": null, - "streaming": null, "teaching": true }, "0507.02.760": { @@ -2131,8 +2102,7 @@ } ], "seats": 108, - "steckdosen": null, - "streaming": "USB.H\u00f6rsaal.Webcam", + "streaming_webcam": true, "teaching": true }, "0507.02.770": { @@ -2211,8 +2181,7 @@ } ], "seats": 188, - "steckdosen": null, - "streaming": "USB.H\u00f6rsaal.Webcam", + "streaming_webcam": true, "teaching": true }, "0507.03.750": { @@ -2295,7 +2264,7 @@ "de": "Einzelne (insgesamt f\u00fcnf Doppelsteckdosen) Steckdosen im Bereich der Sitzreihen", "en": "Single sockets (five double sockets in total) in the area of the seat rows" }, - "streaming": "USB.H\u00f6rsaal.Webcam", + "streaming_webcam": true, "teaching": true }, "0509.EG.980": { @@ -2374,8 +2343,7 @@ } ], "seats": 1107, - "steckdosen": null, - "streaming": "USB.H\u00f6rsaal.Webcam", + "streaming_webcam": true, "teaching": true }, "2907.06.605": { @@ -2453,7 +2421,7 @@ "de": "Es sind im vorderen Bereich jeweils an den Au\u00dfenseiten in den Reihen bis 1, 3, 5, 7, 9 Dreifachsteckdosen vorhanden", "en": "There are triple sockets in the front area on the outer sides of each row up to 1, 3, 5, 7, 9." }, - "streaming": "USB.H\u00f6rsaal.Webcam", + "streaming_webcam": true, "teaching": true }, "4101.01.129": { @@ -2532,8 +2500,7 @@ } ], "seats": 144, - "steckdosen": null, - "streaming": "USB.H\u00f6rsaal.Webcam", + "streaming_webcam": true, "teaching": true }, "4102.01.038": { @@ -2585,8 +2552,6 @@ } ], "seats": 62, - "steckdosen": null, - "streaming": null, "teaching": true }, "4102.01.040": { @@ -2638,8 +2603,6 @@ } ], "seats": 48, - "steckdosen": null, - "streaming": null, "teaching": true }, "4102.01.043": { @@ -2691,8 +2654,6 @@ } ], "seats": 32, - "steckdosen": null, - "streaming": null, "teaching": true }, "4102.EG.034": { @@ -2771,8 +2732,7 @@ } ], "seats": 128, - "steckdosen": null, - "streaming": "USB.H\u00f6rsaal.Webcam", + "streaming_webcam": true, "teaching": true }, "4102.EG.036": { @@ -2851,8 +2811,6 @@ } ], "seats": 98, - "steckdosen": null, - "streaming": null, "teaching": true }, "4113.01.105": { @@ -2931,8 +2889,6 @@ } ], "seats": 90, - "steckdosen": null, - "streaming": null, "teaching": true }, "4214.EG.010": { @@ -3011,8 +2967,7 @@ } ], "seats": 250, - "steckdosen": null, - "streaming": "USB.H\u00f6rsaal.Webcam", + "streaming_webcam": true, "teaching": true }, "4214.EG.020": { @@ -3091,8 +3046,7 @@ } ], "seats": 350, - "steckdosen": null, - "streaming": "USB.H\u00f6rsaal.Webcam", + "streaming_webcam": true, "teaching": true }, "4214.EG.030": { @@ -3171,8 +3125,7 @@ } ], "seats": 650, - "steckdosen": null, - "streaming": "USB.H\u00f6rsaal.Webcam", + "streaming_webcam": true, "teaching": true }, "4214.U1.034": { @@ -3224,8 +3177,6 @@ } ], "seats": 60, - "steckdosen": null, - "streaming": null, "teaching": true }, "4216.01.129": { @@ -3288,8 +3239,6 @@ } ], "seats": 400, - "steckdosen": null, - "streaming": null, "teaching": true }, "4216.01.131": { @@ -3352,8 +3301,6 @@ } ], "seats": 250, - "steckdosen": null, - "streaming": null, "teaching": true }, "4217.EG.041": { @@ -3432,8 +3379,7 @@ } ], "seats": 150, - "steckdosen": null, - "streaming": "USB.H\u00f6rsaal.Webcam", + "streaming_webcam": true, "teaching": true }, "4277.EG.073A": { @@ -3485,8 +3431,6 @@ } ], "seats": null, - "steckdosen": null, - "streaming": null, "teaching": true }, "4277.EG.073B": { @@ -3538,8 +3482,6 @@ } ], "seats": null, - "steckdosen": null, - "streaming": null, "teaching": true }, "4277.EG.108": { @@ -3591,8 +3533,6 @@ } ], "seats": 30, - "steckdosen": null, - "streaming": null, "teaching": true }, "4277.EG.109": { @@ -3644,8 +3584,6 @@ } ], "seats": 30, - "steckdosen": null, - "streaming": null, "teaching": true }, "4277.EG.127": { @@ -3705,8 +3643,6 @@ } ], "seats": 92, - "steckdosen": null, - "streaming": null, "teaching": true }, "4277.EG.128": { @@ -3766,8 +3702,6 @@ } ], "seats": 92, - "steckdosen": null, - "streaming": null, "teaching": true }, "4277.EG.129": { @@ -3827,8 +3761,7 @@ } ], "seats": 104, - "steckdosen": null, - "streaming": "USB.H\u00f6rsaal.Webcam", + "streaming_webcam": true, "teaching": true }, "4277.EG.130": { @@ -3888,8 +3821,7 @@ } ], "seats": 150, - "steckdosen": null, - "streaming": "USB.H\u00f6rsaal.Webcam", + "streaming_webcam": true, "teaching": true }, "4317.EG.003": { @@ -3949,8 +3881,7 @@ } ], "seats": 130, - "steckdosen": null, - "streaming": "USB.H\u00f6rsaal.Webcam", + "streaming_webcam": true, "teaching": true }, "4318.EG.002": { @@ -4002,8 +3933,6 @@ } ], "seats": 32, - "steckdosen": null, - "streaming": null, "teaching": true }, "4318.EG.007": { @@ -4055,8 +3984,6 @@ } ], "seats": 48, - "steckdosen": null, - "streaming": null, "teaching": true }, "4318.EG.008": { @@ -4108,8 +4035,6 @@ } ], "seats": 64, - "steckdosen": null, - "streaming": null, "teaching": true }, "5101.EG.501": { @@ -4192,7 +4117,7 @@ "de": "Keine Steckdosen im Bereich der Sitzreihen", "en": "No sockets in the area of the rows of seats" }, - "streaming": "USB.H\u00f6rsaal.Webcam", + "streaming_webcam": true, "teaching": true }, "5101.EG.502": { @@ -4275,7 +4200,7 @@ "de": "Keine Steckdosen im Bereich der Sitzreihen, nur bei den behindertengerechten Pl\u00e4tzen", "en": "No sockets in the area of the rows of seats, only at the handicapped accessible seats" }, - "streaming": "USB.H\u00f6rsaal.Webcam", + "streaming_webcam": true, "teaching": true }, "5101.EG.503": { @@ -4358,7 +4283,7 @@ "de": "Keine Steckdosen im Bereich der Sitzreihen", "en": "No sockets in the area of the rows of seats" }, - "streaming": "USB.H\u00f6rsaal.Webcam", + "streaming_webcam": true, "teaching": true }, "5123.EG.019": { @@ -4437,8 +4362,7 @@ } ], "seats": 200, - "steckdosen": null, - "streaming": "USB.H\u00f6rsaal.Webcam", + "streaming_webcam": true, "teaching": true }, "5401.01.101K": { @@ -4524,7 +4448,7 @@ "de": "Steckdose an jedem zweiten Platz", "en": "Socket at every second place" }, - "streaming": "USB.H\u00f6rsaal.Webcam", + "streaming_webcam": true, "teaching": true }, "5402.01.221K": { @@ -4603,8 +4527,7 @@ } ], "seats": 122, - "steckdosen": null, - "streaming": "USB.H\u00f6rsaal.Webcam", + "streaming_webcam": true, "teaching": true }, "5406.01.641A": { @@ -4683,8 +4606,7 @@ } ], "seats": 118, - "steckdosen": null, - "streaming": "USB.H\u00f6rsaal.Webcam", + "streaming_webcam": true, "teaching": true }, "5407.01.740B": { @@ -4763,8 +4685,7 @@ } ], "seats": 118, - "steckdosen": null, - "streaming": "USB.H\u00f6rsaal.Webcam", + "streaming_webcam": true, "teaching": true }, "5414.EG.001": { @@ -4842,7 +4763,7 @@ "de": "Steckdosen an den einzelnen Tischen", "en": "Sockets at the individual tables" }, - "streaming": "USB.H\u00f6rsaal.Webcam", + "streaming_webcam": true, "teaching": true }, "5416.01.003": { @@ -4928,7 +4849,7 @@ "de": "Steckdose an jedem dritten Platz", "en": "Socket at every third seat" }, - "streaming": "USB.H\u00f6rsaal.Webcam", + "streaming_webcam": true, "teaching": true }, "5416.01.004": { @@ -5014,7 +4935,7 @@ "de": "Steckdose an jedem dritten Platz", "en": "Socket at every third seat" }, - "streaming": "USB.H\u00f6rsaal.Webcam", + "streaming_webcam": true, "teaching": true }, "5502.01.250": { @@ -5089,7 +5010,7 @@ "de": "Keine Steckdosen im Bereich der Sitzreihen", "en": "No sockets in the area of the rows of seats" }, - "streaming": "USB.H\u00f6rsaal.Webcam", + "streaming_webcam": true, "teaching": true }, "5502.02.235": { @@ -5159,7 +5080,7 @@ "de": "Steckdosen in Bodentanks von jedem Platz aus erreichbar", "en": "Sockets in floor tanks accessible from each seat" }, - "streaming": "USB.H\u00f6rsaal.Webcam", + "streaming_webcam": true, "teaching": true }, "5502.EG.234": { @@ -5222,8 +5143,7 @@ } ], "seats": 30, - "steckdosen": null, - "streaming": "USB.H\u00f6rsaal.Webcam", + "streaming_webcam": true, "teaching": true }, "5502.EG.250": { @@ -5301,7 +5221,7 @@ "de": "Steckdose an jedem Platz", "en": "Socket at each seat" }, - "streaming": "USB.H\u00f6rsaal.Webcam", + "streaming_webcam": true, "teaching": true }, "5503.EG.337": { @@ -5371,7 +5291,7 @@ "de": "Steckdosen in Bodentanks von jedem Platz aus erreichbar", "en": "Sockets in floor tanks accessible from each seat" }, - "streaming": "USB.H\u00f6rsaal.Webcam", + "streaming_webcam": true, "teaching": true }, "5503.EG.350": { @@ -5454,7 +5374,7 @@ "de": "Keine Steckdosen im Bereich der Sitzreihen", "en": "No sockets in the area of the rows of seats" }, - "streaming": "USB.H\u00f6rsaal.Webcam", + "streaming_webcam": true, "teaching": true }, "5508.02.801": { @@ -5537,7 +5457,7 @@ "de": "Keine Steckdosen im Bereich der Sitzreihen", "en": "No sockets in the area of the rows of seats" }, - "streaming": "USB.H\u00f6rsaal.Webcam", + "streaming_webcam": true, "teaching": true }, "5510.02.001": { @@ -5616,8 +5536,7 @@ } ], "seats": 894, - "steckdosen": null, - "streaming": "USB.H\u00f6rsaal.Webcam, Streaming \u00fcber RBG", + "streaming_webcam": true, "teaching": true }, "5510.EG.001": { @@ -5696,8 +5615,7 @@ } ], "seats": 700, - "steckdosen": null, - "streaming": "USB.H\u00f6rsaal.Webcam, Streaming \u00fcber RBG", + "streaming_webcam": true, "teaching": true }, "5530.EG.003": { @@ -5749,8 +5667,6 @@ } ], "seats": 40, - "steckdosen": null, - "streaming": null, "teaching": true }, "5539.EG.001A": { @@ -5806,8 +5722,6 @@ } ], "seats": 400, - "steckdosen": null, - "streaming": null, "teaching": true }, "5539.EG.001B": { @@ -5863,8 +5777,7 @@ } ], "seats": 320, - "steckdosen": null, - "streaming": "Kamera mit H\u00f6rsaal-Ton \u00fcber USB", + "streaming_webcam": true, "teaching": true }, "5539.EG.002": { @@ -5920,8 +5833,7 @@ } ], "seats": 340, - "steckdosen": null, - "streaming": "Kamera mit H\u00f6rsaal-Ton \u00fcber USB", + "streaming_webcam": true, "teaching": true }, "5602.EG.001": { @@ -6007,7 +5919,7 @@ "de": "Steckdose an jedem zweiten Platz", "en": "Socket at every second place" }, - "streaming": "Streaming \u00fcber RBG", + "streaming_tumlive": true, "teaching": true }, "5604.EG.011": { @@ -6086,8 +5998,7 @@ } ], "seats": 100, - "steckdosen": null, - "streaming": "Streaming \u00fcber RBG", + "streaming_tumlive": true, "teaching": true }, "5606.EG.011": { @@ -6166,8 +6077,7 @@ } ], "seats": 100, - "steckdosen": null, - "streaming": "Streaming \u00fcber RBG", + "streaming_tumlive": true, "teaching": true }, "5620.01.101": { @@ -6253,10 +6163,7 @@ "de": "Steckdose an jedem dritten Platz", "en": "Socket at every third seat" }, - "streaming": { - "de": "USB.H\u00f6rsaal.Webcam, Streaming \u00fcber RBG", - "en": "USB.H\u00f6rsaal.Webcam, Streaming via RBG" - }, + "streaming_webcam": true, "teaching": true }, "5620.01.102": { @@ -6342,7 +6249,7 @@ "de": "Steckdose an jedem dritten Platz", "en": "Socket at every third seat" }, - "streaming": "USB.H\u00f6rsaal.Webcam, Streaming \u00fcber RBG", + "streaming_webcam": true, "teaching": true }, "5701.EG.026": { @@ -6382,8 +6289,7 @@ } ], "seats": 80, - "steckdosen": null, - "streaming": "USB.H\u00f6rsaal.Webcam", + "streaming_webcam": true, "teaching": true }, "5901.EG.051": { @@ -6462,8 +6368,7 @@ } ], "seats": 187, - "steckdosen": null, - "streaming": "USB.H\u00f6rsaal.Webcam", + "streaming_webcam": true, "teaching": true }, "8102.EG.104": { @@ -6533,7 +6438,6 @@ "de": "Steckdosen jeweils an den W\u00e4nden, au\u00dfer Platz 10+11", "en": "Sockets at each wall, except seat 10+11" }, - "streaming": null, "teaching": true }, "8102.EG.105": { @@ -6603,7 +6507,6 @@ "de": "Steckdosen jeweils an den W\u00e4nden", "en": "Sockets on the walls of each seat" }, - "streaming": null, "teaching": true }, "8102.EG.116": { @@ -6681,7 +6584,7 @@ "de": "Steckdose an jedem zweiten Platz", "en": "Socket at every second place" }, - "streaming": "USB.H\u00f6rsaal.Webcam", + "streaming_webcam": true, "teaching": true }, "8102.EG.117": { @@ -6767,7 +6670,7 @@ "de": "Steckdose an jedem zweiten Platz", "en": "Socket at every second place" }, - "streaming": "USB.H\u00f6rsaal.Webcam", + "streaming_webcam": true, "teaching": true }, "8120.01.101": { @@ -6846,8 +6749,6 @@ } ], "seats": 1236, - "steckdosen": null, - "streaming": null, "teaching": true }, "8120.EG.001": { @@ -6926,8 +6827,6 @@ } ], "seats": 300, - "steckdosen": null, - "streaming": null, "teaching": true }, "8120.EG.002": { @@ -6998,8 +6897,6 @@ } ], "seats": 51, - "steckdosen": null, - "streaming": null, "teaching": true }, "8120.EG.003": { @@ -7070,8 +6967,6 @@ } ], "seats": 51, - "steckdosen": null, - "streaming": null, "teaching": true } } diff --git a/data/external/scrapers/nat.py b/data/external/scrapers/nat.py index e510bd899..d3a99fc29 100644 --- a/data/external/scrapers/nat.py +++ b/data/external/scrapers/nat.py @@ -130,6 +130,8 @@ def _sanitise_room(room: dict) -> dict: room["building"]["campus"]["campus_id"] = campus_id if isinstance(room["steckdosen"], str): room["steckdosen"] = _(room["steckdosen"].rstrip(".")) + if room["steckdosen"] is None: + room.pop("steckdosen") room["campus"] = room["building"].pop("campus") # bauarbeiten is a str, indicating if something is wrong on in the room @@ -161,6 +163,21 @@ def _sanitise_room(room: dict) -> dict: ] for field_name in fields_with_no_information: room.pop(field_name) + if streaming := room.pop("streaming", None): + if streaming is not None: + if isinstance(streaming, dict): + streaming = streaming.get("de", streaming["en"]) + if not isinstance(streaming, str): + raise RuntimeError("invalid type for streaming: " + type(streaming)) + streaming_webcam = "USB.Hörsaal.Webcam" in streaming or "Kamera mit Hörsaal-Ton über USB" == streaming + streaming_tumlive = "RBG" in streaming + if streaming_webcam: + room["streaming_webcam"] = True + elif streaming_tumlive: + room["streaming_tumlive"] = True + else: + raise RuntimeError(f"new streaming '{streaming}'") + return room