|
11 | 11 | import pickle |
12 | 12 | import time |
13 | 13 |
|
14 | | -from todoist_api_python.api import TodoistAPI |
15 | | -from todoist_api_python.endpoints import get_sync_url |
16 | | -from todoist_api_python.http_requests import get |
17 | | -from todoist_api_python.models import Task |
| 14 | + |
18 | 15 | import main |
19 | 16 | from todo_task import TodTask |
| 17 | +from todo_api_plus import TodoAPIPlus |
20 | 18 | import config |
21 | 19 | import habitica |
22 | 20 |
|
23 | 21 |
|
24 | 22 | def get_tasks(token): |
25 | 23 | tasks = [] |
26 | | - api = TodoistAPI(token) |
| 24 | + api = TodoAPIPlus(token) |
27 | 25 | try: |
28 | 26 | tasks = api.get_tasks() |
29 | 27 | except Exception as error: |
30 | 28 | print(error) |
31 | 29 | return tasks, api |
32 | 30 |
|
33 | 31 |
|
34 | | -def dict_to_task(obj, url): |
35 | | - obj['comment_count'] = obj['note_count'] |
36 | | - obj['is_completed'] = (obj['completed_at'] != '') |
37 | | - obj['created_at'] = "unknown" |
38 | | - obj['creator_id'] = obj['user_id'] |
39 | | - obj['description'] = obj['content'] |
40 | | - obj["priority"] = '' |
41 | | - obj['url'] = url |
42 | | - return Task.from_dict(obj) |
43 | | - |
44 | | - |
45 | | -def get_all_completed_items(api): |
46 | | - url = get_sync_url('completed/get_all') |
47 | | - completed_items = get(api._session, url, api._token) |
48 | | - tasks = completed_items['items'] |
49 | | - return [dict_to_task(obj, url) for obj in tasks] |
50 | | - |
51 | | - |
52 | 32 | def sync_todoist_to_habitica(): |
53 | 33 | # todayFilter = todo_api.filters.add('todayFilter', 'today') |
54 | 34 |
|
@@ -84,7 +64,7 @@ def sync_todoist_to_habitica(): |
84 | 64 | match_dict = main.update_hab_matchDict(hab_tasks, match_dict) |
85 | 65 |
|
86 | 66 | # We'll want to just... pull all the unmatched completed tasks out of our lists of tasks. Yeah? |
87 | | - tod_done = [TodTask(task) for task in get_all_completed_items(todo_api)] |
| 67 | + tod_done = [TodTask(task) for task in todo_api.get_all_completed_items()] |
88 | 68 | tod_uniq, hab_uniq = main.get_uniqs(match_dict, tod_done, hab_tasks) |
89 | 69 |
|
90 | 70 | # Okay, so what if there are two matched tasks in the two uniq lists that really should be paired? |
|
0 commit comments