Use XPath string() to select just attribute value - plumb - Open certain URL patterns with an ad-hoc opener (plumber)
(HTM) hg clone https://bitbucket.org/iamleot/plumb
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
---
(DIR) changeset 6604cb15a95b7c3caa3fd6cb8c59c26640107294
(DIR) parent 486ff5dc364a027a60d74588e7f7c0998aea40b6
(HTM) Author: Leonardo Taccari <iamleot@gmail.com>
Date: Wed, 19 Sep 2018 17:13:43
Use XPath string() to select just attribute value
Diffstat:
openers/dilbert | 4 ++--
openers/userfriendly | 3 +--
2 files changed, 3 insertions(+), 4 deletions(-)
---
diff -r 486ff5dc364a -r 6604cb15a95b openers/dilbert
--- a/openers/dilbert Wed Sep 19 17:08:52 2018 +0200
+++ b/openers/dilbert Wed Sep 19 17:13:43 2018 +0200
@@ -2,7 +2,7 @@
for u in "$@"; do
gifurl=$(curl -gs -L "$u" |
- xmllint --html --xpath '//meta[@property="og:image"]/@content' - 2>/dev/null |
- sed -e 's/^ content="//' -e 's/"$/.gif/')
+ xmllint --html --xpath 'string(//meta[@property="og:image"]/@content)' - 2>/dev/null |
+ sed -e 's/$/.gif/')
plumb "${gifurl}"
done
diff -r 486ff5dc364a -r 6604cb15a95b openers/userfriendly
--- a/openers/userfriendly Wed Sep 19 17:08:52 2018 +0200
+++ b/openers/userfriendly Wed Sep 19 17:13:43 2018 +0200
@@ -2,7 +2,6 @@
for u in "$@"; do
gifurl=$(curl -gs -L "$u" |
- xmllint --html --xpath '//img[@width="720"]/@src' - 2>/dev/null |
- sed -e 's/^ src="//' -e 's/"$//')
+ xmllint --html --xpath 'string(//img[@width="720"]/@src)' - 2>/dev/null)
plumb "${gifurl}"
done