marvel-nokeys

· lachesis's pastes · raw

expires: 2025-06-16

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