Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import todoist
- from datetime import date
- api = todoist.TodoistAPI('<Insert_access_token_here>')
- api.sync()
- # Get labels
- label_time_mapping = {}
- for label in api['labels']:
- if label['name'].endswith('_min'):
- time = int(label['name'].replace("_min", ""))
- label_time_mapping[label['id']] = time
- # Get all items due today
- today = date.today()
- due_date = "{}-{}-{}".format(today.year, str(today.month).zfill(2), today.day)
- # Calculate time needed
- total_time = 0
- num_items_due = 0
- for item in api['items']:
- # Filter for all items due today
- if item['due'] is not None:
- if item['due']['date'] == due_date and item['date_completed'] is None:
- for label in item['labels']:
- if label in label_time_mapping.keys():
- total_time += label_time_mapping[label]
- num_items_due += 1
- hours = total_time // 60
- minutes = total_time % 60
- print("Today your {} due items are estimated to take {}h {}min".format(num_items_due, hours, minutes))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement