horribro.sh - randomcrap - random crap programs of varying quality
(HTM) git clone git://git.codemadness.org/randomcrap
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
horribro.sh (1252B)
---
1 #!/bin/sh
2 # ugly script hack to search for anime on https://horriblesubs.info/
3 #
4 # some NOTES:
5 # - pipe to your browser, for example: lynx -stdin
6 # - horriblesubs contains many ads and crap: don't use a browser that
7 # loads external resources.
8 # - use magnet links.
9
10 http() {
11 curl \
12 -s \
13 -L --max-redirs 0 \
14 -f \
15 -H 'User-Agent:' \
16 -m 10 \
17 "$1"
18 }
19
20 s="$1"
21 filter="$2"
22
23 if test x"$s" = x"" || test x"$1" = x"-h"; then
24 echo "usage: $0 <show> [filter]" >&2
25 exit 1
26 fi
27
28 showname=$(http 'https://horriblesubs.info/api.php?method=search&value='"$s" | \
29 tr -d '\n' | \
30 sed -E -e 's@</?[a-zA-Z]*/?>@@g' -e 's@<a href="/shows/([^#]*)#.*@\1@g')
31 #echo "DEBUG: Show name: ${showname}"
32
33 if test x"${showname}" = x""; then
34 echo "No showname found" >&2
35 exit 1
36 fi
37
38 showid=$(http 'https://horriblesubs.info/shows/'"${showname}"'/' | \
39 grep 'hs_showid' |
40 sed -E 's@.*var hs_showid = ([^;]*);.*@\1@g')
41 #echo "DEBUG: Show ID: ${showid}"
42
43 if test x"${showid}" = x""; then
44 echo "No showid found" >&2
45 exit 1
46 fi
47
48 if test x"$filter" != x""; then
49 http 'https://horriblesubs.info/api.php?method=getshows&type=show&showid='"$showid"'&mode=filter&value='"$filter"
50 else
51 http 'https://horriblesubs.info/api.php?method=getshows&type=show&showid='"$showid"
52 fi