Created
May 19, 2013 17:22
-
-
Save proudzhu/5608336 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
# | |
# retreive aur comments for a package | |
# - package name can be specified or pulled from a PKGBUILD in $PWD | |
# - specify -a to show all comments | |
# | |
AURURL="https://aur.archlinux.org" | |
ALL='&comments=all' | |
CON=$(echo -e '\033[1;37m') | |
COFF=$(echo -e '\033[0m') | |
commfilter() { | |
xmllint --html --xpath \ | |
'//div[@id="news"]' - 2>/dev/null |\ | |
sed -e 's/<[^>]\+>//g; s/\t//g; s/\r$//; | |
/^$/d; /^Comment\ by/{x;p;x;}; ' | |
# line 1: strip html tags, tabs and ^M | |
# line 2: strip empty lines between timestamp and body | |
} | |
getpkgID() { | |
curl -s "$AURURL/rpc.php?type=info&arg=$1" | awk ' | |
BEGIN { FS="," } | |
/ID/ {split($4, id, ":"); print id[2]; exit} ' | |
} | |
[[ $1 = -a ]] && { showall=$ALL; shift; } | |
if ! (( $# )); then | |
if [[ ! -f PKGBUILD ]]; then | |
echo "error: no PKGBUILD found and no arg provided" | |
exit 1 | |
fi | |
eval $(grep '^pkgname=' PKGBUILD) | |
fi | |
pkgname=${1:-$pkgname} | |
pkgID=$(getpkgID $pkgname) | |
[[ $pkgID ]] || { echo "error: package \`$pkgname' not found"; exit 1; } | |
curl -s "$AURURL/packages.php?ID=$pkgID$showall" | commfilter |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment