3 ms·
I think this prints out title and author of every book: curl https://standardebooks.org/opds/all | awk '/<title>/ {split($0,a,">");split(a[2],b,"<");printf b
by yesenadam 6y ago
I think this prints out title and author of every book:
curl https://standardebooks.org/opds/all | awk '/<title>/ {split($0,a,">");split(a[2],b,"<");printf b[1]} /<name>/{split($0,a,">");split(a[2],b,"<");print " - "b[1]}' | tail -r
The tail -r is to reverse the output, it's otherwise in approximately reverse alphabetical order of author's first name. Output is
Hadji Murád - Leo Tolstoy
Pierre and Jean - Guy de Maupassant
The Red House Mystery - A. A. Milne
The Moon Pool - A. Merritt
Fables - Aesop
Poirot Investigates - Agatha Christie
The Man in the Brown Suit - Agatha Christie ...
- acabal 6y agoThe "all" feed is sorted by most-recently-updated-first (this is part of the OPDS standard), so instead of tail -r you should pipe to sort.
- philsnow 6y agooh very nice. My machine doesn't have a `tail -r`, but it has `tac`, which I guess does the same thing. I tweaked your output to put author first, to make sorting work better: curl -s https://standardebooks.org/opds/all | awk '/<title>/ {split($0,a,">");split(a[2],b,"<")} /<name>/{split($0,c,">");split(c[2],d,"<");print d[1]" - "b[1]}' | sort gives something like: A. A. Milne - The Red House Mystery A. Merritt - The Moon Pool Aesop - Fables Agatha Christie - Poirot Investigates Agatha Christie - The Man in the Brown Suit Agatha Christie - The Murder on the Links Agatha Christie - The Mysterious Affair at Styles Agatha Christie - The Secret Adversary Aldous Huxley - Antic Hay ...