-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
xcallback for adding tasks to sorted3
- Loading branch information
1 parent
0073fba
commit ab2c4e9
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
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
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() | ||
|