nerrixde / DSBApi

API für die in Deutschland verbreitete DSBmobile App für Vertretungspläne an Bildungseinrichtungen
GNU General Public License v3.0
35 stars 6 forks source link

Implement Units2019 // more flexible parser #11

Closed makusu720 closed 4 years ago

makusu720 commented 4 years ago

Das Beispiel funktioniert nicht ich bekomme diesen Fehler:

Traceback (most recent call last): File ".\dsbmobile.py", line 4, in <module> entries = dsbclient.fetch_entries() # Rückgabe einer JSON Liste an Arrays File "C:\Python38\lib\site-packages\dsbapi\__init__.py", line 62, in fetch_entries output.append(self.fetch_timetable(entry)) File "C:\Python38\lib\site-packages\dsbapi\__init__.py", line 96, in fetch_timetable "teacher": infos[7].text if infos[7].text != "\xa0" and infos[7].text != "+" else "---", IndexError: list index out of range

nerrixde commented 4 years ago

@GameHQ702 Can you provide the JSON-response you get? (Just insert a print after the request)

makusu720 commented 4 years ago

@nerrixDE I can't print it. If I want to print it, the same mistake occurs. This is my code:

import dsbapi

dsbclient = dsbapi.DSBApi("USERNAME", "PASS")
entries = dsbclient.fetch_entries() # Rückgabe einer JSON Liste an Arrays

print(entries)

print(entries[0]["date"]) # Datum des ersten Eintrags
nerrixde commented 4 years ago

@GameHQ702 No, just insert print(data) here Sure you have to open C:\Python38\lib\site-packages\dsbapi\__init__.py in an editor first

makusu720 commented 4 years ago

This is the data output:

{'Resultcode': 0, 'ResultStatusInfo': '', 'StartIndex': -1, 'ResultMenuItems': [{'Index': 0, 'IconLink': '', 'Title': 'Inhalte', 'Childs': [{'Index': 1, 'IconLink': 'https://app.dsbcontrol.de/static/androidicons/Tiles.png', 'Title': 'Aushänge', 'Root': {'Id': '', 'Date': '', 'Title': '', 'Detail': '', 'Tags': '', 'ConType': 0, 'Prio': 0, 'Index': 0, 'Childs': [{'Id': '0d380292-dbea-4d16-90ce-ef4273da8eb2', 'Date': '01.11.2019 14:24', 'Title': 'Terminplan Stand 01.11.2019', 'Detail': '', 'Tags': '', 'ConType': 2, 'Prio': 0, 'Index': 0, 'Childs': [{'Id': '0d380292-dbea-4d16-90ce-ef4273da8eb2', 'Date': '01.11.2019 14:24', 'Title': 'Terminplan Stand 01.11.2019.pdf', 'Detail': 'https://app.dsbcontrol.de/data/094feb60-bb60-4aee-bda1-8941eded0806/0d380292-dbea-4d16-90ce-ef4273da8eb2/0d380292-dbea-4d16-90ce-ef4273da8eb2_000.jpg', 'Tags': '', 'ConType': 4, 'Prio': 0, 'Index': 0, 'Childs': [], 'Preview': '094feb60-bb60-4aee-bda1-8941eded0806/0d380292-dbea-4d16-90ce-ef4273da8eb2/0d380292-dbea-4d16-90ce-ef4273da8eb2_000.jpg'}, {'Id': '0d380292-dbea-4d16-90ce-ef4273da8eb2', 'Date': '01.11.2019 14:24', 'Title': 'Terminplan Stand 01.11.2019.pdf', 'Detail': 'https://app.dsbcontrol.de/data/094feb60-bb60-4aee-bda1-8941eded0806/0d380292-dbea-4d16-90ce-ef4273da8eb2/0d380292-dbea-4d16-90ce-ef4273da8eb2_001.jpg', 'Tags': '', 'ConType': 4, 'Prio': 0, 'Index': 1, 'Childs': [], 'Preview': '094feb60-bb60-4aee-bda1-8941eded0806/0d380292-dbea-4d16-90ce-ef4273da8eb2/0d380292-dbea-4d16-90ce-ef4273da8eb2_001.jpg'}, {'Id': '0d380292-dbea-4d16-90ce-ef4273da8eb2', 'Date': '01.11.2019 14:24', 'Title': 'Terminplan Stand 01.11.2019.pdf', 'Detail': 'https://app.dsbcontrol.de/data/094feb60-bb60-4aee-bda1-8941eded0806/0d380292-dbea-4d16-90ce-ef4273da8eb2/0d380292-dbea-4d16-90ce-ef4273da8eb2_002.jpg', 'Tags': '', 'ConType': 4, 'Prio': 0, 'Index': 2, 'Childs': [], 'Preview': '094feb60-bb60-4aee-bda1-8941eded0806/0d380292-dbea-4d16-90ce-ef4273da8eb2/0d380292-dbea-4d16-90ce-ef4273da8eb2_002.jpg'}, {'Id': '0d380292-dbea-4d16-90ce-ef4273da8eb2', 'Date': '01.11.2019 14:24', 'Title': 'Terminplan Stand 01.11.2019.pdf', 'Detail': 'https://app.dsbcontrol.de/data/094feb60-bb60-4aee-bda1-8941eded0806/0d380292-dbea-4d16-90ce-ef4273da8eb2/0d380292-dbea-4d16-90ce-ef4273da8eb2_003.jpg', 'Tags': '', 'ConType': 4, 'Prio': 0, 'Index': 3, 'Childs': [], 'Preview': '094feb60-bb60-4aee-bda1-8941eded0806/0d380292-dbea-4d16-90ce-ef4273da8eb2/0d380292-dbea-4d16-90ce-ef4273da8eb2_003.jpg'}, {'Id': '0d380292-dbea-4d16-90ce-ef4273da8eb2', 'Date': '01.11.2019 14:24', 'Title': 'Terminplan Stand 01.11.2019.pdf', 'Detail': 'https://app.dsbcontrol.de/data/094feb60-bb60-4aee-bda1-8941eded0806/0d380292-dbea-4d16-90ce-ef4273da8eb2/0d380292-dbea-4d16-90ce-ef4273da8eb2_004.jpg', 'Tags': '', 'ConType': 4, 'Prio': 0, 'Index': 4, 'Childs': [], 'Preview': '094feb60-bb60-4aee-bda1-8941eded0806/0d380292-dbea-4d16-90ce-ef4273da8eb2/0d380292-dbea-4d16-90ce-ef4273da8eb2_004.jpg'}, {'Id': '0d380292-dbea-4d16-90ce-ef4273da8eb2', 'Date': '01.11.2019 14:24', 'Title': 'Terminplan Stand 01.11.2019.pdf', 'Detail': 'https://app.dsbcontrol.de/data/094feb60-bb60-4aee-bda1-8941eded0806/0d380292-dbea-4d16-90ce-ef4273da8eb2/0d380292-dbea-4d16-90ce-ef4273da8eb2_005.jpg', 'Tags': '', 'ConType': 4, 'Prio': 0, 'Index': 5, 'Childs': [], 'Preview': '094feb60-bb60-4aee-bda1-8941eded0806/0d380292-dbea-4d16-90ce-ef4273da8eb2/0d380292-dbea-4d16-90ce-ef4273da8eb2_005.jpg'}, {'Id': '0d380292-dbea-4d16-90ce-ef4273da8eb2', 'Date': '01.11.2019 14:24', 'Title': 'Terminplan Stand 01.11.2019.pdf', 'Detail': 'https://app.dsbcontrol.de/data/094feb60-bb60-4aee-bda1-8941eded0806/0d380292-dbea-4d16-90ce-ef4273da8eb2/0d380292-dbea-4d16-90ce-ef4273da8eb2_006.jpg', 'Tags': '', 'ConType': 4, 'Prio': 0, 'Index': 6, 'Childs': [], 'Preview': '094feb60-bb60-4aee-bda1-8941eded0806/0d380292-dbea-4d16-90ce-ef4273da8eb2/0d380292-dbea-4d16-90ce-ef4273da8eb2_006.jpg'}], 'Preview': ''}, {'Id': 'f39ddd98-5fe9-4348-aab6-d8156e7fc848', 'Date': '22.11.2019 16:28', 'Title': 'Mensa Speiseplan Aktuell', 'Detail': '', 'Tags': '', 'ConType': 2, 'Prio': 0, 'Index': 0, 'Childs': [{'Id': 'f39ddd98-5fe9-4348-aab6-d8156e7fc848', 'Date': '22.11.2019 16:28', 'Title': 'Mensa Speiseplan Aktuell.pdf', 'Detail': 'https://app.dsbcontrol.de/data/094feb60-bb60-4aee-bda1-8941eded0806/f39ddd98-5fe9-4348-aab6-d8156e7fc848/f39ddd98-5fe9-4348-aab6-d8156e7fc848_000.jpg', 'Tags': '', 'ConType': 4, 'Prio': 0, 'Index': 0, 'Childs': [], 'Preview': '094feb60-bb60-4aee-bda1-8941eded0806/f39ddd98-5fe9-4348-aab6-d8156e7fc848/f39ddd98-5fe9-4348-aab6-d8156e7fc848_000.jpg'}], 'Preview': ''}, {'Id': '4940052c-26b4-4ba5-bcf0-8cc0a26c60e7', 'Date': '17.10.2019 17:13', 'Title': '93128af3-f73c-434d-b931-03c0399ea15d', 'Detail': '', 'Tags': '', 'ConType': 2, 'Prio': 0, 'Index': 0, 'Childs': [{'Id': '4940052c-26b4-4ba5-bcf0-8cc0a26c60e7', 'Date': '17.10.2019 17:13', 'Title': '93128af3-f73c-434d-b931-03c0399ea15d.pdf', 'Detail': 'https://app.dsbcontrol.de/data/094feb60-bb60-4aee-bda1-8941eded0806/4940052c-26b4-4ba5-bcf0-8cc0a26c60e7/4940052c-26b4-4ba5-bcf0-8cc0a26c60e7_000.jpg', 'Tags': '', 'ConType': 4, 'Prio': 0, 'Index': 0, 'Childs': [], 'Preview': '094feb60-bb60-4aee-bda1-8941eded0806/4940052c-26b4-4ba5-bcf0-8cc0a26c60e7/4940052c-26b4-4ba5-bcf0-8cc0a26c60e7_000.jpg'}, {'Id': '4940052c-26b4-4ba5-bcf0-8cc0a26c60e7', 'Date': '17.10.2019 17:13', 'Title': '93128af3-f73c-434d-b931-03c0399ea15d.pdf', 'Detail': 'https://app.dsbcontrol.de/data/094feb60-bb60-4aee-bda1-8941eded0806/4940052c-26b4-4ba5-bcf0-8cc0a26c60e7/4940052c-26b4-4ba5-bcf0-8cc0a26c60e7_001.jpg', 'Tags': '', 'ConType': 4, 'Prio': 0, 'Index': 1, 'Childs': [], 'Preview': '094feb60-bb60-4aee-bda1-8941eded0806/4940052c-26b4-4ba5-bcf0-8cc0a26c60e7/4940052c-26b4-4ba5-bcf0-8cc0a26c60e7_001.jpg'}, {'Id': '4940052c-26b4-4ba5-bcf0-8cc0a26c60e7', 'Date': '17.10.2019 17:13', 'Title': '93128af3-f73c-434d-b931-03c0399ea15d.pdf', 'Detail': 'https://app.dsbcontrol.de/data/094feb60-bb60-4aee-bda1-8941eded0806/4940052c-26b4-4ba5-bcf0-8cc0a26c60e7/4940052c-26b4-4ba5-bcf0-8cc0a26c60e7_002.jpg', 'Tags': '', 'ConType': 4, 'Prio': 0, 'Index': 2, 'Childs': [], 'Preview': '094feb60-bb60-4aee-bda1-8941eded0806/4940052c-26b4-4ba5-bcf0-8cc0a26c60e7/4940052c-26b4-4ba5-bcf0-8cc0a26c60e7_002.jpg'}], 'Preview': ''}], 'Preview': ''}, 'Childs': [], 'MethodName': 'tiles', 'NewCount': 0, 'SaveLastState': True}, {'Index': 0, 'IconLink': 'https://app.dsbcontrol.de/static/androidicons/Timetable.png', 'Title': 'Pläne', 'Root': {'Id': '', 'Date': '', 'Title': '', 'Detail': '', 'Tags': '', 'ConType': 0, 'Prio': 0, 'Index': 0, 'Childs': [{'Id': '8765a6d7-d511-4dd3-b01c-46488e24712d', 'Date': '22.11.2019 11:38', 'Title': 'Oberstufe App heute', 'Detail': '', 'Tags': '', 'ConType': 2, 'Prio': 0, 'Index': 0, 'Childs': [{'Id': '8765a6d7-d511-4dd3-b01c-46488e24712d', 'Date': '22.11.2019 11:38', 'Title': 'subst_001.htm', 'Detail': 'https://app.dsbcontrol.de/data/094feb60-bb60-4aee-bda1-8941eded0806/8765a6d7-d511-4dd3-b01c-46488e24712d/subst_001.htm', 'Tags': '', 'ConType': 3, 'Prio': 0, 'Index': 0, 'Childs': [], 'Preview': '094feb60-bb60-4aee-bda1-8941eded0806/8765a6d7-d511-4dd3-b01c-46488e24712d/preview.png'}], 'Preview': ''}, {'Id': '95999c92-6596-4b13-bc66-e7fa247beaf2', 'Date': '22.11.2019 11:38', 'Title': 'Oberstufe App morgen', 'Detail': '', 'Tags': '', 'ConType': 2, 'Prio': 0, 'Index': 0, 'Childs': [{'Id': '95999c92-6596-4b13-bc66-e7fa247beaf2', 'Date': '22.11.2019 11:38', 'Title': 'subst_001.htm', 'Detail': 'https://app.dsbcontrol.de/data/094feb60-bb60-4aee-bda1-8941eded0806/95999c92-6596-4b13-bc66-e7fa247beaf2/subst_001.htm', 'Tags': '', 'ConType': 3, 'Prio': 0, 'Index': 0, 'Childs': [], 'Preview': '094feb60-bb60-4aee-bda1-8941eded0806/95999c92-6596-4b13-bc66-e7fa247beaf2/preview.png'}], 'Preview': ''}, {'Id': '81fc3f12-e827-47e7-9a6c-1ea3c2b0b3fe', 'Date': '22.11.2019 11:38', 'Title': 'Gymnasium App heute', 'Detail': '', 'Tags': '', 'ConType': 2, 'Prio': 0, 'Index': 0, 'Childs': [{'Id': '81fc3f12-e827-47e7-9a6c-1ea3c2b0b3fe', 'Date': '22.11.2019 11:38', 'Title': 'subst_001.htm', 'Detail': 'https://app.dsbcontrol.de/data/094feb60-bb60-4aee-bda1-8941eded0806/81fc3f12-e827-47e7-9a6c-1ea3c2b0b3fe/subst_001.htm', 'Tags': '', 'ConType': 3, 'Prio': 0, 'Index': 0, 'Childs': [], 'Preview': '094feb60-bb60-4aee-bda1-8941eded0806/81fc3f12-e827-47e7-9a6c-1ea3c2b0b3fe/preview.png'}, {'Id': '81fc3f12-e827-47e7-9a6c-1ea3c2b0b3fe', 'Date': '22.11.2019 11:38', 'Title': 'subst_001.htm', 'Detail': 'https://app.dsbcontrol.de/data/094feb60-bb60-4aee-bda1-8941eded0806/81fc3f12-e827-47e7-9a6c-1ea3c2b0b3fe/subst_002.htm', 'Tags': '', 'ConType': 3, 'Prio': 0, 'Index': 0, 'Childs': [], 'Preview': '094feb60-bb60-4aee-bda1-8941eded0806/81fc3f12-e827-47e7-9a6c-1ea3c2b0b3fe/preview.png'}], 'Preview': ''}, {'Id': 'c01eb357-d0bd-4636-8e31-cabf47da3e89', 'Date': '22.11.2019 11:38', 'Title': 'Gymnasium App morgen', 'Detail': '', 'Tags': '', 'ConType': 2, 'Prio': 0, 'Index': 0, 'Childs': [{'Id': 'c01eb357-d0bd-4636-8e31-cabf47da3e89', 'Date': '22.11.2019 11:38', 'Title': 'subst_001.htm', 'Detail': 'https://app.dsbcontrol.de/data/094feb60-bb60-4aee-bda1-8941eded0806/c01eb357-d0bd-4636-8e31-cabf47da3e89/subst_001.htm', 'Tags': '', 'ConType': 3, 'Prio': 0, 'Index': 0, 'Childs': [], 'Preview': '094feb60-bb60-4aee-bda1-8941eded0806/c01eb357-d0bd-4636-8e31-cabf47da3e89/preview.png'}], 'Preview': ''}, {'Id': 'da551fdc-21ef-45fa-bb1c-b1aceba2efd4', 'Date': '22.11.2019 11:38', 'Title': 'Realschule App heute', 'Detail': '', 'Tags': '', 'ConType': 2, 'Prio': 0, 'Index': 0, 'Childs': [{'Id': 'da551fdc-21ef-45fa-bb1c-b1aceba2efd4', 'Date': '22.11.2019 11:38', 'Title': 'subst_001.htm', 'Detail': 'https://app.dsbcontrol.de/data/094feb60-bb60-4aee-bda1-8941eded0806/da551fdc-21ef-45fa-bb1c-b1aceba2efd4/subst_001.htm', 'Tags': '', 'ConType': 3, 'Prio': 0, 'Index': 0, 'Childs': [], 'Preview': '094feb60-bb60-4aee-bda1-8941eded0806/da551fdc-21ef-45fa-bb1c-b1aceba2efd4/preview.png'}], 'Preview': ''}, {'Id': 'bf236d3c-a3aa-4451-9a58-bc0f5ae07cbb', 'Date': '22.11.2019 11:38', 'Title': 'RealschuleApp morgen', 'Detail': '', 'Tags': '', 'ConType': 2, 'Prio': 0, 'Index': 0, 'Childs': [{'Id': 'bf236d3c-a3aa-4451-9a58-bc0f5ae07cbb', 'Date': '22.11.2019 11:38', 'Title': 'subst_001.htm', 'Detail': 'https://app.dsbcontrol.de/data/094feb60-bb60-4aee-bda1-8941eded0806/bf236d3c-a3aa-4451-9a58-bc0f5ae07cbb/subst_001.htm', 'Tags': '', 'ConType': 3, 'Prio': 0, 'Index': 0, 'Childs': [], 'Preview': '094feb60-bb60-4aee-bda1-8941eded0806/bf236d3c-a3aa-4451-9a58-bc0f5ae07cbb/preview.png'}], 'Preview': ''}, {'Id': '36de3be8-1bdb-406c-b3b6-73039d7b4ea8', 'Date': '22.11.2019 11:38', 'Title': 'HauptschuleApp heute', 'Detail': '', 'Tags': '', 'ConType': 2, 'Prio': 0, 'Index': 0, 'Childs': [{'Id': '36de3be8-1bdb-406c-b3b6-73039d7b4ea8', 'Date': '22.11.2019 11:38', 'Title': 'subst_001.htm', 'Detail': 'https://app.dsbcontrol.de/data/094feb60-bb60-4aee-bda1-8941eded0806/36de3be8-1bdb-406c-b3b6-73039d7b4ea8/subst_001.htm', 'Tags': '', 'ConType': 3, 'Prio': 0, 'Index': 0, 'Childs': [], 'Preview': '094feb60-bb60-4aee-bda1-8941eded0806/36de3be8-1bdb-406c-b3b6-73039d7b4ea8/preview.png'}], 'Preview': ''}, {'Id': '61f00a89-1267-4564-b163-943eedbb50c7', 'Date': '22.11.2019 11:38', 'Title': 'HauptschuleAppmorgen', 'Detail': '', 'Tags': '', 'ConType': 2, 'Prio': 0, 'Index': 0, 'Childs': [{'Id': '61f00a89-1267-4564-b163-943eedbb50c7', 'Date': '22.11.2019 11:38', 'Title': 'subst_001.htm', 'Detail': 'https://app.dsbcontrol.de/data/094feb60-bb60-4aee-bda1-8941eded0806/61f00a89-1267-4564-b163-943eedbb50c7/subst_001.htm', 'Tags': '', 'ConType': 3, 'Prio': 0, 'Index': 0, 'Childs': [], 'Preview': '094feb60-bb60-4aee-bda1-8941eded0806/61f00a89-1267-4564-b163-943eedbb50c7/preview.png'}], 'Preview': ''}], 'Preview': ''}, 'Childs': [], 'MethodName': 'timetable', 'NewCount': 0, 'SaveLastState': True}], 'MethodName': '', 'NewCount': 0, 'SaveLastState': True}, {'Index': 1, 'IconLink': '', 'Title': 'Sonstiges', 'Childs': [{'Index': 0, 'IconLink': 'https://app.dsbcontrol.de/static/androidicons/Settings.png', 'Title': 'Einstellungen', 'Childs': [], 'MethodName': 'settings', 'NewCount': 0, 'SaveLastState': False}, {'Index': 1, 'IconLink': 'https://app.dsbcontrol.de/static/androidicons/Feedback.png', 'Title': 'Feedback', 'Childs': [], 'MethodName': 'feedback', 'NewCount': 0, 'SaveLastState': False}, {'Index': 2, 'IconLink': 'https://app.dsbcontrol.de/static/androidicons/About.png', 'Title': 'Info', 'Childs': [], 'MethodName': 'about', 'NewCount': 0, 'SaveLastState': False}, {'Index': 3, 'IconLink': 'https://app.dsbcontrol.de/static/androidicons/Logout.png', 'Title': 'Logout', 'Childs': [], 'MethodName': 'logout', 'NewCount': 0, 'SaveLastState': False}], 'MethodName': '', 'NewCount': 0, 'SaveLastState': True}], 'ChannelType': 0, 'MandantId': '40d8da6a-643f-4fc0-bb12-6fb8f615df7d'}
nerrixde commented 4 years ago

