streammeta

package
v0.15.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 22, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package streammeta extracts now-playing data from live audio streams.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Title

func Title(block string) string

Title extracts StreamTitle from one ICY metadata block.

Types

type NowPlaying

type NowPlaying struct {
	// Raw is the unmodified stream title.
	Raw string `json:"raw"`
	// Artist is populated when the title follows an artist-title form.
	Artist string `json:"artist,omitempty"`
	// Title is the song, program, or complete stream title.
	Title string `json:"title"`
	// Program is a station-supplied show or programme name when available.
	Program string `json:"program,omitempty"`
	// Artwork is the current station or track artwork URL.
	Artwork string `json:"artwork,omitempty"`
	// ChangedAt is when this title became current.
	ChangedAt time.Time `json:"changed_at,omitzero"`
}

NowPlaying is a normalized live-stream metadata update.

func Parse

func Parse(raw string) NowPlaying

Parse converts a raw stream title into structured fields.

type Reader

type Reader struct {
	// contains filtered or unexported fields
}

Reader removes interleaved metadata while passing audio to a decoder.

func NewReader

func NewReader(source io.ReadCloser, interval int, onTitle func(string)) *Reader

NewReader wraps an ICY response body with its advertised metadata interval.

func (*Reader) Close

func (r *Reader) Close() error

Close closes the underlying live response body.

func (*Reader) Read

func (r *Reader) Read(p []byte) (int, error)

Read returns audio bytes without crossing into a metadata block.

type Source

type Source struct {
	// Body contains audio with any interleaved ICY blocks removed.
	Body io.ReadCloser
	// ContentType is the normalized response media type.
	ContentType string
	// StationName is the server's advertised station name.
	StationName string
	// Playlist reports content that the decoder must open by URL to retain a base path.
	Playlist bool
}

Source is an open live response that can be passed directly to a decoder.

func Open

func Open(ctx context.Context, rawURL string, headers map[string]string, onTitle func(string)) (Source, error)

Open requests one live stream with ICY metadata enabled.

func OpenFinite added in v0.15.0

func OpenFinite(ctx context.Context, rawURL string, headers map[string]string, onTitle func(string)) (Source, error)

OpenFinite allows validated byte-range seeking for finite, non-ICY responses.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL