difm

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2024 License: BSD-2-Clause Imports: 20 Imported by: 0

Documentation

Index

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

Types

type ApplicationMetadata added in v1.3.11

type ApplicationMetadata struct {
	User struct {
		ID         int64  `json:"id"`
		AudioToken string `json:"audio_token"`
		SessionKey string `json:"session_key"`
	} `json:"user"`
	CsrfToken string
}

Jump to

Keyboard shortcuts

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