Skip to content

Commit

Permalink
xcallback for adding tasks to sorted3
Browse files Browse the repository at this point in the history
  • Loading branch information
marksibrahim committed Jul 25, 2021
1 parent 0073fba commit ab2c4e9
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions sorted3-quick-add/quick_add.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
"""
For use with Alfred, combine with
https://github.com/fnando/alfred-workflows/blob/master/Copy%20current%20URL.alfredworkflow
"""

import webbrowser
import click


OPEN_URL = "sorted://x-callback-url/open?item=today"
SAVE_URL = "sorted://x-callback-url/add?"


@click.group()
def cli():
pass


@cli.command()
@click.argument("task", type=str)
def add_to_inbox(task):
xcallback = SAVE_URL + f"title={task}"
webbrowser.open(xcallback, new=0)


@cli.command()
@click.argument("title-url", type=str)
def add_to_reading_list(title_url):
title, url = title_url.split("~")
clean_title = remove_arxiv_num(title)
xcallback = SAVE_URL + f"title={clean_title} {url}&list=Reading List"
webbrowser.open(xcallback, new=0)


def remove_arxiv_num(url: str):
if not url.startswith("["):
return url
return url.split("]")[1].strip()


if __name__ == "__main__":
cli()

0 comments on commit ab2c4e9

Please sign in to comment.