google.sh - randomcrap - random crap programs of varying quality
(HTM) git clone git://git.codemadness.org/randomcrap
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
google.sh (869B)
---
1 #!/bin/sh
2
3 # match(str, regex, [flags])
4 match() {
5 printf '%s' "$1" | grep "-qE$3" "$2"
6 }
7
8 # google drive
9 # list files from some google drive url.
10 # the default interface is garbage and requires JS etc.
11 # test: "https://drive.google.com/file/d/1uNuvngHrTZ3AVpNEdoXS-E8rKlwVdhlX/view"
12 if match "$1" '^https:\/\/drive\.google\.com\/uc'; then
13 hurl -t 15 "$1" | \
14 sed -nE 's@.*"(https://drive\.google\.com/uc[^"]*)".*@\1@p' | \
15 sed -e 's@\\u0026@\&@g' -e 's@\\u003d@=@g' | \
16 ~/.config/scripts/dmenu_urls_plumb.sh
17 elif match "$1" 'https:\/\/docs\.google\.com\/document\/d'; then
18 # google docs: export document to PDF.
19 id=$(printf '%s' "$1" | sed -nE 's@.*https://docs\.google\.com/document/d/([^\/]*).*@\1@p')
20 if test -n "$id"; then
21 url="https://docs.google.com/document/d/$id/export?format=pdf"
22 echo "$url"
23 # ~/.config/scripts/plumb.sh "${url}" "pdf"
24 fi
25 fi