disgofy

package module
v0.0.0-...-1baf491 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

README

disgofy

Go Reference Go Report Go Version License Disgo Version Disgo Discord

Lazy Loading Spotify Integration for Disgolink and Lavalink written in Go aimed to be easy to use

Getting Started

Installing
go get github.com/DisgoOrg/disgofy
Usage

Import the package into your project.

import (
	"github.com/DisgoOrg/disgofy"
	"github.com/DisgoOrg/disgolink/api"
)
Create Spotify Resolver

Now create a *SpotifyResolver by passing in your Lavalink instance and your Spotify Client ID & Secret from here into disgofy.NewSpotifyResolver

spotifyResolver, err := disgofy.NewSpotifyResolver(lavalink, "SPOTIFY_ID", "SPOTIFY_SECRET")
Get Tracks from Spotify Album/Playlist/Track

To get track/s from Spotify pass an album/playlist/track url into SpotifyResolver.LoadItemHandler with a AudioLoaderResultHandler to handle whatever was loaded just like is Disgolink

spotifyResolver.LoadItemHandler("https://open.spotify.com/track/3aniWcwiiYKHpm3F5TdeKD", api.NewResultHandler(
    func(track api.Track) {
    	// found one track
    },
    func(playlist *api.Playlist) {
        // found a playlist
    },
    nil, // disgofy does not support search
    func() {
        // found no matches
    },
    func(e *api.Exception) {
        // something went wrong
    },
))

Documentation

Documentation is unfinished and can be found under

  • Go Reference

Examples

You can find examples under example

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

This section is empty.

Variables

View Source
var SpotifyURLPattern = regexp.MustCompile("^(https?://)?(www\\.)?open\\.spotify\\.com/(user/(?P<user>[a-zA-Z0-9-_]+)/)?(?P<type>track|album|playlist)/(?P<identifier>[a-zA-Z0-9-_]+)?.+")

Functions

This section is empty.

Types

type SpotifyResolver

type SpotifyResolver struct {
	Client   *spotify.Client
	Lavalink api.Lavalink
}

func NewSpotifyResolver

func NewSpotifyResolver(lavalink api.Lavalink, spotifyID string, spotifySecret string) (*SpotifyResolver, error)

func (*SpotifyResolver) LoadItem

func (r *SpotifyResolver) LoadItem(identifier string) *api.LoadResult

func (*SpotifyResolver) LoadItemHandler

func (r *SpotifyResolver) LoadItemHandler(identifier string, audioLoaderResultHandler api.AudioLoaderResultHandler)

type SpotifyTrack

type SpotifyTrack struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewSpotifyTrack

func NewSpotifyTrack(lavalink api.Lavalink, track spotify.SimpleTrack) *SpotifyTrack

func (*SpotifyTrack) Info

func (t *SpotifyTrack) Info() api.TrackInfo

func (*SpotifyTrack) Track

func (t *SpotifyTrack) Track() *string

Jump to

Keyboard shortcuts

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