spotifysync

package module
v0.0.0-...-5c8d9c4 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2020 License: MIT Imports: 12 Imported by: 0

README

Spotify Sync

(wip)

Listen to the same spotify track your friend is listening to!

How it (will) work

  • UserA links their Spotify account with Spotify Sync
  • UserB visits spotifysync.org/sync?user=UserA which presents a Spotify browser player
  • Server queries Spotify to check what UserA is listening to so that UserB can stay synced

Useful for sharing music during livestreams without violating DMCA laws

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	sync.Mutex
	Admins           []string        // Spotify user ids of people with admin priviliges
	PermittedSharers []string        // Spotify user ids of people permitted to register as sharers
	RegisteredUsers  map[string]User `json:"registeredUsers"` // Users who are permitted to share music
	Oauth2Cfg        oauth2.Config
	ListenAddress    string
	Host             string
	Filepath         string `json:"-"`
}

func NewConfigFromFile

func NewConfigFromFile(fp string) (*Config, error)

func (*Config) Save

func (c *Config) Save() error

type CurrentTrack

type CurrentTrack struct {
	Track                Track  `json:"item"`
	IsPlaying            bool   `json:"is_playing"`
	CurrentlyPlayingType string `json:"currently_playing_type"`
	ProgressMS           int    `json:"progress_ms"`
	Timestamp            int64  `json:"timestamp"` // unix millis
	Fetched              int64  `json:"fetched"`   // unix seconds
}

type SpotifyClient

type SpotifyClient struct {
	Cfg *Config
	// contains filtered or unexported fields
}

func NewSpotifyClient

func NewSpotifyClient(cfg *Config) *SpotifyClient

func (*SpotifyClient) CurrentlyPlaying

func (c *SpotifyClient) CurrentlyPlaying(ctx context.Context, user User) (CurrentTrack, error)

func (*SpotifyClient) UserFromToken

func (c *SpotifyClient) UserFromToken(ctx context.Context, t *oauth2.Token) (User, error)

type SpotifySyncServer

type SpotifySyncServer struct {
	SpotifyClient *SpotifyClient
	Cfg           *Config
}

func (*SpotifySyncServer) Callback

func (s *SpotifySyncServer) Callback(w http.ResponseWriter, req *http.Request)

spotify oauth2 callback

func (*SpotifySyncServer) CurrentTrack

func (s *SpotifySyncServer) CurrentTrack(w http.ResponseWriter, req *http.Request)

func (*SpotifySyncServer) Home

func (*SpotifySyncServer) Login

func (s *SpotifySyncServer) Login(w http.ResponseWriter, req *http.Request)

initiate spotify 3-legged oauth

func (*SpotifySyncServer) PermitSharer

func (s *SpotifySyncServer) PermitSharer(w http.ResponseWriter, req *http.Request)

func (*SpotifySyncServer) RegisterHandlers

func (s *SpotifySyncServer) RegisterHandlers()

func (*SpotifySyncServer) Sync

type Track

type Track struct {
	URI string `json:"uri"`
}

type User

type User struct {
	DisplayName string        `json:"display_name"` // Spotify display_name
	Token       *oauth2.Token // Spotify oauth token
}

Directories

Path Synopsis
cmd
spotifysync command

Jump to

Keyboard shortcuts

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