mirror of
https://git.sr.ht/~phw/scotty
synced 2025-04-15 17:49:29 +02:00
Restructured code, moved all modules into internal
For now all modules are considered internal. This might change later
This commit is contained in:
parent
f94e0f1e85
commit
857661ebf9
76 changed files with 121 additions and 68 deletions
|
@ -23,10 +23,10 @@ import (
|
|||
"github.com/cli/browser"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
"go.uploadedlobster.com/scotty/backends"
|
||||
"go.uploadedlobster.com/scotty/internal/auth"
|
||||
"go.uploadedlobster.com/scotty/models"
|
||||
"go.uploadedlobster.com/scotty/storage"
|
||||
"go.uploadedlobster.com/scotty/internal/backends"
|
||||
"go.uploadedlobster.com/scotty/internal/models"
|
||||
"go.uploadedlobster.com/scotty/internal/storage"
|
||||
"golang.org/x/oauth2"
|
||||
)
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"go.uploadedlobster.com/scotty/backends"
|
||||
"go.uploadedlobster.com/scotty/internal/backends"
|
||||
)
|
||||
|
||||
// backendsCmd represents the backends command
|
||||
|
|
|
@ -23,9 +23,9 @@ import (
|
|||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
"go.uploadedlobster.com/scotty/backends"
|
||||
"go.uploadedlobster.com/scotty/models"
|
||||
"go.uploadedlobster.com/scotty/storage"
|
||||
"go.uploadedlobster.com/scotty/internal/backends"
|
||||
"go.uploadedlobster.com/scotty/internal/models"
|
||||
"go.uploadedlobster.com/scotty/internal/storage"
|
||||
)
|
||||
|
||||
// listensCmd represents the listens command
|
||||
|
|
|
@ -23,9 +23,9 @@ import (
|
|||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
"go.uploadedlobster.com/scotty/backends"
|
||||
"go.uploadedlobster.com/scotty/models"
|
||||
"go.uploadedlobster.com/scotty/storage"
|
||||
"go.uploadedlobster.com/scotty/internal/backends"
|
||||
"go.uploadedlobster.com/scotty/internal/models"
|
||||
"go.uploadedlobster.com/scotty/internal/storage"
|
||||
)
|
||||
|
||||
// lovesCmd represents the loves command
|
||||
|
|
|
@ -24,7 +24,7 @@ import (
|
|||
"github.com/fatih/color"
|
||||
"github.com/vbauerster/mpb/v8"
|
||||
"github.com/vbauerster/mpb/v8/decor"
|
||||
"go.uploadedlobster.com/scotty/models"
|
||||
"go.uploadedlobster.com/scotty/internal/models"
|
||||
)
|
||||
|
||||
func progressBar(wg *sync.WaitGroup, exportProgress chan models.Progress, importProgress chan models.Progress) *mpb.Progress {
|
||||
|
|
|
@ -22,8 +22,8 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
"go.uploadedlobster.com/scotty/models"
|
||||
"go.uploadedlobster.com/scotty/storage"
|
||||
"go.uploadedlobster.com/scotty/internal/models"
|
||||
"go.uploadedlobster.com/scotty/internal/storage"
|
||||
)
|
||||
|
||||
func BuildRedirectURL(config *viper.Viper, backend string) (*url.URL, error) {
|
|
@ -23,7 +23,7 @@ import (
|
|||
"github.com/spf13/viper"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uploadedlobster.com/scotty/backends"
|
||||
"go.uploadedlobster.com/scotty/internal/backends"
|
||||
)
|
||||
|
||||
func TestBuildRedirectURL(t *testing.T) {
|
|
@ -23,16 +23,16 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
"go.uploadedlobster.com/scotty/backends/deezer"
|
||||
"go.uploadedlobster.com/scotty/backends/dump"
|
||||
"go.uploadedlobster.com/scotty/backends/funkwhale"
|
||||
"go.uploadedlobster.com/scotty/backends/jspf"
|
||||
"go.uploadedlobster.com/scotty/backends/listenbrainz"
|
||||
"go.uploadedlobster.com/scotty/backends/maloja"
|
||||
"go.uploadedlobster.com/scotty/backends/scrobblerlog"
|
||||
"go.uploadedlobster.com/scotty/backends/spotify"
|
||||
"go.uploadedlobster.com/scotty/backends/subsonic"
|
||||
"go.uploadedlobster.com/scotty/models"
|
||||
"go.uploadedlobster.com/scotty/internal/backends/deezer"
|
||||
"go.uploadedlobster.com/scotty/internal/backends/dump"
|
||||
"go.uploadedlobster.com/scotty/internal/backends/funkwhale"
|
||||
"go.uploadedlobster.com/scotty/internal/backends/jspf"
|
||||
"go.uploadedlobster.com/scotty/internal/backends/listenbrainz"
|
||||
"go.uploadedlobster.com/scotty/internal/backends/maloja"
|
||||
"go.uploadedlobster.com/scotty/internal/backends/scrobblerlog"
|
||||
"go.uploadedlobster.com/scotty/internal/backends/spotify"
|
||||
"go.uploadedlobster.com/scotty/internal/backends/subsonic"
|
||||
"go.uploadedlobster.com/scotty/internal/models"
|
||||
)
|
||||
|
||||
type BackendInfo struct {
|
|
@ -23,15 +23,15 @@ import (
|
|||
|
||||
"github.com/spf13/viper"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"go.uploadedlobster.com/scotty/backends"
|
||||
"go.uploadedlobster.com/scotty/backends/dump"
|
||||
"go.uploadedlobster.com/scotty/backends/funkwhale"
|
||||
"go.uploadedlobster.com/scotty/backends/jspf"
|
||||
"go.uploadedlobster.com/scotty/backends/listenbrainz"
|
||||
"go.uploadedlobster.com/scotty/backends/maloja"
|
||||
"go.uploadedlobster.com/scotty/backends/scrobblerlog"
|
||||
"go.uploadedlobster.com/scotty/backends/subsonic"
|
||||
"go.uploadedlobster.com/scotty/models"
|
||||
"go.uploadedlobster.com/scotty/internal/backends"
|
||||
"go.uploadedlobster.com/scotty/internal/backends/dump"
|
||||
"go.uploadedlobster.com/scotty/internal/backends/funkwhale"
|
||||
"go.uploadedlobster.com/scotty/internal/backends/jspf"
|
||||
"go.uploadedlobster.com/scotty/internal/backends/listenbrainz"
|
||||
"go.uploadedlobster.com/scotty/internal/backends/maloja"
|
||||
"go.uploadedlobster.com/scotty/internal/backends/scrobblerlog"
|
||||
"go.uploadedlobster.com/scotty/internal/backends/subsonic"
|
||||
"go.uploadedlobster.com/scotty/internal/models"
|
||||
)
|
||||
|
||||
func TestResolveBackend(t *testing.T) {
|
|
@ -29,7 +29,7 @@ import (
|
|||
"github.com/jarcoal/httpmock"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uploadedlobster.com/scotty/backends/deezer"
|
||||
"go.uploadedlobster.com/scotty/internal/backends/deezer"
|
||||
"golang.org/x/oauth2"
|
||||
)
|
||||
|
|
@ -24,7 +24,7 @@ import (
|
|||
|
||||
"github.com/spf13/viper"
|
||||
"go.uploadedlobster.com/scotty/internal/auth"
|
||||
"go.uploadedlobster.com/scotty/models"
|
||||
"go.uploadedlobster.com/scotty/internal/models"
|
||||
"golang.org/x/oauth2"
|
||||
)
|
||||
|
|
@ -24,7 +24,7 @@ import (
|
|||
"github.com/spf13/viper"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uploadedlobster.com/scotty/backends/deezer"
|
||||
"go.uploadedlobster.com/scotty/internal/backends/deezer"
|
||||
)
|
||||
|
||||
func TestFromConfig(t *testing.T) {
|
|
@ -22,7 +22,7 @@ import (
|
|||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uploadedlobster.com/scotty/backends/deezer"
|
||||
"go.uploadedlobster.com/scotty/internal/backends/deezer"
|
||||
)
|
||||
|
||||
func TestUserTracksResult(t *testing.T) {
|
|
@ -18,7 +18,7 @@ package dump
|
|||
|
||||
import (
|
||||
"github.com/spf13/viper"
|
||||
"go.uploadedlobster.com/scotty/models"
|
||||
"go.uploadedlobster.com/scotty/internal/models"
|
||||
)
|
||||
|
||||
type DumpBackend struct{}
|
|
@ -28,7 +28,7 @@ import (
|
|||
"github.com/jarcoal/httpmock"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uploadedlobster.com/scotty/backends/funkwhale"
|
||||
"go.uploadedlobster.com/scotty/internal/backends/funkwhale"
|
||||
)
|
||||
|
||||
func TestNewClient(t *testing.T) {
|
|
@ -21,7 +21,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
"go.uploadedlobster.com/scotty/models"
|
||||
"go.uploadedlobster.com/scotty/internal/models"
|
||||
)
|
||||
|
||||
const FunkwhaleClientName = "Funkwhale"
|
|
@ -23,8 +23,8 @@ import (
|
|||
"github.com/spf13/viper"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uploadedlobster.com/scotty/backends/funkwhale"
|
||||
"go.uploadedlobster.com/scotty/models"
|
||||
"go.uploadedlobster.com/scotty/internal/backends/funkwhale"
|
||||
"go.uploadedlobster.com/scotty/internal/models"
|
||||
)
|
||||
|
||||
func TestFromConfig(t *testing.T) {
|
|
@ -23,7 +23,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
"go.uploadedlobster.com/scotty/models"
|
||||
"go.uploadedlobster.com/scotty/internal/models"
|
||||
)
|
||||
|
||||
type JSPFBackend struct {
|
|
@ -22,7 +22,7 @@ import (
|
|||
|
||||
"github.com/spf13/viper"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"go.uploadedlobster.com/scotty/backends/scrobblerlog"
|
||||
"go.uploadedlobster.com/scotty/internal/backends/scrobblerlog"
|
||||
)
|
||||
|
||||
func TestFromConfig(t *testing.T) {
|
|
@ -27,7 +27,7 @@ import (
|
|||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uploadedlobster.com/scotty/backends/jspf"
|
||||
"go.uploadedlobster.com/scotty/internal/backends/jspf"
|
||||
)
|
||||
|
||||
func TestUnmarshalSimple(t *testing.T) {
|
|
@ -29,7 +29,7 @@ import (
|
|||
"github.com/jarcoal/httpmock"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uploadedlobster.com/scotty/backends/listenbrainz"
|
||||
"go.uploadedlobster.com/scotty/internal/backends/listenbrainz"
|
||||
)
|
||||
|
||||
func TestNewClient(t *testing.T) {
|
|
@ -22,7 +22,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
"go.uploadedlobster.com/scotty/models"
|
||||
"go.uploadedlobster.com/scotty/internal/models"
|
||||
)
|
||||
|
||||
type ListenBrainzApiBackend struct {
|
|
@ -23,8 +23,8 @@ import (
|
|||
"github.com/spf13/viper"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uploadedlobster.com/scotty/backends/listenbrainz"
|
||||
"go.uploadedlobster.com/scotty/models"
|
||||
"go.uploadedlobster.com/scotty/internal/backends/listenbrainz"
|
||||
"go.uploadedlobster.com/scotty/internal/models"
|
||||
)
|
||||
|
||||
func TestFromConfig(t *testing.T) {
|
|
@ -28,7 +28,7 @@ import (
|
|||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uploadedlobster.com/scotty/backends/listenbrainz"
|
||||
"go.uploadedlobster.com/scotty/internal/backends/listenbrainz"
|
||||
)
|
||||
|
||||
func TestTrackDurationMillisecondsInt(t *testing.T) {
|
53
internal/backends/listenbrainz/testdata/listen.json
vendored
Normal file
53
internal/backends/listenbrainz/testdata/listen.json
vendored
Normal file
|
@ -0,0 +1,53 @@
|
|||
{
|
||||
"inserted_at": 1700580352,
|
||||
"listened_at": 1700580273,
|
||||
"recording_msid": "0a3144ea-f85c-4238-b0e3-e3d7a422df9d",
|
||||
"track_metadata": {
|
||||
"additional_info": {
|
||||
"artist_names": [
|
||||
"Dool"
|
||||
],
|
||||
"discnumber": 1,
|
||||
"duration_ms": 413826,
|
||||
"isrc": "DES561620801",
|
||||
"music_service": "spotify.com",
|
||||
"origin_url": "https://open.spotify.com/track/2JKUgGuXK3dEvyuIJ4Yj2V",
|
||||
"recording_msid": "0a3144ea-f85c-4238-b0e3-e3d7a422df9d",
|
||||
"release_artist_name": "Dool",
|
||||
"release_artist_names": [
|
||||
"Dool"
|
||||
],
|
||||
"spotify_album_artist_ids": [
|
||||
"https://open.spotify.com/artist/101HSR6JTJqe3DBh6rb8kz"
|
||||
],
|
||||
"spotify_album_id": "https://open.spotify.com/album/5U1umzRH4EONHWsFgPtRbA",
|
||||
"spotify_artist_ids": [
|
||||
"https://open.spotify.com/artist/101HSR6JTJqe3DBh6rb8kz"
|
||||
],
|
||||
"spotify_id": "https://open.spotify.com/track/2JKUgGuXK3dEvyuIJ4Yj2V",
|
||||
"submission_client": "listenbrainz",
|
||||
"tracknumber": 5
|
||||
},
|
||||
"artist_name": "Dool",
|
||||
"mbid_mapping": {
|
||||
"artist_mbids": [
|
||||
"24412926-c7bd-48e8-afad-8a285b42e131"
|
||||
],
|
||||
"artists": [
|
||||
{
|
||||
"artist_credit_name": "Dool",
|
||||
"artist_mbid": "24412926-c7bd-48e8-afad-8a285b42e131",
|
||||
"join_phrase": ""
|
||||
}
|
||||
],
|
||||
"caa_id": 15991300316,
|
||||
"caa_release_mbid": "d7f22677-9803-4d21-ba42-081b633a6f68",
|
||||
"recording_mbid": "c0a1fc94-5f04-4a5f-bc09-e5de0c49cd12",
|
||||
"recording_name": "Oweynagat",
|
||||
"release_mbid": "aa1ea1ac-7ec4-4542-a494-105afbfe547d"
|
||||
},
|
||||
"release_name": "Here Now, There Then",
|
||||
"track_name": "Oweynagat"
|
||||
},
|
||||
"user_name": "outsidecontext"
|
||||
}
|
|
@ -28,7 +28,7 @@ import (
|
|||
"github.com/jarcoal/httpmock"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uploadedlobster.com/scotty/backends/maloja"
|
||||
"go.uploadedlobster.com/scotty/internal/backends/maloja"
|
||||
)
|
||||
|
||||
func TestNewClient(t *testing.T) {
|
|
@ -23,7 +23,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
"go.uploadedlobster.com/scotty/models"
|
||||
"go.uploadedlobster.com/scotty/internal/models"
|
||||
)
|
||||
|
||||
type MalojaApiBackend struct {
|
|
@ -22,7 +22,7 @@ import (
|
|||
|
||||
"github.com/spf13/viper"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"go.uploadedlobster.com/scotty/backends/maloja"
|
||||
"go.uploadedlobster.com/scotty/internal/backends/maloja"
|
||||
)
|
||||
|
||||
func TestFromConfig(t *testing.T) {
|
|
@ -17,7 +17,7 @@ Scotty. If not, see <https://www.gnu.org/licenses/>.
|
|||
|
||||
package backends
|
||||
|
||||
import "go.uploadedlobster.com/scotty/models"
|
||||
import "go.uploadedlobster.com/scotty/internal/models"
|
||||
|
||||
func ProcessListensImports(importer models.ListensImport, results chan models.ListensResult, out chan models.ImportResult, progress chan models.Progress) {
|
||||
defer close(out)
|
|
@ -31,7 +31,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"go.uploadedlobster.com/scotty/models"
|
||||
"go.uploadedlobster.com/scotty/internal/models"
|
||||
)
|
||||
|
||||
type ScrobblerLog struct {
|
|
@ -30,8 +30,8 @@ import (
|
|||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uploadedlobster.com/scotty/backends/scrobblerlog"
|
||||
"go.uploadedlobster.com/scotty/models"
|
||||
"go.uploadedlobster.com/scotty/internal/backends/scrobblerlog"
|
||||
"go.uploadedlobster.com/scotty/internal/models"
|
||||
)
|
||||
|
||||
var testScrobblerLog = `#AUDIOSCROBBLER/1.1
|
|
@ -23,7 +23,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
"go.uploadedlobster.com/scotty/models"
|
||||
"go.uploadedlobster.com/scotty/internal/models"
|
||||
)
|
||||
|
||||
type ScrobblerLogBackend struct {
|
|
@ -21,7 +21,7 @@ import (
|
|||
|
||||
"github.com/spf13/viper"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"go.uploadedlobster.com/scotty/backends/scrobblerlog"
|
||||
"go.uploadedlobster.com/scotty/internal/backends/scrobblerlog"
|
||||
)
|
||||
|
||||
func TestFromConfig(t *testing.T) {
|
|
@ -29,7 +29,7 @@ import (
|
|||
"github.com/jarcoal/httpmock"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uploadedlobster.com/scotty/backends/spotify"
|
||||
"go.uploadedlobster.com/scotty/internal/backends/spotify"
|
||||
"golang.org/x/oauth2"
|
||||
)
|
||||
|
|
@ -29,7 +29,7 @@ import (
|
|||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uploadedlobster.com/scotty/backends/spotify"
|
||||
"go.uploadedlobster.com/scotty/internal/backends/spotify"
|
||||
)
|
||||
|
||||
func TestRecentlyPlayedResult(t *testing.T) {
|
|
@ -26,7 +26,7 @@ import (
|
|||
|
||||
"github.com/spf13/viper"
|
||||
"go.uploadedlobster.com/scotty/internal/auth"
|
||||
"go.uploadedlobster.com/scotty/models"
|
||||
"go.uploadedlobster.com/scotty/internal/models"
|
||||
"golang.org/x/oauth2"
|
||||
"golang.org/x/oauth2/spotify"
|
||||
)
|
|
@ -26,7 +26,7 @@ import (
|
|||
"github.com/spf13/viper"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uploadedlobster.com/scotty/backends/spotify"
|
||||
"go.uploadedlobster.com/scotty/internal/backends/spotify"
|
||||
)
|
||||
|
||||
func TestFromConfig(t *testing.T) {
|
|
@ -23,7 +23,7 @@ import (
|
|||
|
||||
"github.com/delucks/go-subsonic"
|
||||
"github.com/spf13/viper"
|
||||
"go.uploadedlobster.com/scotty/models"
|
||||
"go.uploadedlobster.com/scotty/internal/models"
|
||||
)
|
||||
|
||||
type SubsonicApiBackend struct {
|
|
@ -23,7 +23,7 @@ import (
|
|||
go_subsonic "github.com/delucks/go-subsonic"
|
||||
"github.com/spf13/viper"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"go.uploadedlobster.com/scotty/backends/subsonic"
|
||||
"go.uploadedlobster.com/scotty/internal/backends/subsonic"
|
||||
)
|
||||
|
||||
func TestFromConfig(t *testing.T) {
|
|
@ -18,7 +18,7 @@ package backends
|
|||
import (
|
||||
"context"
|
||||
|
||||
"go.uploadedlobster.com/scotty/storage"
|
||||
"go.uploadedlobster.com/scotty/internal/storage"
|
||||
"golang.org/x/oauth2"
|
||||
)
|
||||
|
|
@ -28,7 +28,7 @@ import (
|
|||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uploadedlobster.com/scotty/models"
|
||||
"go.uploadedlobster.com/scotty/internal/models"
|
||||
)
|
||||
|
||||
func TestTrackArtistName(t *testing.T) {
|
|
@ -23,7 +23,7 @@ import (
|
|||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uploadedlobster.com/scotty/storage"
|
||||
"go.uploadedlobster.com/scotty/internal/storage"
|
||||
"golang.org/x/oauth2"
|
||||
)
|
||||
|
Loading…
Add table
Reference in a new issue