mirror of
https://github.com/tonydamage/nux-env.git
synced 2025-12-11 13:24:28 +01:00
Legacy sync
Signed-off-by: Tony Tkacik <tonydamage@gmail.com>
This commit is contained in:
parent
851914ff75
commit
4c4bb238a0
13 changed files with 1026 additions and 7 deletions
46
inc/thumby/builtin.nuxsh.sh
Normal file
46
inc/thumby/builtin.nuxsh.sh
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
|
||||
@namespace thumby.thumb.source {
|
||||
|
||||
function :locator.directory {
|
||||
nux.log info "Using find to find jpg or png"
|
||||
find -L "$1" -maxdepth 1 -iname "*.jpg" -or -iname "*.png" | sort -n | head -n1
|
||||
}
|
||||
|
||||
function :locator.application.pdf {
|
||||
echo "$1[0]"
|
||||
}
|
||||
|
||||
function :extractor.application.epub+zip() {
|
||||
|
||||
local rootDesc=$(unzip -p "$1" META-INF/container.xml \
|
||||
| xmlstarlet sel -N od="urn:oasis:names:tc:opendocument:xmlns:container" \
|
||||
-t -v "/od:container/od:rootfiles/od:rootfile[@media-type='application/oebps-package+xml']/@full-path" -n)
|
||||
nux.log info "Root description is in: $rootDesc";
|
||||
local imgDesc=$(unzip -p "$1" "$rootDesc" \
|
||||
| xmlstarlet sel -N opf="http://www.idpf.org/2007/opf" \
|
||||
-t -m "/opf:package/opf:manifest/opf:item[@id=/opf:package/opf:metadata/opf:meta[@name='cover']/@content]" \
|
||||
-v "@href" -o ":" -v "@media-type" -n)
|
||||
IFS=":" read -r img media <<< "$imgDesc";
|
||||
nux.log info "Image name is $imgDesc $img";
|
||||
if [ -n "$img" ]; then
|
||||
unzip -p "$1" $img
|
||||
fi
|
||||
}
|
||||
|
||||
function :extractor.application.x-cbr() {
|
||||
suffix="${1##*.}"
|
||||
case "$suffix" in
|
||||
zip) ;&
|
||||
cbz)
|
||||
potential=$(unzip -l "$1" | sed -re "s/^ *[0-9]+ +[0-9\\-]+ +[0-9:]+ +//gi" | grep -E '\.((jpg)|(png)|(jpeg))$' | sort -n | head -n 1)
|
||||
nux.log debug "Potential preview is: $potential";
|
||||
if [ -n "$potential" ]; then
|
||||
unzip -p "$1" "$potential"
|
||||
nux.log debug "Preview extracted."
|
||||
fi
|
||||
;;
|
||||
*) nux.log error "$suffix is not supported."
|
||||
esac
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue