~kris/dots

srice

ref: b42b72dc2648499470b89418ac629e40f41d3149 srice/.local/bin/arxiv-search -rwxr-xr-x 650 bytes
b42b72dc — Kris Yotam sb-battery: match macsmc-battery by type, add low-battery dunst alerts; xprofile: caps:super 2 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env python3
"""arxiv-search -- search arXiv from the terminal
Usage: arxiv-search <query terms>
"""
import arxiv, sys

if len(sys.argv) < 2:
    print("Usage: arxiv-search <query>", file=sys.stderr)
    sys.exit(1)

client = arxiv.Client()
search = arxiv.Search(
    query=" ".join(sys.argv[1:]),
    max_results=15,
    sort_by=arxiv.SortCriterion.Relevance
)
for r in client.results(search):
    aid = r.entry_id.split("/")[-1]
    authors = ", ".join(a.name for a in r.authors[:3])
    if len(r.authors) > 3:
        authors += " et al."
    print(f"{aid:20} {r.title}")
    print(f"{'':20} {authors} ({r.published.year})")
    print()