aboutsummaryrefslogtreecommitdiff
path: root/create_static_list.sh
blob: a618d9f68f65b9aed076aab91d682d6669cc6921 (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
#!/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>Lists</h2><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 '<h2>Shows</h2><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