]> CyberLeo.Net >> Repos - CDN/taggery.git/blob - lib/profiles/danbooru
Change to accept URL instead of post ID and glean profile from that
[CDN/taggery.git] / lib / profiles / danbooru
1 danbooru_can_handle() {
2   local url="${1}"
3   echo "${url}" | grep -qi 'danbooru.donmai.us/posts/[0-9]*' || return 1
4   taggery_id_filter=danbooru_id_filter
5   taggery_fmturl="https://danbooru.donmai.us/posts/%s"
6   taggery_image_url_filter=danbooru_image_url_filter
7   taggery_image_tags_filter=danbooru_image_tags_filter
8 }
9 danbooru_id_filter() {
10   sed -e 's#^.*/posts/\([0-9]\+\)\($\|/.*$\)#\1#'
11 }
12 danbooru_image_url_filter() {
13   sed -e '/Size: /!d; s/^.*<a //i; s/^.*href="\([^"]*\)".*$/http:\/\/danbooru.donmai.us\1/i'
14 }
15 danbooru_image_tags_filter() {
16   sed -e '/class="search-tag"/!d; s/<\/li>/&\n/g' | sed -e '/class="search-tag/!d; s/\([^?]\)<\/a>.*$/\1/; s/^.*>//; s/ /_/g'
17 }