Documentation ¶
Overview ¶
Package internal defines internal types and functions for online sources.
Index ¶
- func AppendImageEdit(edits []seed.Edit, imgURL, relURL string) ([]seed.Edit, error)
- func FetchPage(ctx context.Context, url string, cfg *Config) (*web.Page, error)
- func GetArtistMBIDFromURL(ctx context.Context, db *mbdb.DB, url, name string) string
- func GetLabelMBIDFromURL(ctx context.Context, db *mbdb.DB, url, name string) string
- func HostnameHasDomain(hostname, domain string) bool
- func MakeEditNote(url string) string
- func MakeImageEditNote(imgURL, relURL string) string
- func ResolveHostname(ctx context.Context, hostname string, cfg *Config) ([]string, error)
- func RewriteReleaseTitle(title string, cfg *Config) string
- func RewriteTrackTitle(title string, cfg *Config) string
- type BadURLError
- type Config
- type Provider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendImageEdit ¶ added in v0.1.8
AppendImageEdit appends an informational edit with the supplied cover image URL to edits and returns the updated slice. If edits contains a *seed.Release, it may be updated to redirect to the add-cover-art page.
func FetchPage ¶ added in v0.1.8
FetchPage fetches and parses the supplied URL. If cfg.DisallowNetwork is true, it attempts to load the page from a file in a testdata directory instead, with "https://www.example.org/foo/bar" mapped to "testdata/www.example.org_foo_bar.html".
func GetArtistMBIDFromURL ¶
GetArtistMBIDFromURL attempts to find the MBID of the artist corresponding to url. name should contain the artist name as seen online.
func GetLabelMBIDFromURL ¶
GetLabelMBIDFromURL attempts to find the MBID of the label corresponding to url. name should contain the label name as seen online.
func HostnameHasDomain ¶ added in v0.1.8
HostnameHasDomain returns true if hostname is within domain. Provider implementations can use this in SupportsHostname.
func MakeEditNote ¶ added in v0.1.8
MakeEditNote returns an edit note consisting of the supplied URL and a common suffix.
func MakeImageEditNote ¶ added in v0.1.9
MakeImageEditNote returns an edit note describing an image extracted from a release page.
func ResolveHostname ¶ added in v0.1.8
ResolveHostname resolves the supplied hostname to one or more IP addresses.
func RewriteReleaseTitle ¶ added in v0.1.8
RewriteReleaseTitle rewrites the supplied release title as requested by cfg.
func RewriteTrackTitle ¶ added in v0.1.8
RewriteTrackTitle rewrites the supplied track title as requested by cfg. TODO: Should this function take a seed.Track and also extract artists if ExtractTrackArtists is set? I've only seen that be needed for Bandcamp albums so far.
Types ¶
type BadURLError ¶ added in v0.1.8
type BadURLError struct {
// contains filtered or unexported fields
}
BadURLError is returned by MakeEdits to indicate that the supplied URL is unsupported.
func NewBadURLError ¶ added in v0.1.8
func NewBadURLError(err error) *BadURLError
func (*BadURLError) Error ¶ added in v0.1.8
func (e *BadURLError) Error() string
type Config ¶
type Config struct { // 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 // CorrectPunctuation indicates that punctuation in track titles should be replaced with // preferred characters (https://wiki.musicbrainz.org/User:Jacobbrett/English_Punctuation_Guide). CorrectPunctuation bool // 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 // RemoveParens indicates that parenthetical expressions should be removed from the ends // of track titles, e.g. "Title (Deluxe Edition)". RemoveParens bool // SplitArtists indicates that artist names should be automatically split on separators like // " & " and " feat. ". This is currently only used for Bandcamp pages. SplitArtists bool // DisallowNetwork indicates that network requests should not be made. // This can be set by tests. DisallowNetwork bool // TestdataDir overrides FetchPage's default directory of "testdata" for page // data when DisallowNetwork is true. TestdataDir string // HostnameAddrs provides answers for ResolveHostname to return if DisallowNetwork is true. HostnameAddrs map[string][]string }
Config is passed to Provider implementations to configure their behavior.
type Provider ¶
type Provider interface { // SupportsHostname returns true if the supplied hostname (e.g. "www.bandcamp.com") // can be handled by this provider. Callers are responsible for lowercasing the // hostname and removing ":port" suffixes. SupportsHostname(ctx context.Context, hostname string, cfg *Config) bool // MakeEdits generates one or more seeded edits based on a user-supplied URL. MakeEdits(ctx context.Context, url string, db *mbdb.DB, cfg *Config) ([]seed.Edit, error) // ExampleURL returns an example URL that can be displayed to the user. ExampleURL() string }
Provider gets information from an online music provider.