-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
inital commit with support for passing spotify SongIDs
- Loading branch information
1 parent
3bb2949
commit 61b0485
Showing
6 changed files
with
138 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
FROM golang:latest AS builder | ||
|
||
ENV DEP_VERSION=v0.3.2 | ||
|
||
RUN curl -fsSL -o /usr/local/bin/dep https://github.com/golang/dep/releases/download/${DEP_VERSION}/dep-linux-amd64 && chmod +x /usr/local/bin/dep | ||
|
||
RUN mkdir -p /go/src/github.com/trisongulate | ||
WORKDIR /go/src/github.com/trisongulate | ||
|
||
COPY Gopkg.toml Gopkg.lock ./ | ||
# copies the Gopkg.toml and Gopkg.lock to WORKDIR | ||
|
||
RUN dep ensure -vendor-only | ||
|
||
ADD . . | ||
RUN go install . | ||
|
||
ENTRYPOINT [ "/go/bin/trisongulate" ] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
# Gopkg.toml example | ||
# | ||
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md | ||
# for detailed Gopkg.toml documentation. | ||
# | ||
# required = ["github.com/user/thing/cmd/thing"] | ||
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] | ||
# | ||
# [[constraint]] | ||
# name = "github.com/user/project" | ||
# version = "1.0.0" | ||
# | ||
# [[constraint]] | ||
# name = "github.com/user/project2" | ||
# branch = "dev" | ||
# source = "github.com/myfork/project2" | ||
# | ||
# [[override]] | ||
# name = "github.com/x/y" | ||
# version = "2.4.0" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
version: '3' | ||
services: | ||
trisongulate: | ||
build: . | ||
env_file: | ||
- local.env | ||
command: 0zlTLKnLY5hYur9w2hPLqB 7bFOkwjxOcGaw6ZULE58Mh 5VS7aJFWhrm5U4gO7wHbVB |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"log" | ||
"os" | ||
|
||
"github.com/zmb3/spotify" | ||
"golang.org/x/oauth2/clientcredentials" | ||
) | ||
|
||
func main() { | ||
//Get Auth Token for Spotify | ||
config := &clientcredentials.Config{ | ||
ClientID: os.Getenv("SPOTIFY_ID"), | ||
ClientSecret: os.Getenv("SPOTIFY_SECRET"), | ||
TokenURL: spotify.TokenURL, | ||
} | ||
token, err := config.Token(context.Background()) | ||
if err != nil { | ||
log.Fatalf("couldn't get token: %v", err) | ||
} | ||
|
||
client := spotify.Authenticator{}.NewClient(token) | ||
|
||
//Get Track IDs | ||
trackIDs := []spotify.ID{spotify.ID(os.Args[1]), spotify.ID(os.Args[2]), spotify.ID(os.Args[3])} | ||
|
||
//Build recommend Request | ||
seeds := spotify.Seeds{ | ||
Artists: []spotify.ID{}, | ||
Tracks: trackIDs, | ||
Genres: []string{}, | ||
} | ||
|
||
//Get Recs from Spotify | ||
recs, err := client.GetRecommendations(seeds, nil, nil) | ||
if err != nil { | ||
log.Fatalf("couldn't get Recs: %v", err) | ||
} | ||
for _, recommendations := range recs.Tracks { | ||
fmt.Println(" ", recommendations.Name, " ", recommendations.Artists) | ||
} | ||
|
||
} |