godiscogs

package module
v0.0.0-...-f1692f7 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: MIT Imports: 17 Imported by: 10

README

Godiscogs

Golang interface to discogs, with some refinements for my system. Also some bonus bits and pieces.

Coverage Status

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DiscogsRequests request out to discogs
	DiscogsRequests = promauto.NewCounterVec(prometheus.CounterOpts{
		Name: "godiscogs_requests",
		Help: "The number of server requests",
	}, []string{"method", "path1"})

	// DiscogsRequests request out to discogs
	RequestLatency = promauto.NewHistogramVec(prometheus.HistogramOpts{
		Name:    "godiscogs_request_latency",
		Help:    "The number of server requests",
		Buckets: []float64{5, 10, 25, 50, 100, 250, 500, 1000, 2000, 4000, 8000, 16000, 32000, 64000, 128000, 256000, 1024000},
	}, []string{"method", "path1"})
)

Functions

func GetHTTPGetCount

func GetHTTPGetCount() int

GetHTTPGetCount The number of http gets performed

func GetMainLabel

func GetMainLabel(labels []*pb.Label) *pb.Label

GetMainLabel gets the main label from the release - this is the label to be used in e.g. sorting

func GetReleaseArtist

func GetReleaseArtist(rel *pb.Release) string

GetReleaseArtist Gets a string of the release artist of this record

Types

type AddToFolderResponse

type AddToFolderResponse struct {
	InstanceID  int `json:"instance_id"`
	ResourceURL string
	Simple      int
}

AddToFolderResponse the response back from an add request

type BasicRelease

type BasicRelease struct {
	ID int
}

BasicRelease is the release returned from the inventory pull

type ByLabelCat

type ByLabelCat []*pb.Release

ByLabelCat is a sorting function that sorts by label name, then catalogue number

func (ByLabelCat) Len

func (a ByLabelCat) Len() int

func (ByLabelCat) Less

func (a ByLabelCat) Less(i, j int) bool

func (ByLabelCat) Swap

func (a ByLabelCat) Swap(i, j int)

type CollectionRelease

type CollectionRelease struct {
	ID         int `json:"id"`
	FolderID   int `json:"folder_id"`
	InstanceID int `json:"instance_id"`
	Rating     int `json:"rating"`
	Notes      []*pb.Note
}

CollectionRelease returned from collection pull

type CollectionResponse

type CollectionResponse struct {
	Pagination Pagination
	Releases   []*CollectionRelease
}

CollectionResponse returned from discogs

type DiscogsRetriever

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

DiscogsRetriever Main retriever type

func NewDiscogsRetriever

func NewDiscogsRetriever(token string, logger func(context.Context, string)) *DiscogsRetriever

NewDiscogsRetriever Build a production retriever

func (*DiscogsRetriever) AddToFolder

func (r *DiscogsRetriever) AddToFolder(ctx context.Context, folderID int32, releaseID int32) (int, error)

AddToFolder adds the release to the given folder

func (*DiscogsRetriever) AddToWantlist

func (r *DiscogsRetriever) AddToWantlist(ctx context.Context, releaseID int) error

AddToWantlist adds a record to the wantlist

func (*DiscogsRetriever) DeleteInstance

func (r *DiscogsRetriever) DeleteInstance(ctx context.Context, folderID int, releaseID int, instanceID int) error

DeleteInstance removes a record from the collection

func (*DiscogsRetriever) ExpireSale

func (r *DiscogsRetriever) ExpireSale(ctx context.Context, saleID int, releaseID int, price float32) error

ExpireSale removes the listing from sale

func (*DiscogsRetriever) GetCollection

func (r *DiscogsRetriever) GetCollection(ctx context.Context) []*pb.Release

GetCollection gets all the releases in the users collection

func (*DiscogsRetriever) GetCurrentSalePrice

func (r *DiscogsRetriever) GetCurrentSalePrice(ctx context.Context, saleID int64) float32

GetCurrentSalePrice gets the current sale price

func (*DiscogsRetriever) GetCurrentSaleState

func (r *DiscogsRetriever) GetCurrentSaleState(ctx context.Context, saleID int64) (pb.SaleState, error)

GetCurrentSaleState gets the current sale state

func (*DiscogsRetriever) GetFolders

func (r *DiscogsRetriever) GetFolders(ctx context.Context) []pb.Folder

GetFolders gets all the folders for a given user

func (*DiscogsRetriever) GetInstanceID

func (r *DiscogsRetriever) GetInstanceID(ctx context.Context, releaseID int) int32

GetInstanceID Gets the instance ID for this release

func (*DiscogsRetriever) GetInstanceInfo

func (r *DiscogsRetriever) GetInstanceInfo(ctx context.Context, rid int32) (map[int32]*InstanceInfo, error)

GetInstanceInfo gets the info for an instance

func (*DiscogsRetriever) GetInventory

func (r *DiscogsRetriever) GetInventory(ctx context.Context) ([]*pb.ForSale, error)

GetInventory gets all the releases that are for sale

func (*DiscogsRetriever) GetOrder

func (r *DiscogsRetriever) GetOrder(ctx context.Context, order string) (map[int64]int32, time.Time, error)

GetCurrentSalePrice gets the current sale price

func (*DiscogsRetriever) GetRateLimit

func (r *DiscogsRetriever) GetRateLimit(ctx context.Context) int

GetRateLimit returns the rate limit

func (*DiscogsRetriever) GetRelease

func (r *DiscogsRetriever) GetRelease(ctx context.Context, id int32) (*pb.Release, error)

GetRelease returns a release from the discogs system

func (*DiscogsRetriever) GetSalePrice

func (r *DiscogsRetriever) GetSalePrice(ctx context.Context, releaseID int) (float32, error)

GetSalePrice gets the sale price for a release

func (*DiscogsRetriever) GetStats

func (r *DiscogsRetriever) GetStats(ctx context.Context, rid int32) (*Stats, error)

func (*DiscogsRetriever) GetWantlist

func (r *DiscogsRetriever) GetWantlist(ctx context.Context) ([]*pb.Release, error)

GetWantlist returns the wantlist for the given user

func (*DiscogsRetriever) Log

func (r *DiscogsRetriever) Log(ctx context.Context, text string)

Log out a value to the log function

func (*DiscogsRetriever) MoveToFolder

func (r *DiscogsRetriever) MoveToFolder(ctx context.Context, folderID int, releaseID int, instanceID int, newFolderID int) (string, error)

MoveToFolder Moves the given release to the new folder

func (*DiscogsRetriever) RemoveFromSale

func (r *DiscogsRetriever) RemoveFromSale(ctx context.Context, saleID int, releaseID int) error

RemoveFromSale removes the listing from sale

func (*DiscogsRetriever) RemoveFromWantlist

func (r *DiscogsRetriever) RemoveFromWantlist(ctx context.Context, releaseID int) error

RemoveFromWantlist adds a record to the wantlist

func (*DiscogsRetriever) SellRecord

func (r *DiscogsRetriever) SellRecord(ctx context.Context, releaseID int, price float32, state string, condition, sleeve string, weight int) (int64, error)

SellRecord sells a given release

func (*DiscogsRetriever) SetNotes

func (r *DiscogsRetriever) SetNotes(iid, fid, id int32, value string) error

func (*DiscogsRetriever) SetRating

func (r *DiscogsRetriever) SetRating(ctx context.Context, releaseID int, rating int) error

SetRating sets the rating on the specified releases

func (*DiscogsRetriever) UpdateSalePrice

func (r *DiscogsRetriever) UpdateSalePrice(ctx context.Context, saleID int, releaseID int, condition, sleeve string, price float32) error

UpdateSalePrice updates the sale price

type FoldersResponse

type FoldersResponse struct {
	Pagination Pagination
	Folders    []pb.Folder
}

FoldersResponse returned from discogs

type InstanceInfo

type InstanceInfo struct {
	DateAdded       int64
	RecordCondition string
	SleeveCondition string
	LastCleanDate   string
	Width           string
	Weight          string
	Sleeve          string
	Keep            string
}

InstanceInfo some basic details about the instance

type InventoryEntry

type InventoryEntry struct {
	Price   Pricing
	ID      int64 `json:"id"`
	Release BasicRelease
	Posted  string `json:"posted"`
}

InventoryEntry returned from invetory pull

type InventoryResponse

type InventoryResponse struct {
	Pagination Pagination
	Listings   []*InventoryEntry
}

InventoryResponse returned from discogs

type Item

type Item struct {
	ID    int64
	Price Pricing
}

type OrderResponse

type OrderResponse struct {
	Status   string
	Created  string
	Items    []Item
	Archived bool
}

type Pagination

type Pagination struct {
	Pages int
	Page  int
	Urls  Urls
}

Pagination the pagination structure

type PriceResponse

type PriceResponse struct {
	Price  Pricing
	Status string
}

PriceResponse response from get sale details

type Pricing

type Pricing struct {
	Currency string
	Value    float32
}

Pricing the single price

type ReleaseBack

type ReleaseBack struct {
	DateAdded  string     `json:"date_added"`
	InstanceID int32      `json:"instance_id"`
	Notes      []*pb.Note `json:"notes"`
}

ReleaseBack what we get for a single release

type ReleaseResponse

type ReleaseResponse struct {
	Pagination Pagination
	Releases   []ReleaseBack
}

ReleaseResponse what we get back from release

type SellResponse

type SellResponse struct {
	ListingID int64 `json:"listing_id"`
}

SellResponse response from selling a record

type Stats

type Stats struct {
	NumHave int32 `json:"num_have"`
	NumWant int32 `json:"num_want"`
}

type Urls

type Urls struct {
	Next string
}

Urls list of urls in pagination

type Version

type Version struct {
	Released     string
	Format       string
	MajorFormats []string `json:"major_formats"`
	ID           int32
}

Version a version of a master release

type VersionsResponse

type VersionsResponse struct {
	Pagination Pagination
	Versions   []Version
}

VersionsResponse returned from discogs

type WantlistResponse

type WantlistResponse struct {
	Pagination Pagination
	Wants      []*pb.Release
}

WantlistResponse returned from discogs

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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