From: Ian Jackson Date: Sun, 21 Mar 2021 20:53:32 +0000 (+0000) Subject: media-scraper: Provide local-build scraper (is actually for oxymoron) X-Git-Tag: otter-0.5.0~550 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=0ba843762c08b641b400a15441e60986f22f26f2;p=otter.git media-scraper: Provide local-build scraper (is actually for oxymoron) This is not as general as its name, but this is how I wrote it. It will be renamed in a later commit. Signed-off-by: Ian Jackson --- diff --git a/README.md b/README.md index 82e917f7..195101bf 100644 --- a/README.md +++ b/README.md @@ -126,7 +126,7 @@ Setup sudo apt install build-essential cpio git curl \ pkg-config libssl-dev \ node-typescript inkscape bubblewrap \ - netpbm + netpbm imagemagick ``` 2. Install Rust. This is most easily done with [rustup](https://rustup.rs)): diff --git a/library/cards-oxymoron/.gitignore b/library/cards-oxymoron/.gitignore index 8c2b7dd4..3c4215f3 100644 --- a/library/cards-oxymoron/.gitignore +++ b/library/cards-oxymoron/.gitignore @@ -1,2 +1,3 @@ +*.svg cards/src/*.gif cards/src/make-cards.massaged diff --git a/media-scraper b/media-scraper index 7861b745..27c54af2 100755 --- a/media-scraper +++ b/media-scraper @@ -142,6 +142,28 @@ sub method_wikimedia ($$$) { sub methodisoffline_wikimedia { 0 } +sub method_local_build { + my ($scraper, $methname) = @_; + return sub { + my ($lbase, $ldest, $rstem) = @_; + my $lgif = $lbase; + $lgif =~ m{/card-oxymoron-(\w+)-(\w+)$} or die "$lbase ?"; + my $basename = $`; + $lgif = "$basename/cards/src/\l$1\E$2.gif"; + + if (stat $lgif) { + } elsif ($! != ENOENT) { + die "$lgif $!"; + } else { + print STDERR "\nbuilding $basename...\n"; + $!=$?=0; system "$basename/build" and die "$! $?"; + } + $!=$?=0; system qw(convert), $lgif, $ldest and die "$! $?"; + } +} +sub methodlic_local_build { undef } +sub methodisoffline_local_build ($$) { 1 } + our $offline; while (@ARGV && $ARGV[0] =~ m/^-/) {