listenbrainz

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2024 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Copyright © 2023 Philipp Wolfer <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright © 2023 Philipp Wolfer <[email protected]>

This file is part of Scotty.

Scotty is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Scotty is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Scotty. If not, see <https://www.gnu.org/licenses/>.

Copyright © 2023 Philipp Wolfer <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Index

Constants

View Source
const (
	DefaultItemsPerGet   = 25
	MaxItemsPerGet       = 1000
	MaxListensPerRequest = 1000
)
View Source
const (
	PlayingNow listenType = "playing_now"
	Single     listenType = "single"
	Import     listenType = "import"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Artist

type Artist struct {
	ArtistCreditName string `json:"artist_credit_name,omitempty"`
	ArtistMbid       string `json:"artist_mbid,omitempty"`
	JoinPhrase       string `json:"join_phrase,omitempty"`
}

type Client

type Client struct {
	HttpClient *resty.Client
	MaxResults int
}

func NewClient

func NewClient(token string) Client

func (Client) GetFeedback

func (c Client) GetFeedback(user string, status int, offset int) (result GetFeedbackResult, err error)

func (Client) GetListens

func (c Client) GetListens(user string, maxTime time.Time, minTime time.Time) (result GetListensResult, err error)

func (Client) Lookup

func (c Client) Lookup(recordingName string, artistName string) (result LookupResult, err error)

func (Client) SendFeedback

func (c Client) SendFeedback(feedback Feedback) (result StatusResult, err error)

func (Client) SubmitListens

func (c Client) SubmitListens(listens ListenSubmission) (result StatusResult, err error)

type ErrorResult

type ErrorResult struct {
	Code  int    `json:"code"`
	Error string `json:"error"`
}

type Feedback

type Feedback struct {
	Created       int64  `json:"created,omitempty"`
	RecordingMbid string `json:"recording_mbid,omitempty"`
	RecordingMsid string `json:"recording_msid,omitempty"`
	Score         int    `json:"score,omitempty"`
	TrackMetadata *Track `json:"track_metadata,omitempty"`
	UserName      string `json:"user_id,omitempty"`
}

func (Feedback) AsLove

func (f Feedback) AsLove() models.Love

type GetFeedbackResult

type GetFeedbackResult struct {
	Count      int        `json:"count"`
	TotalCount int        `json:"total_count"`
	Offset     int        `json:"offset"`
	Feedback   []Feedback `json:"feedback"`
}

type GetListenPayload

type GetListenPayload struct {
	Count                 int      `json:"count"`
	UserName              string   `json:"user_id"`
	LatestListenTimestamp int64    `json:"latest_listen_ts"`
	OldestListenTimestamp int64    `json:"oldest_listen_ts"`
	Listens               []Listen `json:"listens"`
}

type GetListensResult

type GetListensResult struct {
	Payload GetListenPayload `json:"payload"`
}

type Listen

type Listen struct {
	InsertedAt    int64  `json:"inserted_at,omitempty"`
	ListenedAt    int64  `json:"listened_at"`
	RecordingMsid string `json:"recording_msid,omitempty"`
	UserName      string `json:"user_name,omitempty"`
	TrackMetadata Track  `json:"track_metadata"`
}

func (Listen) AsListen

func (lbListen Listen) AsListen() models.Listen

type ListenBrainzApiBackend

type ListenBrainzApiBackend struct {
	// contains filtered or unexported fields
}

func (*ListenBrainzApiBackend) ExportListens

func (b *ListenBrainzApiBackend) ExportListens(oldestTimestamp time.Time, results chan models.ListensResult, progress chan models.Progress)

func (*ListenBrainzApiBackend) ExportLoves

func (b *ListenBrainzApiBackend) ExportLoves(oldestTimestamp time.Time, results chan models.LovesResult, progress chan models.Progress)

func (*ListenBrainzApiBackend) FinishImport

func (b *ListenBrainzApiBackend) FinishImport() error

func (*ListenBrainzApiBackend) FromConfig

func (b *ListenBrainzApiBackend) FromConfig(config *config.ServiceConfig) models.Backend

func (*ListenBrainzApiBackend) ImportListens

func (b *ListenBrainzApiBackend) ImportListens(export models.ListensResult, importResult models.ImportResult, progress chan models.Progress) (models.ImportResult, error)

func (*ListenBrainzApiBackend) ImportLoves

func (b *ListenBrainzApiBackend) ImportLoves(export models.LovesResult, importResult models.ImportResult, progress chan models.Progress) (models.ImportResult, error)

func (*ListenBrainzApiBackend) Name

func (b *ListenBrainzApiBackend) Name() string

func (*ListenBrainzApiBackend) Options added in v0.3.0

func (*ListenBrainzApiBackend) StartImport

func (b *ListenBrainzApiBackend) StartImport() error

type ListenSubmission

type ListenSubmission struct {
	ListenType listenType `json:"listen_type"`
	Payload    []Listen   `json:"payload"`
}

type LookupResult

type LookupResult struct {
	ArtistCreditName string   `json:"artist_credit_name"`
	ReleaseName      string   `json:"release_name"`
	RecordingName    string   `json:"recording_name"`
	RecordingMbid    string   `json:"recording_mbid"`
	ReleaseMbid      string   `json:"release_mbid"`
	ArtistMbids      []string `json:"artist_mbids"`
}

type MbidMapping

type MbidMapping struct {
	RecordingName string   `json:"recording_name,omitempty"`
	RecordingMbid string   `json:"recording_mbid,omitempty"`
	ReleaseMbid   string   `json:"release_mbid,omitempty"`
	ArtistMbids   []string `json:"artist_mbids,omitempty"`
	Artists       []Artist `json:"artists,omitempty"`
}

type StatusResult

type StatusResult struct {
	Status string `json:"status"`
}

type Track

type Track struct {
	TrackName      string         `json:"track_name,omitempty"`
	ArtistName     string         `json:"artist_name,omitempty"`
	ReleaseName    string         `json:"release_name,omitempty"`
	AdditionalInfo map[string]any `json:"additional_info,omitempty"`
	MbidMapping    *MbidMapping   `json:"mbid_mapping,omitempty"`
}

func (Track) AsTrack

func (t Track) AsTrack() models.Track

func (Track) DiscNumber

func (t Track) DiscNumber() int

func (Track) Duration

func (t Track) Duration() time.Duration

func (Track) ISRC

func (t Track) ISRC() string

func (Track) RecordingMbid

func (t Track) RecordingMbid() string

func (Track) ReleaseGroupMbid

func (t Track) ReleaseGroupMbid() string

func (Track) ReleaseMbid

func (t Track) ReleaseMbid() string

func (Track) TrackNumber

func (t Track) TrackNumber() int

Jump to

Keyboard shortcuts

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