]> CyberLeo.Net >> Repos - CDN/taggery.git/blob - lib/profiles/gelbooru.sh
Update gelbooru tags filter
[CDN/taggery.git] / lib / profiles / gelbooru.sh
1 gelbooru_can_handle() {
2   local url="${1}"
3   echo "${url}" | grep -qi 'gelbooru.com/.*id=[0-9]*' || return 1
4   taggery_id_filter=gelbooru_id_filter
5   taggery_fmturl="http://gelbooru.com/index.php?page=post&s=view&id=%s"
6   taggery_image_referer=gelbooru_image_referer
7   taggery_image_url_filter=gelbooru_image_url_filter
8   taggery_image_tags_filter=gelbooru_image_tags_filter
9 }
10 gelbooru_id_filter() {
11   sed -e 's#^.*id=\([0-9]\+\)\($\|&.*$\)#\1#'
12 }
13 gelbooru_image_referer() {
14   echo "http://www.gelbooru.com/index.php?page=post&s=view&id=${1}"
15 }
16 gelbooru_image_url_filter() {
17   sed -e '/>Original image</!d; s/>Original image.*//i; s/^.*<a //i; s/^.*href="\([^"]*\)".*$/\1/i; /:\/\//!s/^/http:/'
18 }
19 gelbooru_image_tags_filter() {
20   sed -e '/<ul id="tag-list">/,/<\/ul>/!d; s/<\/li>/&\n/g' | sed -e '/class="tag-type-/!d; s/\([^?]\)<\/a>.*$/\1/; s/^.*>//; s/ /_/g'
21 }