Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. import todoist
  2. from datetime import date
  3.  
  4. api = todoist.TodoistAPI('<Insert_access_token_here>')
  5. api.sync()
  6.  
  7. # Get labels
  8. label_time_mapping = {}
  9. for label in api['labels']:
  10. if label['name'].endswith('_min'):
  11. time = int(label['name'].replace("_min", ""))
  12. label_time_mapping[label['id']] = time
  13.  
  14. # Get all items due today
  15. today = date.today()
  16. due_date = "{}-{}-{}".format(today.year, str(today.month).zfill(2), today.day)
  17.  
  18. # Calculate time needed
  19. total_time = 0
  20. num_items_due = 0
  21. for item in api['items']:
  22. # Filter for all items due today
  23. if item['due'] is not None:
  24. if item['due']['date'] == due_date and item['date_completed'] is None:
  25. for label in item['labels']:
  26. if label in label_time_mapping.keys():
  27. total_time += label_time_mapping[label]
  28. num_items_due += 1
  29.  
  30. hours = total_time // 60
  31. minutes = total_time % 60
  32.  
  33. 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