@GameHQ702 Leider brauche ich deine DSB-Login-Daten, da ich so den Fehler effektiver untersuchen kann. Ohne Login-Daten würde es viel länger dauern und aufwändiger sein, diesen Aufwand kann man vermeiden.

Bitte Schreibe Username und Password hier rein: https://keybase.io/encrypt#nerrix_de

und Copy & Paste die verschlüsselte Nachricht in diese Issue, nur ich kann sie entschlüsseln.

makusu720 commented 4 years ago

@nerrixDE

-----BEGIN PGP MESSAGE-----
Version: Keybase OpenPGP v2.1.3
Comment: https://keybase.io/crypto

wcBMA2Y76++sMEu0AQgAmjpNlL0S/8duUtLwP3UkkfrhdrYznfsqjMi2LJhe1s8y
5/RonJYMwP5IQTp6LMccJTukEVv/oy78lXv7sph3xsGdD8+U0hbY/8RSoVBraNXL
GmQZz3xSXK+/Z/ATPEb2H13U7D4sIc6IxwFpP22mt9G+zMNnfRWpzaszGEeG0mPc
2VKnHvrERzspjBGFHg2GC4O3eP8YQ4Mi90NVJvz1Btbsq9Ue/ods+qO9q9/6RYaX
pZ54qLnvBxdU0+eFzKZsvqTWsxbzpixhbWSTjBhQkW7wyloCsgCIYE1HtBhABEwO
x3vAufVWKlBqud+NjtEVCxS9/6em6voYiV2zztL49tJfAapbThPRuXyyOu/CvJbV
+e+02JJZHJ/WseW60AmCaTV/ROe96cqBKz9WquY6kEcPIWR9GMH6TA6Krjgn68n1
WG79Dsv+q+RsJh4rp8AZb8Hm3hFZgUxvpkFIyXeX0eM=
=xcBX
-----END PGP MESSAGE-----
nerrixde commented 4 years ago

@GameHQ702 Jap, leider ist DSBApi nicht mit dem Setup deiner Schule kompatibel und man müsste diesen Fall extra implementieren. Es gibt da sicher eine Lösung, nur mir fehlt zur Zeit ein wenig die Zeit dafür. Sonst stehen die PRs ja offen.

makusu720 commented 4 years ago

ok schade, trotzdem danke für die Hilfe

nerrixde commented 4 years ago

I think this is dead / unrealistic rn.