1
0
Disbranĉigi 0

Init commit

This commit is contained in:
Jaidyn Ann 2017-06-13 20:29:32 -05:00
parent 48c5f0fbf0
commit 0cc9f2e659
3 changed files with 84 additions and 1 deletions

11
COPYING Normal file
View File

@ -0,0 +1,11 @@
Copyright 2017 Jaiden Levesque
Permission to use, copy, modify, and/or distribute this software for any purpose with or without
fee is hereby granted, provided that the above copyright notice and this permission notice appear
in all copies.
THE SOFTWARE IS PROVIDED AS IS AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE
LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

View File

@ -1,2 +1,17 @@
# pronounce.sh
Plays/downloads the Wiktionary pronounciation of a word
Plays/downloads the Wiktionary pronounciation of a word.
*Usage:* "**pronounce.sh WORD [-po filename]**"
If you use the "**-p**" option, then isntead of saving the pronounciation, it will be played.
If you use the "**-o**" option, then it will be saved to the specified filename.
If you use both ("-po"), then it'll do both.
Oh, and the options *must* come after the word.
There's a bloody eel in my hovercraft, dammit! How do I say hovercraft?
```$ pronounce.sh hovercraft -p```
Only tested on OpenBSD's ksh, but it should work on bash and other modern shells.

57
pronounce.sh Executable file
View File

@ -0,0 +1,57 @@
#!/bin/sh
# pronounce.sh
# Fetches the pronounciation of a word from Wiktionary
# Lisc: ISC
# Config:
player="play"
WORD=$1
OPTIONTWO=$2
wd_pg=/tmp/wt_wd_pg
fl_pg=/tmp/wt_fl_pg
fl_pg_url=/tmp/wt_fl_pg_url
fl_url=/tmp/wt_fl_url
fl=/tmp/wt_file
ftp -Vo $wd_pg "https://en.wiktionary.org/wiki/$WORD" > /dev/null
grep "\"audiometa\"" $wd_pg > $fl_pg_url
sed -i 's^.*href="^^g' $fl_pg_url
sed -i 's^" title.*^^g' $fl_pg_url
sed -i 's^/wiki/^https://en.wiktionary.org/wiki/^g' $fl_pg_url
for FL_PG_URL in $(cat $fl_pg_url)
do
ftp -Vo $fl_pg "$FL_PG_URL" > /dev/null
grep "class=\"fullMedia\"><a href=" $fl_pg > $fl_url
sed -i 's^.*a href="^^g' $fl_url
sed -i 's^" class="internal".*^^g' $fl_url
FL_URL=$(echo "https:$(cat $fl_url)")
if [ -n "$OPTIONTWO" ]
then
case "$OPTIONTWO" in
-p)
ftp -Vo $fl $FL_URL > /dev/null
$player $fl
;;
-o)
ftp -Vo "$3" $FL_URL > /dev/null
;;
-po)
ftp -Vo "$3" $FL_URL > /dev/null
$player "$3"
;;
esac
elif [ -z "$OPTIONTWO" ]
then
ftp -V $FL_URL > dev/null
fi
done
# Cleanup
rm $wd_pg $fl_pg $fl_pg_url $fl_url $fl