-
-
Save liuxk99/f6f971adc4354f7e2fae959f16ac77fa to your computer and use it in GitHub Desktop.
pomotodo task switch reminder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import json | |
from datetime import datetime, timedelta | |
import os | |
if os.name == 'nt': | |
from win10toast import ToastNotifier | |
toaster = ToastNotifier() | |
//from config import * | |
POMO_URL='https://api.pomotodo.com/1/pomos' | |
API_TOKEN='YOUR TOKEN' | |
headers = {'Authorization': 'token '+API_TOKEN} | |
parameters = {'started_later_than': (datetime.today() - timedelta(days=1)).strftime('%Y-%m-%d')} | |
result = requests.get(POMO_URL, headers=headers, params=parameters) | |
result_j = result.json() | |
if len(result_j) > 8: | |
last_res = result_j[-8:] | |
else: | |
last_res = result_j | |
task_dict = {} | |
for pomo in last_res: | |
description = pomo['description'] | |
for task in description.split('+'): | |
task = task.strip() | |
if task in task_dict: | |
task_dict[task] += 1 | |
else: | |
task_dict[task] = 1 | |
for key in task_dict: | |
if task_dict[key] >=8: | |
if os.name == 'nt': | |
toaster.show_toast("Pomo Reminder", | |
key + ' is enough, Time to switch task!') | |
else: | |
os.system('notify-send "{}" "{}"'.format('Pomo Reminder', key + ' is enough, Time to switch task!')) | |
break | |
elif task_dict[key] <8: | |
# os.system('notify-send "{}" "{}"'.format('pomo-reminder', 'not time to switch task!')) | |
pass | |
print(task_dict) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment