pyicloud
pyicloud copied to clipboard
Calendar Service Overhaul
Breaking change
There should not be any breaking changes.
Proposed change
- Firstly, this fixes an issue that came with an update to the icloud API where some service require a
dsid(this broke several services on pyicloud, including Contacts and Calendar). - Secondly, this includes a major overhaul of the Calendar service on pyicloud, allowing for adding and removing calendars and events, as well as adding Calendar and Event dataclass objects.
Type of change
- [ ] Dependency upgrade
- [] Bugfix (non-breaking change which fixes an issue)
- [ ] New service (thank you!)
- [x] New feature (which adds functionality to an existing service)
- [ ] Breaking change (fix/feature causing existing functionality to break)
- [ ] Code quality improvements to existing code or addition of tests
- [ ] Documentation or code sample
Example of code:
api = login("email", "pass")
calendar_service = api.calendar
cal = calendar_service.get_calendars(as_objs=True)[0]
event = calendar_service.EventObject("test", pGuid=cal.guid, startDate=datetime.today(), endDate=datetime.today() + timedelta(hours=1))
calendar_service.add_event(event)
Additional information
- This PR fixes or closes issue: fixes #392, #391, #389
- The
dsidfix is included in this pr because it is required for the new calendar features to work.
Checklist
- [x] The code change is tested and works locally.
- [x] Local tests pass. Your PR cannot be merged unless tests pass
- [x] There is no commented-out code in this PR.
- [ ] Tests have been added to verify that the new code works.
If user exposed functionality or configuration variables are added/changed:
- [x] Documentation added/updated to README
Thanks @ACB-prgm , do you know if this project is still maintained?
Thanks @ACB-prgm , do you know if this project is still maintained?
Do you mean pyicloud or my branch? I am not adding any more new features to my branch but would fix any issues that arise, and idk about the main branch.
@ACB-prgm I meant the main branch, but the last commit was on Feb,17 of this year. To check if the owners of this project will review all the pull requests that are pending to merge.
@JuanFran928 My guess is that they are not maintaining it anymore unfortunately. I just made a PR so that someone might find what I did useful and/or on the off chance it is still maintained, merge it.
Hello @ACB-prgm, thanks for the fix! :)
calendar_service = api.calendar.get_calendars(as_objs=True)[0]
calendar_service.get_events(from_dt=datetime.today() + timedelta(days=7), period="week", as_objs=True)
always results in AttributeError: 'CalendarObject' object has no attribute 'get_events'. I also tried it with as_objs=False, that results in
AttributeError: 'dict' object has no attribute 'get_events'
or without the [0], I'm using python 3.10.
Any ideas what could cause the error?
Trying it with
calendar_service = api.calendar
calendar_service.get_events(from_dt=datetime.today() + timedelta(days=7), period="week", as_objs=True)
yields:
Traceback (most recent call last):
File "E:\OneDrive\PyCharm\iCloudCalendar\api\testeasda.py", line 50, in <module>
calendar_service.get_events(from_dt=datetime.today() + timedelta(days=7), period="week", as_objs=True)
File "E:\OneDrive\PyCharm\iCloudCalendar\api\venv\lib\site-packages\pyicloud\services\calendar.py", line 296, in get_events
events[idx] = self.obj_from_dict(self.EventObject(), event)
TypeError: CalendarService.EventObject.__init__() missing 1 required positional argument: 'pGuid'
As for your first comment, it seems you figured it out that get_events() needs to be called from the calendarService class not the calendar object.
As for your second, this is actually an error on my end that I have just fixed and push a change to.
Please let me know if you are having any more trouble, and sorry for the late reply.
@ACB-prgm just wanted to say thanks for the update. It works for me. hopefully one day the main branch awake and apply your fix one day.