aboutsummaryrefslogtreecommitdiff
path: root/create_static_list.sh
blob: caf16a18c00677439dbd0ffb9d51471c20f20baa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash

cat >&1 <<EOF
<!DOCTYPE>
<html>
    <head>
        <meta charset="UTF-8"/>
        <title>Radio Station Emulator : index</title>
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet preload" href="./css/styles.css" type="text/css" as="style"/>
    </head>
    <body>
        <div>
            <div class="header">
                <img class="logo" src="./img/logo.jpg"/>
                <div>
                    <h1>Radio Station Emulator : index</h1>
                    <em>by <a href="https://kaotisk-hund.com/" target="_blank">Kaotisk Hund</a>, for <a href="https://arching-kaos.org" target="_blank">Arching Kaos</a> and for everyone.</em>
                </div>
            </div>
EOF

echo '<h2>application/json</h2>'

echo '<h3>Latest list route</h3><ul>'
echo '<li><a href="http://z.kaotisk-hund.com:8010/v0/list">/v0/list</a></li>'
echo '</ul>'
echo '<h3>Lists</h3><ul>'
find hashes -type f | while read filepath
do
    hash_string="$(basename ${filepath})"
    file ${filepath} | grep 'JSON text data' > /dev/null 2>&1
    if [ $? -eq 0 ]
    then
        if [ "$(cat ${filepath} | jq -r '.type')" == "list" ]
        then
            echo '<li><a href="http://z.kaotisk-hund.com:8010/v0/application/json/'${hash_string}'">'${hash_string}'</a></li>'
        fi
    fi
done
echo '</ul>'

echo '<h3>Shows</h3><ul>'
find hashes -type f | while read filepath
do
    hash_string="$(basename ${filepath})"
    file ${filepath} | grep 'JSON text data' > /dev/null 2>&1
    if [ $? -eq 0 ]
    then
        if [ "$(cat ${filepath} | jq -r '.type')" == "show" ]
        then
            echo '<li><a href="http://z.kaotisk-hund.com:8010/v0/application/json/'${hash_string}'">'${hash_string}'</a></li>'
        fi
        continue
    fi
done
echo '</ul>'

echo '<h2>audio/ogg</h2><ul>'
find hashes -type f | while read filepath
do
    hash_string="$(basename ${filepath})"
    file ${filepath} | grep 'Ogg data, Vorbis audio' > /dev/null 2>&1
    if [ $? -eq 0 ]
    then
        echo '<li><a href="http://z.kaotisk-hund.com:8010/v0/audio/ogg/'${hash_string}'">'${hash_string}'</a></li>'
        continue
    fi
done
echo '</ul>'
cat >&1 <<EOF
    </body>
</html>
EOF