source_plugins

package module
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: May 1, 2022 License: Apache-2.0 Imports: 4 Imported by: 2

README

Go Reference Go Report Go Version License Disgo Version Disgo Discord

source-plugins

source-plugins is a collection of additional audio sources for disgolink

Getting Started

Installing
go get github.com/disgoorg/source-plugins

Usage

import (
    "github.com/disgoorg/disgolink/lavalink"
    "github.com/disgoorg/source-plugins"
)

// create new lavalink and add the spotify plugin
link := lavalink.New(
    lavalink.WithUserID("user_id_here"),
    lavalink.WithPlugins(
        source_plugins.NewNewSpotifyPlugin(),
        source_plugins.NewAppleMusicPlugin(),
    ),
)

// when loading track you can type cast the track to an ISRCAudioTrack to access extra data
_ = link.BestRestClient().LoadItemHandler("https://open.spotify.com/track/3yk51U329nwdpeIHV0O5ez", lavalink.NewResultHandler(
    func (track lavalink.AudioTrack) {
        if spotifyTrack, ok := track.(*source_plugins.SpotifyAudioTrack); ok {
            println("Spotify ISRC: ", spotifyTrack.ISRC)
            println("Spotify ArtworkURL: ", spotifyTrack.ArtworkURL)
        } else if appleMusicTrack, ok := track.(*source_plugins.AppleMusicAudioTrack); ok {
            println("AppleMusic ISRC: ", appleMusicTrack.ISRC)
            println("AppleMusic ArtworkURL: ", appleMusicTrack.ArtworkURL)
        }
    },
    func (playlist lavalink.AudioPlaylist) {},
    func (tracks []lavalink.AudioTrack) {},
    func () {},
    func (ex lavalink.FriendlyException) {},
))

Troubleshooting

For help feel free to open an issues or reach out on Discord

Contributing

Contributions are welcomed but for bigger changes please first reach out via Discord or create an issue to discuss your intentions and ideas.

License

Distributed under the License. See LICENSE for more information.

Documentation

Index

Constants

View Source
const SearchTypeAppleMusic lavalink.SearchType = "amsearch"
View Source
const SearchTypeSpotify lavalink.SearchType = "spsearch"

Variables

This section is empty.

Functions

func DecodeISRCArtworkURL

func DecodeISRCArtworkURL(r io.Reader) (isrc *string, artworkURL *string, err error)

func EncodeISRCArtworkURL

func EncodeISRCArtworkURL(isrc *string, artworkURL *string, w io.Writer) (err error)

Types

type AppleMusicAudioTrack

type AppleMusicAudioTrack struct {
	lavalink.AudioTrack
	ISRC       *string `json:"isrc"`
	ArtworkURL *string `json:"artwork_url"`
}

func (*AppleMusicAudioTrack) Clone

func (*AppleMusicAudioTrack) UnmarshalJSON

func (t *AppleMusicAudioTrack) UnmarshalJSON(data []byte) error

type AppleMusicPlugin

type AppleMusicPlugin struct{}

func NewAppleMusicPlugin

func NewAppleMusicPlugin() *AppleMusicPlugin

func (*AppleMusicPlugin) Decode

func (*AppleMusicPlugin) Encode

func (p *AppleMusicPlugin) Encode(track lavalink.AudioTrack, w io.Writer) error

func (*AppleMusicPlugin) SourceName

func (p *AppleMusicPlugin) SourceName() string

type SpotifyAudioTrack

type SpotifyAudioTrack struct {
	lavalink.AudioTrack
	ISRC       *string `json:"isrc"`
	ArtworkURL *string `json:"artwork_url"`
}

func (*SpotifyAudioTrack) Clone

func (*SpotifyAudioTrack) UnmarshalJSON

func (t *SpotifyAudioTrack) UnmarshalJSON(data []byte) error

type SpotifyPlugin

type SpotifyPlugin struct{}

func NewSpotifyPlugin

func NewSpotifyPlugin() *SpotifyPlugin

func (*SpotifyPlugin) Decode

func (*SpotifyPlugin) Encode

func (p *SpotifyPlugin) Encode(track lavalink.AudioTrack, w io.Writer) error

func (*SpotifyPlugin) SourceName

func (p *SpotifyPlugin) SourceName() string

Jump to

Keyboard shortcuts

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