Introduction
Introduction Statistics Contact Development Disclaimer Help
Move tagtype detection to separate script for further use. - annna - Annna the …
git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws6…
Log
Files
Refs
Tags
README
---
commit 9c2d6a5313bd098963f1e8350ad2037d6dca5e37
parent 05a5677d0d72f707f08e15317c6c9073a723ea0a
Author: Annna Robert-Houdin <[email protected]>
Date: Tue, 19 May 2020 12:59:59 +0200
Move tagtype detection to separate script for further use.
Thanks parazyd for the hint!
Diffstat:
M annna-add-hashtag | 18 +-----------------
A get-tagtype | 30 ++++++++++++++++++++++++++++++
2 files changed, 31 insertions(+), 17 deletions(-)
---
diff --git a/annna-add-hashtag b/annna-add-hashtag
@@ -83,23 +83,7 @@ inserttag() {
stag="$(printf "${tag}\n" | cut -c 2-)"
cd "${memecachedir}"
tagfile="$(basename "$(find . -name "${stag}.*" | grep -v .orig)")"
- case "${tagfile}" in
- *.jpg|*.JPG|*.jpeg|*.JPEG|*.png|*.PNG|*.svg|*.SVG)
- tagtype="I"
- ;;
- *.gif|*.GIF)
- tagtype="g"
- ;;
- *.txt|*.TXT|*.vt|*.VT|*.vtv|*.VTV|*.vtt|*.VTT)
- tagtype="0"
- ;;
- *.wav|*.WAV|*.mp3|*.MP3)
- tagtype="A"
- ;;
- *)
- tagtype="9"
- ;;
- esac
+ tagtype="$(get-tagtype "${tagfile}")"
memecacheuri="gopher://bitreich.org/${tagtype}/memecache/${tagfile}"
printf "%s %s\n" "${tag}" "${memecacheuri}" >> "${hashtagdb}"
diff --git a/get-tagtype b/get-tagtype
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+if [ $# -lt 1 ];
+then
+ printf "usage: %s filename.ext\n" "$(basename "$0")" >&2
+ exit 1
+fi
+
+tagfile="$1"
+case "${tagfile}" in
+*.jpg|*.JPG|*.jpeg|*.JPEG|*.png|*.PNG|*.svg|*.SVG)
+ tagtype="I"
+ ;;
+*.gif|*.GIF)
+ tagtype="g"
+ ;;
+*.txt|*.TXT|*.vt|*.VT|*.vtv|*.VTV|*.vtt|*.VTT)
+ tagtype="0"
+ ;;
+*.wav|*.WAV|*.mp3|*.MP3)
+ tagtype="A"
+ ;;
+*)
+ tagtype="9"
+ ;;
+esac
+
+printf "%s\n" "${tagtype}"
+return 0
+
You are viewing proxied material from bitreich.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.