EdupageAPI / edupage-api

A python library for accessing your Edupage account
https://edupageapi.github.io/edupage-api/
GNU General Public License v3.0
66 stars 13 forks source link

[Feature request] new timeline event class #54

Closed mrtineu closed 2 years ago

mrtineu commented 2 years ago

Is your feature request related to a problem? Please describe. Im making a discord bot that is wiritng homework to channel but the timeline event dont have the class for date to for homework or for test like when is the test

Describe the solution you'd like Please add the class for date to for homewrok type like if the event_type is homework or test the date_to class will be there

Thanks so much

ivanhrabcak commented 2 years ago

Hello, there is an example that shows how to get homework due dates. You can do a simmilar thing with tests, or anything else really.

This is not and never will be a feature because the data edupage returns is very messy and it could change any time. Everything you need is in the additional_data property of every timeline event (print it and you will see how to get the data you need, it's a dict)

Please reply and close this issue if this solved your problem. If you need further guidance, reply and I can give you more example code.

mrtineu commented 2 years ago

i printed the due_date but still it equals none how can i print only due date and why it returs this every time


nastenka
signin
settings
signin
interest
Homework from 2022-09-12 17:22:16
Vypočítať príklady 11, 13 a-e, j-l
—
Homework from 2022-09-12 11:34:11
6/pokus1
—
None
You have 0 unfinished homework assignments.```

please help
thanks
ivanhrabcak commented 2 years ago

Then it has no due date, that can also happen. Or the code I sent you is no longer valid. I can look into it and send up to date code later today.

mrtineu commented 2 years ago

It has date due and why there is like nastenka and etc

ivanhrabcak commented 2 years ago

It is there because we need all event the event types for edupage_api to work correctly. The idea was the users of edupage_api send us what is printed and we collect all the event types.

But I've already removed it (if you update after I create the release - later today - it won't happen anymore).

I will be sending you the code for getting due dates shortly.

ivanhrabcak commented 2 years ago

On homework, you can get the title, due date and some other metadata with this code:

# ...
notifications = edupage.get_notifications()
homework = list(filter(lambda x: x.event_type == EventType.HOMEWORK, notifications))

for hw in homework:
    # be careful, this might not always apply!
    # hw.get("date") may be `None` or an empty string sometimes.
    due_date = hw.additional_data.get("date") 
    title = hw.additional_data.get("nazov")

    print(f"{title} is due {due_date}")

I don't have any exams assigned so I couldn't figure that out, but I think this code will work, or very it will be simmilar, i.e.:

hw.additional_data.get("some_key_that_you_have_to_figure_out")

If this code doesn't work for exams, don't worry, it will be very easy to figure out on your own:

# To figure out just print:
print(hw.additional_data)

# You will see all the keys and values, it will be pretty easy to figure out.
# Example output:
#
# {'predmetid': '33346', 
#  'triedaid': '979850', 
#  'skupinyids': ['Trieda979850'], 
#  'nazov': 'Mili študenti. Prineste si prosím na stredu Yes 1 a maturitný zošit, Ďakujem a teším sa na vás! ', 
#  'popis': '', 'date': '2022-09-07', 
#  'typ': None, 'id': 'DC610EE4D9FD2509EA66', 
#  'skupiny': ['SK1'], 
#  'zmena': False, 
#  'oldVals': False, 
#  'superid': '253831', 
# 'etestCards': 0, 
# 'attachements': None, 
# 'planid': '6522'}

Please reply if you have any other issues, or close this issue if your problem is resolved.

mrtineu commented 2 years ago

thanks it wroks but still it displays this


nastenka
signin
settings
signin
interest````
at the begining why it still displays
ivanhrabcak commented 2 years ago

You just need to update edupage_api. You can do that by running this command in the terminal:

pip install --upgrade edupage_api
mrtineu commented 2 years ago

Thank you so much it works perfectly now and your cloud api is great too thanks