Skip to content

Commit

Permalink
chore: keep member names consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
muesli committed Mar 1, 2023
1 parent c77c861 commit 09753f3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
9 changes: 4 additions & 5 deletions lastfm.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ import (
)

func lastfmFavouriteAlbums(count int) interface{} {

params := lastfm.P{
"user": lastfmUser,
"limit": count,
}
albums, err := lastfmApi.User.GetTopAlbums(params)
albums, err := lastfmClient.User.GetTopAlbums(params)
if err != nil {
panic(err)
}
Expand All @@ -22,7 +21,7 @@ func lastfmFavouriteTracks(count int) interface{} {
"user": lastfmUser,
"limit": count,
}
tracks, err := lastfmApi.User.GetTopTracks(params)
tracks, err := lastfmClient.User.GetTopTracks(params)
if err != nil {
panic(err)
}
Expand All @@ -34,7 +33,7 @@ func lastfmFavouriteArtists(count int) interface{} {
"user": lastfmUser,
"limit": count,
}
artists, err := lastfmApi.User.GetTopArtists(params)
artists, err := lastfmClient.User.GetTopArtists(params)
if err != nil {
panic(err)
}
Expand All @@ -46,7 +45,7 @@ func lastfmRecentTracks(count int) interface{} {
"user": lastfmUser,
"limit": count,
}
tracks, err := lastfmApi.User.GetRecentTracks(params)
tracks, err := lastfmClient.User.GetRecentTracks(params)
if err != nil {
panic(err)
}
Expand Down
29 changes: 14 additions & 15 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import (
var (
gitHubClient *githubv4.Client
goodReadsClient *goodreads.Client
goodReadsID string
username string
lastfmClient *lastfm.Api

lastfmApi *lastfm.Api
goodReadsID string
username string
lastfmUser string
lastfmApiKey string
lastfmSecret string
Expand Down Expand Up @@ -64,27 +64,31 @@ func main() {
"goodReadsCurrentlyReading": goodReadsCurrentlyReading,
/* Literal.club */
"literalClubCurrentlyReading": literalClubCurrentlyReading,
/* last.fm */
"lastfmFavouriteAlbums": lastfmFavouriteAlbums,
"lastfmFavouriteTracks": lastfmFavouriteTracks,
"lastfmFavouriteArtists": lastfmFavouriteArtists,
"lastfmRecentTracks": lastfmRecentTracks,
/* Utils */
"humanize": humanized,
"reverse": reverse,
"now": time.Now,
"contains": strings.Contains,
"toLower": strings.ToLower,
/* last.fm* */
"lastfmFavouriteAlbums": lastfmFavouriteAlbums,
"lastfmFavouriteTracks": lastfmFavouriteTracks,
"lastfmFavouriteArtists": lastfmFavouriteArtists,
"lastfmRecentTracks": lastfmRecentTracks,
}).Parse(string(tplIn))
if err != nil {
fmt.Println("Can't parse template:", err)
os.Exit(1)
}

var httpClient *http.Client
gitHubToken := os.Getenv("GITHUB_TOKEN")
goodReadsToken := os.Getenv("GOODREADS_TOKEN")
goodReadsID = os.Getenv("GOODREADS_USER_ID")
lastfmUser = os.Getenv("LASTFM_USER")
lastfmApiKey = os.Getenv("LASTFM_API_KEY")
lastfmSecret = os.Getenv("LASTFM_API_SECRET")

var httpClient *http.Client
if len(gitHubToken) > 0 {
httpClient = oauth2.NewClient(context.Background(), oauth2.StaticTokenSource(
&oauth2.Token{AccessToken: gitHubToken},
Expand All @@ -93,6 +97,7 @@ func main() {

gitHubClient = githubv4.NewClient(httpClient)
goodReadsClient = goodreads.NewClient(goodReadsToken)
lastfmClient = lastfm.New(lastfmApiKey, lastfmSecret)

if len(gitHubToken) > 0 {
username, err = getUsername()
Expand All @@ -102,12 +107,6 @@ func main() {
}
}

lastfmUser = os.Getenv("LASTFM_USER")
lastfmApiKey = os.Getenv("LASTFM_API_KEY")
lastfmSecret = os.Getenv("LASTFM_API_SECRET")

lastfmApi = lastfm.New(lastfmApiKey, lastfmSecret)

w := os.Stdout
if len(*write) > 0 {
f, err := os.Create(*write)
Expand Down

0 comments on commit 09753f3

Please sign in to comment.