livestream code refactoring

This commit is contained in:
2024-08-24 13:07:07 +02:00
parent 434efc79d8
commit d4feefd639
4 changed files with 12 additions and 17 deletions

View File

@@ -111,7 +111,7 @@ export enum LiveStreamStatus {
} }
export type LiveStreamProgress = Record<string, { export type LiveStreamProgress = Record<string, {
Status: LiveStreamStatus status: LiveStreamStatus
WaitTime: string waitTime: string
LiveDate: string liveDate: string
}> }>

View File

@@ -101,17 +101,17 @@ const LiveStreamMonitorView: React.FC = () => {
> >
<TableCell>{k}</TableCell> <TableCell>{k}</TableCell>
<TableCell align='right'> <TableCell align='right'>
{mapStatusToChip(progress[k].Status)} {mapStatusToChip(progress[k].status)}
</TableCell> </TableCell>
<TableCell align='right'> <TableCell align='right'>
{progress[k].Status === LiveStreamStatus.WAITING {progress[k].status === LiveStreamStatus.WAITING
? formatMicro(Number(progress[k].WaitTime)) ? formatMicro(Number(progress[k].waitTime))
: "-" : "-"
} }
</TableCell> </TableCell>
<TableCell align='right'> <TableCell align='right'>
{progress[k].Status === LiveStreamStatus.WAITING {progress[k].status === LiveStreamStatus.WAITING
? new Date(progress[k].LiveDate).toLocaleString() ? new Date(progress[k].liveDate).toLocaleString()
: "-" : "-"
} }
</TableCell> </TableCell>

View File

@@ -5,7 +5,6 @@ import (
"log/slog" "log/slog"
"os" "os"
"path/filepath" "path/filepath"
"time"
"github.com/marcopeocchi/yt-dlp-web-ui/server/config" "github.com/marcopeocchi/yt-dlp-web-ui/server/config"
"github.com/marcopeocchi/yt-dlp-web-ui/server/internal" "github.com/marcopeocchi/yt-dlp-web-ui/server/internal"
@@ -63,11 +62,7 @@ func (m *Monitor) Status() LiveStreamStatus {
// continue // continue
// } // }
status[k] = struct { status[k] = Status{
Status int
WaitTime time.Duration
LiveDate time.Time
}{
Status: v.status, Status: v.status,
WaitTime: v.waitTime, WaitTime: v.waitTime,
LiveDate: v.liveDate, LiveDate: v.liveDate,

View File

@@ -5,7 +5,7 @@ import "time"
type LiveStreamStatus = map[string]Status type LiveStreamStatus = map[string]Status
type Status = struct { type Status = struct {
Status int Status int `json:"status"`
WaitTime time.Duration WaitTime time.Duration `json:"waitTime"`
LiveDate time.Time LiveDate time.Time `json:"liveDate"`
} }