Documentation ¶
Index ¶
- func Authenticate(ctx *context.AppContext, username, password string) (token string)
- func FavoriteItemChannel(ctx *context.AppContext, favorite components.FavoriteItem) (channel *components.ChannelItem)
- func GetCurrentlyPlaying(ctx *context.AppContext) (currentlyPlaying components.CurrentlyPlaying)
- func GetStreamURL(data []byte, ctx *context.AppContext) (streamURL string, ok bool)
- func ListChannels(ctx *context.AppContext) (channels []components.ChannelItem)
- func ListFavorites(ctx *context.AppContext) (favorites []components.FavoriteItem)
- func Stream(url string, ctx *context.AppContext)
- func ToggleFavorite(ctx *context.AppContext)
- type ApplicationMetadata
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Authenticate ¶
func Authenticate(ctx *context.AppContext, username, password string) (token string)
login workflow 1. GET www.di.fm/login to get the CSRF token 2. POST www.di.fm/login (with CSRF token and other appropriate headers) 3. GET www.di.fm/ to retrieve two key pieces of information
- an "audio_token"
- a "session_key"
Both of which are required to perform advanced player features such as adding/removing favorites.
One added benefit of logging in this way is that di-tui may use the audio token to stream "on-demand" audio in the future, which would allow the player to buffer content. Currently, no buffering is performed because di-tui uses the streaming API.
However, until a developer-friendly, go-native AAC decoder is available, this player will continue using the MP3 "streaming" API.
func FavoriteItemChannel ¶ added in v1.3.11
func FavoriteItemChannel(ctx *context.AppContext, favorite components.FavoriteItem) (channel *components.ChannelItem)
FavoriteItemChannel identifies the ChannelItem that corresponds with a FavoriteItem
func GetCurrentlyPlaying ¶
func GetCurrentlyPlaying(ctx *context.AppContext) (currentlyPlaying components.CurrentlyPlaying)
GetCurrentlyPlaying fetches the list of all currently playing tracks site-side
func GetStreamURL ¶
func GetStreamURL(data []byte, ctx *context.AppContext) (streamURL string, ok bool)
GetStreamURL extracts a playlist's stream URL from raw INI bytes (pls file)
func ListChannels ¶
func ListChannels(ctx *context.AppContext) (channels []components.ChannelItem)
ListChannels lists all premium MP3 channels
func ListFavorites ¶
func ListFavorites(ctx *context.AppContext) (favorites []components.FavoriteItem)
ListFavorites lists a user's favorite channels
func Stream ¶
func Stream(url string, ctx *context.AppContext)
Stream streams the provided URL using the given di.fm premium token
func ToggleFavorite ¶ added in v1.3.11
func ToggleFavorite(ctx *context.AppContext)
ToggleFavorite adds/removes the currentlly selected channel to/from the user's favorites