Article View: news.software.readers
Article #223849Re: what is your favourite M-ID search/retrieve tool?
From: »Q«
Date: Tue, 29 Jul 2008 05:00
Date: Tue, 29 Jul 2008 05:00
145 lines
6604 bytes
6604 bytes
On Tue, 29 Jul 2008 13:32:18 +1000
Troy Piggins <usenet-0807@piggo.com> wrote:
> If I want to search for an article by message-id that's not on my
> local news proxy, I typically use the GG advanced search by
> message-id lookup.
>
> Any "better" ones? Why?
<http://howardk.freenix.org/> has the advantage of saving XNA'd
articles, as long as you use the "bookmark" feature once you've brought
up the article.
> Is there a linux commandline one you know of?
This is overkill -- I've just whittled down the script I use to make a
list of URLs out of a mbox file so that it takes MIDs as input instead.
I think it may need GNU extensions to sed and I'm sure it needs GNU
bash.
It has the option to use Fx, Konqi, or Opera. Other browsers could be
added (just add $BROWSERCOMMAND options) or the output could just be
piped wherever you want.
I've only quickly tested it after quickly cutting down the bigger
script, which is at <http://remarqs.net/scripts/mids2urls.bash>. I
think it's ok, but if I've made any mistakes the worst that could
happen is the script would throw an error or pass a bad URL to the
browser. There are no checks that you're giving it a good MID, so GIGO.
---------------
#!/bin/bash
MYVERSION=0.20080728
# If you improve this script, please read the comments at the
# end of this file. Thanks.
# usage/help message
usage_message() {
cat >&2 <<EOT
Usage: ${0##*/} [options] message-id
The message-id input should include the < angle brackets >
Options:
-a google|freenix specify an archive; default is google
-b firefox|konqueror|opera send the output URLs to browser
-h print this help text and exit
-q suppress output of URLs to stdout
-V print version info and exit
EOT
}
# initialize a few variables
BROWSERCOMMAND="" # Set default to "firefox", "konqueror", or
# "opera -newpage" if you want.
ARCHIVE=google # Set default archive to google or freenix.
QUIET=no # Can be changed to yes, but there's no -v
# switch to turn output back on.
# formats and exit codes for errors
ERRFMT=${0##*/}:\ error:\ %b\\\n # printf format for errors
E_ARGS=65 # something wrong with the arguments
E_SED=7 # sed exited with an error
# this should never happen
# if it does, this script needs debugging
# parse the arguments
while getopts hqa:b:V ARGS 2>/dev/null; do
case $ARGS in
\?) printf "$ERRFMT" "I cannot make sense of those parameters" >&2
usage_message
exit $E_ARGS
;;
h) usage_message; exit 10; ;;
q) QUIET="yes"; ;;
b) if [[ $OPTARG == firefox ]]; then BROWSERCOMMAND=firefox
elif [[ $OPTARG == konqueror ]]; then BROWSERCOMMAND=konqueror
elif [[ $OPTARG == opera ]]; then BROWSERCOMMAND=opera\ -newpage
else
printf "$ERRFMT" "$OPTARG is not a supported browser" >&2
usage_message
exit $E_ARGS
fi
;;
a) # if a bad arg was passed with -a, there's no error
# the default archive specified above is used
[[ $OPTARG == google ]] && ARCHIVE=google
[[ $OPTARG == freenix ]] && ARCHIVE=freenix
;;
V) echo -e "\e[1;33m${0##*/}: version $MYVERSION\e[0m"; exit 10; ;;
esac
done
# having caught the options, move to other parameters
shift $((OPTIND - 1))
# sed commands used to URL-encode the MID fields
# I think these are all the characters which can be
# in MIDs but must be encoded in URLs.
# See RFC 2822, section 3.4.2.
# Note that the < > and @ characters are encoded by
# the last three commands.
URLENC_SED='s~%~%25~g; s~!~%21~g; s~#~%23~g; s~\$~%24~g; s~'\''~%27~g; s~&~%26~g; s~\*~%2a~g; s~\+~%2b~g; s~-~%2d~g; s~/~%2f~g; s~\?~%3f~g; s~\^~%5e~g; s~_~%5f~g; s~`~%60~g; s~{~%7b~g; s~|~%7c~g; s~}~%7d~g; s/~/%7e/g; s~<~%3c~g; s~>~%3e~g; s~@~%40~g'
# make the list of URLS
[[ $ARCHIVE == google ]] && {
URL=$(echo "$@" | sed "{ $URLENC_SED; s~^%3c\(.*\)%3e$~http://groups.google.com/groups?as_umsgid=\1~; }" ) || {
printf "$ERRFMT" "*** exiting due to a sed error ***" \
"*** please, please debug me ***" >&2
exit "$E_SED"
}
}
[[ $ARCHIVE == freenix ]] && {
URL=$(echo "$@" | sed "{ $URLENC_SED; s~.*~http://howardk.freenix.org/msgid.cgi\?STYPE=msgid\&MSGI=\0~; }" ) || {
printf "$ERRFMT" "*** exiting due to a sed error ***" \
"*** please, please debug me ***" >&2
exit "$E_SED"
}
}
# send the URL to stdout and/or browser
[[ $QUIET == no ]] && echo -e "${URL}"
[[ -n $BROWSERCOMMAND ]] && {
echo -e "${URL}" | xargs $BROWSERCOMMAND &>/dev/null &
}
exit 0
##################################################################
## ##
## This script is provided as-is, with no warranty. Use it ##
## however you want. No rights are reserved. ##
## ##
## If you improve the script, please mail your changes to ##
## boxcars at gmx dot net. ##
## ##
##################################################################
Technical Details
Message-ID:
<20080729000010.08aa4abc@bellgrove.remarqs.net>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.20140922.mbox.gz!number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!news-lei1.dfn.de!news1.uni-leipzig.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mailReferences:
<20080729132901.542@usenet.piggo.com>Show Full Headers
Complete Article Headers
Message-ID: <20080729000010.08aa4abc@bellgrove.remarqs.net> Subject: Re: what is your favourite M-ID search/retrieve tool? Date: Tue, 29 Jul 2008 00:00:10 -0500 From: »Q« <boxcars@gmx.net> References: <20080729132901.542@usenet.piggo.com> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.20140922.mbox.gz!number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!news-lei1.dfn.de!news1.uni-leipzig.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Newsgroups: news.software.readers Organization: none Lines: 145 Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Trace: individual.net ZmKFR6BqoluDa7lJeO+VhQk7cwwrWYldu4Conxc0HVxhkl97LK X-Orig-Path: bellgrove.remarqs!not-for-mail Cancel-Lock: sha1:u7DKEYU3Y9JeRMciLrrfw07pieU= X-Newsreader: Claws Mail 3.5.0 (GTK+ 2.12.9; i686-pc-linux-gnu)