improvements to LIVE tracker
This commit is contained in:
parent
9274796729
commit
581273370d
7 changed files with 45 additions and 16 deletions
|
@ -4,7 +4,6 @@ import (
|
|||
"arimelody-web/model"
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"time"
|
||||
|
@ -63,8 +62,6 @@ func GetTwitchStatus(app *model.AppState, broadcaster string) (*model.TwitchStre
|
|||
return lastStreamState, nil
|
||||
}
|
||||
|
||||
fmt.Print("MAKING COSTLY REQUEST TO TWITCH.TV API...\n")
|
||||
|
||||
requestUrl, _ := url.Parse(TWITCH_API_BASE + "streams")
|
||||
requestUrl.RawQuery = url.Values{
|
||||
"user_login": []string{ broadcaster },
|
||||
|
|
8
main.go
8
main.go
|
@ -460,9 +460,11 @@ func main() {
|
|||
// handle DB migrations
|
||||
controller.CheckDBVersionAndMigrate(app.DB)
|
||||
|
||||
err = controller.TwitchSetup(&app)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "WARN: Failed to set up Twitch integration: %v\n", err)
|
||||
if app.Config.Twitch != nil {
|
||||
err = controller.TwitchSetup(&app)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "WARN: Failed to set up Twitch integration: %v\n", err)
|
||||
}
|
||||
}
|
||||
|
||||
// initial invite code
|
||||
|
|
|
@ -34,8 +34,8 @@ type (
|
|||
DataDirectory string `toml:"data_dir"`
|
||||
TrustedProxies []string `toml:"trusted_proxies"`
|
||||
DB DBConfig `toml:"db"`
|
||||
Discord DiscordConfig `toml:"discord"`
|
||||
Twitch TwitchConfig `toml:"twitch"`
|
||||
Discord *DiscordConfig `toml:"discord"`
|
||||
Twitch *TwitchConfig `toml:"twitch"`
|
||||
}
|
||||
|
||||
AppState struct {
|
||||
|
|
|
@ -231,11 +231,6 @@ div#web-buttons {
|
|||
box-shadow: 0 0 8px var(--primary);
|
||||
}
|
||||
|
||||
#live-banner h2 {
|
||||
margin: 0 0 .4em 0;
|
||||
color: var(--on-background);
|
||||
}
|
||||
|
||||
#live-banner p {
|
||||
margin: 0;
|
||||
}
|
||||
|
@ -252,7 +247,11 @@ div#web-buttons {
|
|||
}
|
||||
|
||||
.live-preview div:first-of-type {
|
||||
text-align: center;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: .3em;
|
||||
}
|
||||
|
||||
.live-thumbnail {
|
||||
|
@ -283,6 +282,36 @@ div#web-buttons {
|
|||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
#live-banner h2 {
|
||||
margin: 0;
|
||||
color: var(--on-background);
|
||||
font-family: 'Inter', sans-serif;
|
||||
font-weight: 800;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.live-pinger {
|
||||
width: .5em;
|
||||
height: .5em;
|
||||
margin: .1em .2em;
|
||||
display: inline-block;
|
||||
border-radius: 100%;
|
||||
background-color: var(--primary);
|
||||
box-shadow: 0 0 4px var(--primary);
|
||||
animation: live-pinger-pulse 1s infinite alternate ease-in-out;
|
||||
}
|
||||
|
||||
@keyframes live-pinger-pulse {
|
||||
from {
|
||||
opacity: .8;
|
||||
transform: scale(1.0);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: scale(1.1);
|
||||
}
|
||||
}
|
||||
|
||||
.live-game {
|
||||
overflow: hidden;
|
||||
text-wrap: nowrap;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
@import url("/style/footer.css");
|
||||
@import url("/style/prideflag.css");
|
||||
@import url("/style/cursor.css");
|
||||
@import url("/font/inter/inter.css");
|
||||
|
||||
@font-face {
|
||||
font-family: "Monaspace Argon";
|
||||
|
|
|
@ -22,7 +22,7 @@ func IndexHandler(app *model.AppState) http.Handler {
|
|||
|
||||
var err error
|
||||
var twitchStatus *model.TwitchStreamInfo = nil
|
||||
if len(app.Config.Twitch.Broadcaster) > 0 {
|
||||
if app.Twitch != nil && len(app.Config.Twitch.Broadcaster) > 0 {
|
||||
twitchStatus, err = controller.GetTwitchStatus(app, app.Config.Twitch.Broadcaster)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "WARN: Failed to get Twitch status for %s: %v\n", app.Config.Twitch.Broadcaster, err)
|
||||
|
|
|
@ -24,13 +24,13 @@
|
|||
<main>
|
||||
{{if .TwitchStatus}}
|
||||
<div id="live-banner">
|
||||
<h2>ari is <span class="live-highlight">LIVE</span> right now!</h2>
|
||||
<div class="live-preview">
|
||||
<div>
|
||||
<img src="{{.TwitchStatus.Thumbnail 144 81}}" alt="livestream thumbnail" class="live-thumbnail">
|
||||
<a href="https://twitch.tv/{{.TwitchStatus.UserName}}" class="live-button">join in!</a>
|
||||
</div>
|
||||
<div class="live-info">
|
||||
<h2>ari melody <span class="live-highlight">LIVE</span> <i class="live-pinger"></i></h2>
|
||||
<p class="live-game"><span class="live-game-prefix">streaming:</span> {{.TwitchStatus.GameName}}</p>
|
||||
<p class="live-title">{{.TwitchStatus.Title}}</p>
|
||||
<p class="live-viewers">{{.TwitchStatus.ViewerCount}} viewers</p>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue