Compare commits

..

5 Commits
master ... dev

4 changed files with 15 additions and 44 deletions

View File

@ -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!
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.
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.
# Executing Autodoist

View File

@ -378,10 +378,12 @@ def check_header(level):
method = 0
try:
# Support for legacy structure
name = level['name']
method = 1
except:
try:
# Current structure
content = level['content']
method = 2
except:
@ -391,14 +393,14 @@ def check_header(level):
if name[:3] == '** ':
header_all_in_level = True
level.update(name=name[3:])
if name[:3] == '!* ':
if name[:3] == '!* ' or name[:3] == '_* ':
unheader_all_in_level = True
level.update(name=name[3:])
elif method == 2:
if content[:3] == '** ':
header_all_in_level = True
level.update(content=content[3:])
if content[:3] == '!* ':
if content[:3] == '!* ' or content[:3] == '_* ':
unheader_all_in_level = True
level.update(content=content[3:])
else:
@ -451,11 +453,7 @@ def run_recurring_lists_logic(args, api, item, child_items, child_items_all, reg
if item['due']['is_recurring']:
try:
# Check if the T0 task date has changed
if item['due']['date'] != item['date_old']:
# Save the new date for reference us
item.update(
date_old=item['due']['date'])
if item['due']['date'][:10] != item['date_old']:
# Mark children for action based on mode
if args.regeneration is not None:
@ -497,9 +495,9 @@ def run_recurring_lists_logic(args, api, item, child_items, child_items_all, reg
# Determine the difference in days set by todoist
nd = [
int(x) for x in item['due']['date'].split('-')]
int(x) for x in item['due']['date'][:10].split('-')]
od = [
int(x) for x in item['date_old'].split('-')]
int(x) for x in item['date_old'][:10].split('-')]
new_date = datetime(
nd[0], nd[1], nd[2])
@ -529,11 +527,15 @@ def run_recurring_lists_logic(args, api, item, child_items, child_items_all, reg
item.update(due=item_due)
# 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:
# If date has never been saved before, create a new entry
logging.debug(
'New recurring task detected: %s' % item['content'])
item['date_old'] = item['due']['date']
item['date_old'] = item['due']['date'][:10]
api.items.update(item['id'])
except:
@ -802,7 +804,7 @@ def autodoist_magic(args, api, label_id, regen_labels_id):
try:
if args.hide_future > 0 and 'due' in item.data and item['due'] is not None:
due_date = datetime.strptime(
item['due']['date'], "%Y-%m-%d")
item['due']['date'][:10], "%Y-%m-%d")
future_diff = (
due_date - datetime.today()).days
if future_diff >= args.hide_future:
@ -859,7 +861,7 @@ def autodoist_magic(args, api, label_id, regen_labels_id):
offset = item['content'][f+10:-1]
try:
item_due_date = item['due']['date']
item_due_date = item['due']['date'][:10]
item_due_date = datetime.strptime(
item_due_date, '%Y-%m-%d')
except:

View File

@ -1,17 +0,0 @@
[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

14
run.sh
View File

@ -1,14 +0,0 @@
#!/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