forked from mirrors/autodoist
Compare commits
3 Commits
Author | SHA1 | Date |
---|---|---|
earnest ma | 9949984269 | |
earnest ma | 13eb8ad46a | |
Hoffelhas | 67935a5b0c |
|
@ -108,7 +108,7 @@ By setting an alternative time for the end-of-day you can now finish your work a
|
||||||
|
|
||||||
Todoist allows the asterisk symbol `* ` to be used to ensure tasks can't be checked by turning them into headers. Now you are able to do this en masse!
|
Todoist allows the asterisk symbol `* ` to be used to ensure tasks can't be checked by turning them into headers. Now you are able to do this en masse!
|
||||||
|
|
||||||
Simply add `** ` or `!* ` in front of a project, section, or top item, to automatically turn all the items that it includes into respectively headers or checkable tasks.
|
Simply add `** ` or `!* ` in front of a project, section, or top item, to automatically turn all the items that it includes into respectively headers or checkable tasks. Note: when used in a project title or section title, Todoist will replace an exclamation mark with an underscore; this functionality should nevertheless still work.
|
||||||
|
|
||||||
# Executing Autodoist
|
# Executing Autodoist
|
||||||
|
|
||||||
|
|
26
autodoist.py
26
autodoist.py
|
@ -378,12 +378,10 @@ def check_header(level):
|
||||||
method = 0
|
method = 0
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Support for legacy structure
|
|
||||||
name = level['name']
|
name = level['name']
|
||||||
method = 1
|
method = 1
|
||||||
except:
|
except:
|
||||||
try:
|
try:
|
||||||
# Current structure
|
|
||||||
content = level['content']
|
content = level['content']
|
||||||
method = 2
|
method = 2
|
||||||
except:
|
except:
|
||||||
|
@ -393,14 +391,14 @@ def check_header(level):
|
||||||
if name[:3] == '** ':
|
if name[:3] == '** ':
|
||||||
header_all_in_level = True
|
header_all_in_level = True
|
||||||
level.update(name=name[3:])
|
level.update(name=name[3:])
|
||||||
if name[:3] == '!* ' or name[:3] == '_* ':
|
if name[:3] == '!* ':
|
||||||
unheader_all_in_level = True
|
unheader_all_in_level = True
|
||||||
level.update(name=name[3:])
|
level.update(name=name[3:])
|
||||||
elif method == 2:
|
elif method == 2:
|
||||||
if content[:3] == '** ':
|
if content[:3] == '** ':
|
||||||
header_all_in_level = True
|
header_all_in_level = True
|
||||||
level.update(content=content[3:])
|
level.update(content=content[3:])
|
||||||
if content[:3] == '!* ' or content[:3] == '_* ':
|
if content[:3] == '!* ':
|
||||||
unheader_all_in_level = True
|
unheader_all_in_level = True
|
||||||
level.update(content=content[3:])
|
level.update(content=content[3:])
|
||||||
else:
|
else:
|
||||||
|
@ -453,7 +451,11 @@ def run_recurring_lists_logic(args, api, item, child_items, child_items_all, reg
|
||||||
if item['due']['is_recurring']:
|
if item['due']['is_recurring']:
|
||||||
try:
|
try:
|
||||||
# Check if the T0 task date has changed
|
# Check if the T0 task date has changed
|
||||||
if item['due']['date'][:10] != item['date_old']:
|
if item['due']['date'] != item['date_old']:
|
||||||
|
|
||||||
|
# Save the new date for reference us
|
||||||
|
item.update(
|
||||||
|
date_old=item['due']['date'])
|
||||||
|
|
||||||
# Mark children for action based on mode
|
# Mark children for action based on mode
|
||||||
if args.regeneration is not None:
|
if args.regeneration is not None:
|
||||||
|
@ -495,9 +497,9 @@ def run_recurring_lists_logic(args, api, item, child_items, child_items_all, reg
|
||||||
|
|
||||||
# Determine the difference in days set by todoist
|
# Determine the difference in days set by todoist
|
||||||
nd = [
|
nd = [
|
||||||
int(x) for x in item['due']['date'][:10].split('-')]
|
int(x) for x in item['due']['date'].split('-')]
|
||||||
od = [
|
od = [
|
||||||
int(x) for x in item['date_old'][:10].split('-')]
|
int(x) for x in item['date_old'].split('-')]
|
||||||
|
|
||||||
new_date = datetime(
|
new_date = datetime(
|
||||||
nd[0], nd[1], nd[2])
|
nd[0], nd[1], nd[2])
|
||||||
|
@ -527,15 +529,11 @@ def run_recurring_lists_logic(args, api, item, child_items, child_items_all, reg
|
||||||
item.update(due=item_due)
|
item.update(due=item_due)
|
||||||
# item.update(due={'date': '2020-05-29', 'is_recurring': True, 'string': 'every day'})
|
# item.update(due={'date': '2020-05-29', 'is_recurring': True, 'string': 'every day'})
|
||||||
|
|
||||||
# Save the new date for reference us
|
|
||||||
item.update(
|
|
||||||
date_old=item['due']['date'][:10])
|
|
||||||
|
|
||||||
except:
|
except:
|
||||||
# If date has never been saved before, create a new entry
|
# If date has never been saved before, create a new entry
|
||||||
logging.debug(
|
logging.debug(
|
||||||
'New recurring task detected: %s' % item['content'])
|
'New recurring task detected: %s' % item['content'])
|
||||||
item['date_old'] = item['due']['date'][:10]
|
item['date_old'] = item['due']['date']
|
||||||
api.items.update(item['id'])
|
api.items.update(item['id'])
|
||||||
|
|
||||||
except:
|
except:
|
||||||
|
@ -804,7 +802,7 @@ def autodoist_magic(args, api, label_id, regen_labels_id):
|
||||||
try:
|
try:
|
||||||
if args.hide_future > 0 and 'due' in item.data and item['due'] is not None:
|
if args.hide_future > 0 and 'due' in item.data and item['due'] is not None:
|
||||||
due_date = datetime.strptime(
|
due_date = datetime.strptime(
|
||||||
item['due']['date'][:10], "%Y-%m-%d")
|
item['due']['date'], "%Y-%m-%d")
|
||||||
future_diff = (
|
future_diff = (
|
||||||
due_date - datetime.today()).days
|
due_date - datetime.today()).days
|
||||||
if future_diff >= args.hide_future:
|
if future_diff >= args.hide_future:
|
||||||
|
@ -861,7 +859,7 @@ def autodoist_magic(args, api, label_id, regen_labels_id):
|
||||||
offset = item['content'][f+10:-1]
|
offset = item['content'][f+10:-1]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
item_due_date = item['due']['date'][:10]
|
item_due_date = item['due']['date']
|
||||||
item_due_date = datetime.strptime(
|
item_due_date = datetime.strptime(
|
||||||
item_due_date, '%Y-%m-%d')
|
item_due_date, '%Y-%m-%d')
|
||||||
except:
|
except:
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Autodoist
|
||||||
|
After=syslog.target
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
RestartSec=5s
|
||||||
|
Type=simple
|
||||||
|
User=earne
|
||||||
|
Group=earne
|
||||||
|
WorkingDirectory=/home/earne/autodoist
|
||||||
|
ExecStart=/home/earne/autodoist/run.sh
|
||||||
|
Restart=always
|
||||||
|
# Environment=
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
|
@ -0,0 +1,14 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
if [ ! -d venv ]; then
|
||||||
|
echo "Creating virtualenv and installing requirements"
|
||||||
|
python3 -m venv venv
|
||||||
|
venv/bin/pip3 install -r requirements.txt
|
||||||
|
fi
|
||||||
|
|
||||||
|
venv/bin/python3 autodoist.py \
|
||||||
|
-a $(cat .api-token) \
|
||||||
|
-l Next \
|
||||||
|
-r 2 \
|
||||||
|
-e 1 \
|
||||||
|
--delay 7
|
Loading…
Reference in New Issue