itunes

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package itunes exposes the iTunes Search API as a kit Domain driver.

A multi-domain host (ant) enables it with a single blank import:

import _ "github.com/tamnd/itunes-cli/itunes"

The same Domain also builds the standalone itunes binary (see cli.NewApp).

Package itunes is the library behind the itunes command line: the HTTP client, request shaping, and the typed data models for the iTunes Search API (itunes.apple.com). No API key required.

Index

Constants

View Source
const Host = "itunes.apple.com"

Host is the API host this client talks to.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client talks to the iTunes API over HTTP.

func NewClient

func NewClient(cfg Config) *Client

NewClient returns a Client configured with cfg.

func (*Client) Lookup

func (c *Client) Lookup(ctx context.Context, id int64, entity string) ([]Result, error)

Lookup looks up an item by its Apple ID, optionally filtering by entity.

func (*Client) Search

func (c *Client) Search(ctx context.Context, term, entity, country string, limit int) ([]Result, error)

Search searches the iTunes catalog. entity is one of: song, album, musicArtist, movie, tvShow, podcast, software.

type Config

type Config struct {
	BaseURL   string
	UserAgent string
	Rate      time.Duration
	Timeout   time.Duration
	Retries   int
}

Config holds all tunable parameters for the Client.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a Config with sensible defaults.

type Domain

type Domain struct{}

Domain is the itunes driver.

func (Domain) Classify

func (Domain) Classify(input string) (uriType, id string, err error)

Classify turns an input into the canonical (type, id).

func (Domain) Info

func (Domain) Info() kit.DomainInfo

Info describes the scheme, the hostnames a pasted link is matched against, and the identity reused for the binary's help and version.

func (Domain) Locate

func (Domain) Locate(uriType, id string) (string, error)

Locate returns the live https URL for a (type, id).

func (Domain) Register

func (Domain) Register(app *kit.App)

Register installs the client factory and every operation onto app.

type Result

type Result struct {
	WrapperType    string  `json:"wrapperType"`
	Kind           string  `json:"kind,omitempty"`
	CollectionID   int64   `json:"collectionId,omitempty"`
	TrackID        int64   `json:"trackId,omitempty"`
	ArtistID       int64   `json:"artistId,omitempty"`
	ArtistName     string  `json:"artistName,omitempty"`
	CollectionName string  `json:"collectionName,omitempty"`
	TrackName      string  `json:"trackName,omitempty"`
	PreviewURL     string  `json:"previewUrl,omitempty"`
	ArtworkURL     string  `json:"artworkUrl100,omitempty"`
	Price          float64 `json:"trackPrice,omitempty"`
	Currency       string  `json:"currency,omitempty"`
	ReleaseDate    string  `json:"releaseDate,omitempty"`
	Genre          string  `json:"primaryGenreName,omitempty"`
	Country        string  `json:"country,omitempty"`
	TrackCount     int     `json:"trackCount,omitempty"`
	FeedURL        string  `json:"feedUrl,omitempty"`
}

Result is one item returned by the iTunes API.

Jump to

Keyboard shortcuts

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