Skip to content
This repository has been archived by the owner on Oct 3, 2022. It is now read-only.

V6 #1325

Open
wants to merge 17 commits into
base: v6
Choose a base branch
from
Open

V6 #1325

Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion client/options/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ interface Options extends ChangeEmitter {
radio: boolean
eden: boolean
shamiradio: boolean
shamiradio2: boolean
bgVideo: string
bgMute: boolean
horizontalPosting: boolean
Expand Down Expand Up @@ -173,7 +174,7 @@ export function initOptions() {
break
default:
const flags = parseInt(value, 10)
for (const [i, key] of ["radio", "eden", "shamiradio"].entries()) {
for (const [i, key] of ["radio", "eden", "shamiradio", "shamiradio2"].entries()) {
if (flags & 1 << i) {
localStorage.setItem(key, "true")
}
Expand Down
23 changes: 15 additions & 8 deletions client/options/nowPlaying.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,22 @@ class Banner {
}

async fetch() {
const response = await fetch(this.api)
if (!response.ok) {
throw Error(await response.text())
}
const data = this.unmarshal(await response.json())
if (!RadioData.is(data)) {
throw Error("Unexpected response")
let response
const defaults = {listeners: 0, song: "ded", streamer: this.url.split('/')[2]}
try {
response = await fetch(this.api)
}catch(err) {
return defaults
}
return data
if (!response.ok) {
return defaults
}

const data = this.unmarshal(await response.json())
if (!RadioData.is(data)) {
return defaults
}
return data
}

async update() {
Expand Down
28 changes: 24 additions & 4 deletions client/options/specs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,30 @@ export const specs: { [id: string]: OptionSpec } = {
"https://shamiradio.imgoodatth.is/",
"https://shamiradio.imgoodatth.is/status-json.xsl",
({ icestats: { source } }) => {
const [fallback, main] = Array.isArray(source) ? source : [source]
const { listeners, server_name: streamer, title: song = "oh dear, tags aren't set" }
= main?.stream_start ? main : fallback
return { listeners, song, streamer }
if (source === undefined) {
return null
} else {
const [fallback, main] = Array.isArray(source) ? source : [source]
const { listeners, server_name: streamer, title: song = "oh dear, tags aren't set" }
= main?.stream_start ? main : fallback
return { listeners, song, streamer }
}
},
),
},
shamiradio2: {
exec: toggleNowPlaying(
"https://shamiradio.stream/",
"https://shamiradio.stream/status-json.xsl",
({ icestats: { source } }) => {
if (source === undefined) {
return null
} else {
const [fallback, main] = Array.isArray(source) ? source : [source]
const { listeners, server_name: streamer, title: song = "oh dear, tags aren't set" }
= main?.stream_start ? main : fallback
return { listeners, song, streamer }
}
},
),
},
Expand Down
1 change: 1 addition & 0 deletions docs/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ server {
client_body_timeout 600s;
proxy_read_timeout 36000s;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $host;

# WebSockets support
proxy_http_version 1.1;
Expand Down
4 changes: 4 additions & 0 deletions static/src/lang/en_GB/server.json
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,10 @@
"Shamiradio",
"Shamiradio now playing banner"
],
"shamiradio2": [
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please run ./scripts/migrate_lang.js to replicate this in the other language packs.

"ShamIIradio",
"The cooler shamiradio"
],
"spoilers": [
"Image Spoilers",
"Don't spoiler images"
Expand Down
1 change: 1 addition & 0 deletions templates/specs.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ var optionSpecs = [...][]inputSpec{
{ID: "radio"},
{ID: "eden"},
{ID: "shamiradio"},
{ID: "shamiradio2"},
{Type: _hr},
{
ID: "bgVideo",
Expand Down