misc scripts & programs
1#!/bin/bash
2#
3# unfinished weird little thing i was playing with to query the marvel API
4
5API_KEY=x
6PRIV_KEY=x
7TS=1
8HASH=$(echo -n ${TS}${PRIV_KEY}${API_KEY} | md5sum | cut -d ' ' -f 1)
9
10echo -e "what do you want to look up? \n"
11
12CHOOSE=$(gum choose --limit 1 "characters" "comics" "creators")
13
14echo -e "what do you want to look up from ${CHOOSE}? \n"
15
16LOOK=$(gum input --placeholder "type away")
17
18URL="https://gateway.marvel.com/v1/public/${CHOOSE}?${TYPE}=${LOOK}&apikey=${API_KEY}&ts=${TS}&hash=${HASH}"
19
20if [ "${CHOOSE}" == "characters" ]; then
21 echo -e "pick from below \n"
22 TYPE="name"
23 CHARA=$(gum choose --limit 1 "comics" "series" "events")
24 case ${CHARA} in
25 comics)
26 echo -n -e "comics starring ${LOOK}: \n\n"
27 curl -s ${URL} | jq -r ".data.results[].comics.items[].name"
28 ;;
29 series)
30 echo -n -e "series starring ${LOOK}: \n\n"
31 curl -s ${URL} | jq -r ".data.results[].series.items[].name"
32 ;;
33 events)
34 echo -n -e "events starring ${LOOK}: \n\n"
35 curl -s ${URL} | jq -r ".data.results[].events.items[].name"
36 ;;
37 esac
38elif [ "$CHOOSE" == "comics" ]; then
39 echo -e "pick from below \n"
40 TYPE="title"
41 COMIC=$(gum choose --limit 1 "title" "description")
42 case ${COMIC} in
43 title)
44 echo -n -e "comics featuring ${LOOK}: \n\n"
45 curl -s ${URL} | jq -r ".data.results[].title"
46 ;;
47 description)
48 echo -n -e "comic descriptions with ${LOOK}: \n\n"
49 curl -s ${URL} | jq -r ".data.results[].description"
50 ;;
51 esac
52else
53 echo -e "did you hit ctrl+c"
54fi