17 Commits

Author SHA1 Message Date
aledjones a6f08e9adc Merge pull request 'changed namespace' (#3) from aledjones-patch-2 into main
Build / build (amd64, darwin) (push) Successful in 3m2s
Build / build (amd64, windows) (push) Successful in 42s
Build / build (arm64, darwin) (push) Successful in 40s
Build / build (arm64, windows) (push) Successful in 41s
Build / build (amd64, linux) (push) Successful in 2m35s
Build / build (arm64, linux) (push) Successful in 34s
Reviewed-on: #3
2024-12-31 10:17:53 +01:00
aledjones 102487b6b9 go.mod aktualisiert
Build / build (amd64, linux) (pull_request) Successful in 1m2s
Build / build (amd64, darwin) (pull_request) Successful in 2m24s
Build / build (arm64, darwin) (pull_request) Successful in 2m30s
Build / build (amd64, windows) (pull_request) Successful in 2m36s
Build / build (arm64, linux) (pull_request) Successful in 2m1s
Build / build (arm64, windows) (pull_request) Successful in 1m2s
2024-12-31 10:13:56 +01:00
aledjones f014563521 changed namespace
Build / build (arm64, darwin) (pull_request) Failing after 16s
Build / build (amd64, windows) (pull_request) Failing after 18s
Build / build (amd64, darwin) (pull_request) Failing after 22s
Build / build (amd64, linux) (pull_request) Failing after 21s
Build / build (arm64, linux) (pull_request) Failing after 7s
Build / build (arm64, windows) (pull_request) Failing after 7s
2024-12-31 10:09:38 +01:00
aledjones e71040b838 Merge pull request 'README.md aktualisiert' (#1) from aledjones-patch-1 into main
Build / build (amd64, linux) (push) Successful in 1m56s
Build / build (arm64, darwin) (push) Successful in 3m15s
Build / build (amd64, darwin) (push) Successful in 3m23s
Build / build (amd64, windows) (push) Successful in 3m21s
Build / build (arm64, linux) (push) Successful in 1m54s
Build / build (arm64, windows) (push) Successful in 57s
Reviewed-on: #1
2024-06-01 16:43:05 +02:00
aledjones 296ad3ddfe .github/workflows/go.yaml aktualisiert
Build / build (amd64, darwin) (pull_request) Successful in 39s
Build / build (amd64, linux) (pull_request) Successful in 22s
Build / build (amd64, windows) (pull_request) Successful in 42s
Build / build (arm64, darwin) (pull_request) Successful in 41s
Build / build (arm64, linux) (pull_request) Successful in 39s
Build / build (arm64, windows) (pull_request) Successful in 41s
2024-06-01 16:37:40 +02:00
aledjones c4b571c91b README.md aktualisiert
Build / build (amd64, darwin) (pull_request) Successful in 41s
Build / build (amd64, linux) (pull_request) Successful in 22s
Build / build (amd64, windows) (pull_request) Successful in 41s
Build / build (arm64, darwin) (pull_request) Successful in 39s
Build / build (arm64, linux) (pull_request) Successful in 37s
Build / build (arm64, windows) (pull_request) Successful in 37s
Umstellung auf eigene Gitea-Instanz
2024-06-01 16:28:37 +02:00
aledjones 2cf4799887 Update go.yaml 2023-03-10 08:18:52 +01:00
aledjones 9e8e6d696d Update README.md 2023-03-10 08:17:25 +01:00
Nico Wunder 8b0cc231d0 1 feature request compare existing songs by (#3)
* adding vscode-ish .gitignore file

* check to compare exact IDs of Tracks while add #1

---------

Co-authored-by: Nico Wunder <n.wunder@onacy.de>
2023-03-07 11:19:52 +01:00
aledjones 799cc904a8 Update README.md 2023-03-07 11:19:06 +01:00
aledjones 45f23d0463 Update go.yaml 2023-03-07 11:17:06 +01:00
aledjones 8280162a04 Merge pull request #6 from aledjones/2-github-actions
Adding go workflow for GitHub Actions
2023-03-07 11:10:59 +01:00
aledjones 3d480acc9f Update go.yaml 2023-03-07 11:09:36 +01:00
aledjones 193aa655f0 Update go.yaml 2023-03-07 10:58:34 +01:00
aledjones 80fc1d135e Update go.yaml 2023-03-07 10:53:26 +01:00
aledjones 815a66eb8c Update go.yaml
adds artifact upload
adds bin/ artifact directory
2023-03-07 10:50:17 +01:00
aledjones c3d49e3473 Create go.yaml 2023-03-07 10:43:24 +01:00
6 changed files with 116 additions and 23 deletions
+40
View File
@@ -0,0 +1,40 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
name: Build
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
os: ["darwin","linux","windows"]
arch: ["amd64","arm64"]
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19
- name: Install dependencies
run: |
go get .
- name: Build
run: GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} go build -o spotigram_${{ matrix.os }}_${{ matrix.arch }} -v main.go
- name: upload artifacts
uses: actions/upload-artifact@v3.1.2
with:
name: spotigram_${{ matrix.os }}_${{ matrix.arch }}
path: spotigram_${{ matrix.os }}_${{ matrix.arch }}
retention-days: 90
+2 -1
View File
@@ -1,2 +1,3 @@
bin/
.idea
.idea
.vscode/launch.json
+3 -1
View File
@@ -1,7 +1,9 @@
Spotigram
=========
_Wenns' gut werden muss_
_Wenns' gut werden muss_
[![build status](https://git.jonasmoeller.de/aledjones/spotigram/actions/workflows/go.yaml/badge.svg)](https://git.jonasmoeller.de/aledjones/spotigram)
## Was ist Spotigram?
+68 -18
View File
@@ -24,14 +24,15 @@ package cmd
import (
"context"
"fmt"
"log"
"strings"
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/zmb3/spotify/v2"
spotifyauth "github.com/zmb3/spotify/v2/auth"
"golang.org/x/oauth2"
"log"
"strings"
)
// telegramBotCmd represents the telegramBot command
@@ -104,30 +105,70 @@ It is not planned to extend this in the future.`,
cobra.CheckErr(err)
if results != nil {
track := results.Tracks.Tracks[0]
playlist, err := client.GetPlaylist(ctx, spotify.ID(viper.GetString("spotify_playlist_id")))
cobra.CheckErr(err)
addTrackResponse, err := client.AddTracksToPlaylist(ctx,
playlist.ID,
results.Tracks.Tracks[0].ID)
tracks, err := client.GetPlaylistItems(ctx, playlist.ID)
cobra.CheckErr(err)
msg.Text = fmt.Sprintf("Ich habe den Titel <pre>%s</pre> von <pre>%s</pre> zur Playlist <pre>%s</pre> hinzugefügt.",
track.Name,
track.Artists[0].Name,
playlist.Name,
)
msg.ParseMode = "HTML"
_, err = bot.Send(msg)
cobra.CheckErr(err)
trackIDs := make([]spotify.ID, 0, len(tracks.Items))
fmt.Printf("New track added to playlist: %s by %s\nsnapshot: %s\n\n",
track.Name,
track.Artists[0].Name,
addTrackResponse)
for page := 1; ; page++ {
for _, track := range tracks.Items {
trackIDs = append(trackIDs, track.Track.Track.ID)
}
err = client.NextPage(ctx, tracks)
if err == spotify.ErrNoMorePages {
break
}
if err != nil {
cobra.CheckErr(err)
}
}
if contains(trackIDs, results.Tracks.Tracks[0].ID) {
track := results.Tracks.Tracks[0]
msg.Text = fmt.Sprintf("⛔ Ooops, dieser Titel ist schon in der Playlist!\n Ich habe den Titel <pre>%s</pre> von <pre>%s</pre> nicht ERNEUT zur Playlist <pre>%s</pre> hinzugefügt.",
track.Name,
track.Artists[0].Name,
playlist.Name,
)
msg.ParseMode = "HTML"
_, err = bot.Send(msg)
cobra.CheckErr(err)
fmt.Printf("Declined adding duplicate track: %s by %s",
track.Name,
track.Artists[0].Name)
} else {
track := results.Tracks.Tracks[0]
addTrackResponse, err := client.AddTracksToPlaylist(ctx,
playlist.ID,
results.Tracks.Tracks[0].ID)
cobra.CheckErr(err)
msg.Text = fmt.Sprintf("Ich habe den Titel <pre>%s</pre> von <pre>%s</pre> zur Playlist <pre>%s</pre> hinzugefügt.",
track.Name,
track.Artists[0].Name,
playlist.Name,
)
msg.ParseMode = "HTML"
_, err = bot.Send(msg)
cobra.CheckErr(err)
fmt.Printf("New track added to playlist: %s by %s\nsnapshot: %s\n\n",
track.Name,
track.Artists[0].Name,
addTrackResponse)
}
}
case "rofl":
msg.Text = "🤣"
_, err = bot.Send(msg)
@@ -156,3 +197,12 @@ func init() {
// is called directly, e.g.:
// telegramBotCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}
func contains(s []spotify.ID, e spotify.ID) bool {
for _, a := range s {
if a == e {
return true
}
}
return false
}
+1 -1
View File
@@ -1,4 +1,4 @@
module github.com/aledjones/spotigram
module git.jonasmoeller.de/aledjones/spotigram
go 1.19
+2 -2
View File
@@ -1,5 +1,5 @@
/*
Copyright © 2023 Jonas Möller <mail@jonasmoeller.de>
Copyright © 2024 Jonas Möller <mail@jonasmoeller.de>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -21,7 +21,7 @@ THE SOFTWARE.
*/
package main
import "github.com/aledjones/spotigram/cmd"
import "git.jonasmoeller.de/aledjones/spotigram/cmd"
func main() {
cmd.Execute()