diff options
author | Daniel Woffinden | 2015-06-08 23:04:56 +0100 |
---|---|---|
committer | Daniel Woffinden | 2015-06-08 23:04:56 +0100 |
commit | fba9d8ba9ffe8e3881f2c535623a48303d83d25c (patch) | |
tree | 792f9ace3bd7dc2ec14113e400d1235663fd6ee4 | |
download | aur-fba9d8ba9ffe8e3881f2c535623a48303d83d25c.tar.gz |
Squash history to appease the aur4 hooks.
-rw-r--r-- | .SRCINFO | 17 | ||||
-rw-r--r-- | PKGBUILD | 30 | ||||
-rw-r--r-- | README.md | 10 | ||||
-rw-r--r-- | wiki.pl | 69 |
4 files changed, 126 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 000000000000..37dd811a76fd --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,17 @@ +pkgbase = fortune-mod-farscape + pkgdesc = Fortune cookies: Farscape (TV series), scraped from https://en.wikiquote.org/wiki/Farscape + pkgver = r1813446 + pkgrel = 1 + url = http://github.com/dwoffinden/fortune-mod-farscape + arch = any + groups = fortune-mods + license = CCPL:by-sa3.0 + makedepends = perl + makedepends = perl-mediawiki-api + makedepends = perl-libwww + depends = fortune-mod + source = wiki.pl + md5sums = c298998fe5c54870fbc12ce315ef311f + +pkgname = fortune-mod-farscape + diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 000000000000..0edc3a21379b --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,30 @@ +# Maintainer: d.woffinden +pkgname=fortune-mod-farscape +pkgver=r1813446 +pkgrel=1 +pkgdesc='Fortune cookies: Farscape (TV series), scraped from https://en.wikiquote.org/wiki/Farscape' +arch=('any') +url='http://github.com/dwoffinden/fortune-mod-farscape' +license=('CCPL:by-sa3.0') +makedepends=('perl' 'perl-mediawiki-api' 'perl-libwww') +depends=('fortune-mod') +groups=('fortune-mods') +source=('wiki.pl') +md5sums=('c298998fe5c54870fbc12ce315ef311f') + +pkgver() { + cd "$srcdir" + printf "r%s" $(perl wiki.pl revision) +} + +build() { + cd "$srcdir" + perl wiki.pl > farscape + strfile farscape farscape.dat +} + +package() { + cd "$srcdir" + install -D -m644 farscape ${pkgdir}/usr/share/fortune/farscape + install -D -m644 farscape.dat ${pkgdir}/usr/share/fortune/farscape.dat +} diff --git a/README.md b/README.md new file mode 100644 index 000000000000..316df35b85c1 --- /dev/null +++ b/README.md @@ -0,0 +1,10 @@ +# fortune-mod-farscape + +A script to scrape Farscape quotes from wikiquote into a fortune-mod +package, and a PKGBUILD for Arch Linux. + +https://en.wikiquote.org/wiki/Farscape + +https://aur.archlinux.org/packages.php?ID=63650 + +https://github.com/dwoffinden/fortune-mod-farscape diff --git a/wiki.pl b/wiki.pl new file mode 100644 index 000000000000..afc9b2b4efc6 --- /dev/null +++ b/wiki.pl @@ -0,0 +1,69 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use utf8; + +use MediaWiki::API; + +binmode STDOUT, ":utf8"; + +my $mw = MediaWiki::API->new({ api_url => 'http://en.wikiquote.org/w/api.php' }); + +# TODO fetch a specific, stable revision +# TODO add series numbers + episode names to the end? +# TODO actually scrape it into an array? + +my $page = $mw->get_page( { title => 'Farscape' } ); + +if ($#ARGV == 0 && $ARGV[0] eq "revision") { + print $page->{ 'revid' }; + exit; +} + +if ($#ARGV > -1) { + die; +} + +$_ = $page->{ '*' }; + +# remove everything after, and including, the cast section +s/== Cast ==.*$//s; + +# create seperators from horizontal rules, {,sub}section boundaries, quotes +s/^\s*<hr.+?\/>\s*$/%/gim; + +s/^===.+?===$/%/gm; + +s/^==.+?==$/%/gm; + +s/^\s*\*\s*$/%/gm; + +# remove empty lines +s/\n{2,}/\n/g; + +# collapse any multiple occurances of '%' +s/%\n(%\n)+/%\n/g; + +# remove everything before, and including, the first '%' +s/.*?%\n//s; + +# remove leading colons +s/^://gm; + +# collapse bold and italic text. +s/'''(.+?)'''/$1/g; + +s/''(.+?)''/$1/g; + +# replace wiki links with just the text +s/\[\[(w:.+?\|)?(.+?)\]\]/$2/g; + +# remove trailing whitespace +s/\s+$//gm; +# remove preceding whitespace +s/^\s+//gm; +# collapse runs of spaces +s/(\s)\s+/$1/gm; + +print; |