From 30037e7febd9101e4b9ee49917973824d4cf70cb Mon Sep 17 00:00:00 2001 From: CyberLeo Date: Wed, 20 Sep 2017 21:13:56 -0500 Subject: [PATCH] Add konachan profile; also update lolibooru as it is the same software --- lib/profiles/konachan | 23 +++++++++++++++++++++++ lib/profiles/lolibooru | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 lib/profiles/konachan diff --git a/lib/profiles/konachan b/lib/profiles/konachan new file mode 100644 index 0000000..4e7337d --- /dev/null +++ b/lib/profiles/konachan @@ -0,0 +1,23 @@ +konachan_can_handle() { + local url="${1}" + echo "${url}" | grep -qi 'konachan.com/post/show/[0-9]*' || return 1 + taggery_id_filter=konachan_id_filter + taggery_fmturl="https://konachan.com/post/show/%s" + taggery_image_name_filter=konachan_image_name_filter + taggery_image_url_filter=konachan_image_url_filter + taggery_image_tags_filter=konachan_image_tags_filter +} +konachan_id_filter() { + sed -e 's#^.*/post/show/\([0-9]\+\)\($\|/.*$\)#\1#' +} +konachan_image_url_filter() { + sed -e '/id="\(png\|highres\)"/!d;' | sort -b | tail -n 1 | sed -e 's/^.*href="\([^"]*\)".*$/\1/i; /^\/\//s/^/https:/' +} +konachan_image_tags_filter() { + sed -e '/id="tag-sidebar"/,/<\/ul>/!d; s/<\/li>/&\n/g' | sed -e '/class="tag-link/!d; s/\([^?]\)<\/a>.*$/\1/; s/^.*>//; s/ /_/g' +} +konachan_image_name_filter() { + local id="${1}" + local image_url="${2}" + echo "${image_url}" | sed -e 's#^.*/image/##; s#/.*\(\.[^.]*\)$#\1#' +} diff --git a/lib/profiles/lolibooru b/lib/profiles/lolibooru index 65ccebb..5716405 100644 --- a/lib/profiles/lolibooru +++ b/lib/profiles/lolibooru @@ -11,7 +11,7 @@ lolibooru_id_filter() { sed -e 's#^.*/post/show/\([0-9]\+\)\($\|/.*$\)#\1#' } lolibooru_image_url_filter() { - sed -e '/id="highres"/!d; s/^.*href="\([^"]*\)".*$/\1/i' + sed -e '/id="\(png\|highres\)"/!d;' | sort -b | tail -n 1 | sed -e 's/^.*href="\([^"]*\)".*$/\1/i; /^\/\//s/^/https:/' } lolibooru_image_tags_filter() { sed -e '/id="tag-sidebar"/,/<\/ul>/!d; s/<\/li>/&\n/g' | sed -e '/class="tag-link/!d; s/\([^?]\)<\/a>.*$/\1/; s/^.*>//; s/ /_/g' -- 2.42.0