archive
/
todoist-github
Archived
1
Fork 0

Get relevant todoist tasks

This commit is contained in:
Jake Howard 2020-01-08 21:05:58 +00:00
parent 7790e3a677
commit b8eb2645e7
Signed by: jake
GPG Key ID: 57AFB45680EDD477
7 changed files with 45 additions and 1 deletions

View File

@ -0,0 +1,2 @@
todoist-python==8.1.1
urlextract==0.14.0

View File

@ -4,4 +4,4 @@ set -e
PATH=env/bin:${PATH}
python3 todoist-github/cli.py
python3 -m todoist-github

View File

View File

@ -0,0 +1,3 @@
from .cli import main
main()

View File

@ -1 +1,22 @@
#!/usr/bin/env python3
from .clients import todoist
from .utils import get_github_task
def get_relevant_todoist_tasks():
todoist.items.sync()
tasks = {}
for task in todoist.items.all():
if get_github_task(task["content"]):
tasks[task['content']] = task
return tasks
def main():
todoist_tasks = get_relevant_todoist_tasks()
if __name__ == "__main__":
main()

View File

@ -0,0 +1,4 @@
from todoist import TodoistAPI
import os
todoist = TodoistAPI(os.environ["TODOIST_TOKEN"])

14
todoist-github/utils.py Normal file
View File

@ -0,0 +1,14 @@
from typing import Optional
from urlextract import URLExtract
from urllib.parse import urlparse
extractor = URLExtract()
def get_github_task(content) -> Optional[str]:
if "github" not in content.lower():
return None
for url in extractor.gen_urls(content):
if urlparse(url).netloc == "github.com":
return url