internal

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2023 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package internal defines internal types and functions for online sources.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetArtistMBIDFromURL added in v0.1.6

func GetArtistMBIDFromURL(ctx context.Context, db *mbdb.DB, url, name string) string

GetArtistMBIDFromURL attempts to find the MBID of the artist corresponding to url. name should contain the artist name as seen online.

func GetLabelMBIDFromURL added in v0.1.6

func GetLabelMBIDFromURL(ctx context.Context, db *mbdb.DB, url, name string) string

GetLabelBIDFromURL attempts to find the MBID of the label corresponding to url. name should contain the label name as seen online.

Types

type Config

type Config struct {
	// ExtractTrackArtists indicates that artist names should be extracted from the
	// beginnings of track names, e.g. "Artist - Title". This is currently only used
	// for Bandcamp pages.
	ExtractTrackArtists bool
	// CountryCode contains the ISO 3166 code of the country that should be used when requesting
	// album data, e.g. "US" or "DE". This is currently only used for the Tidal API.
	CountryCode string
	// DisallowNetwork indicates that network requests should not be made.
	// This can be set by tests.
	DisallowNetwork bool
}

Config is passed to Provider implementations to configure their behavior.

type Provider

type Provider interface {
	// CleanURL returns a normalized version of the supplied URL.
	// An error is returned if the URL doesn't match a supported format for the provider.
	CleanURL(orig string) (string, error)
	// NeedsPage returns true if Release needs the page to be fetched and passed to it.
	// Providers should return false if they use some other API to get data.
	NeedsPage() bool
	// Release extracts release information from the supplied page.
	// If NeedsPage returns false, then the supplied page will be nil.
	// The img return value is nil if a cover image is not found.
	Release(ctx context.Context, page *web.Page, url string, db *mbdb.DB, cfg *Config) (
		rel *seed.Release, img *seed.Info, err error)
	// ExampleURL returns an example URL that can be displayed to the user.
	ExampleURL() string
}

Provider gets information from an online music provider.

Jump to

Keyboard shortcuts

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