Skip to main content

A simple Python interface to search the Apple Music and Apple TV libraries

Project description

pyapplemusicapi

A simple Python interface to search the Apple Music and Apple TV libraries by using the still-functional iTunes Store API. Formerly known as "pitunes".

How it Works

Rather than using the Apple Music API, which requires the developer to register for an Apple Developer Account and a MusicKit API key, this package takes advantage of the older iTunes Search API. This older API is still functional, and provides the same results as the newer one.

Installation

To install with pip, just run this in your terminal:

$ pip install pyapplemusicapi

Or clone the code from Github and:

$ python setup.py install

Caching

This module caches responses from the iTunes Search API to speed up repeated queries against the same resources. Note, however, that there's no persistent caching that happens between Python processes. i.e., once a Python process exits, the cache is cleared.

Examples

Search

import pyapplemusicapi

# Search band U2
artist = pyapplemusicapi.search_artist('u2')[0]
for album in artist.get_albums():
    for track in album.get_tracks():
        print(album.name, album.url, track.name, track.duration, track.preview_url)

# Search U2 videos
videos = pyapplemusicapi.search(query='u2', media='musicVideo')
for video in videos:
    print(video.name, video.preview_url, video.artwork)

# Search Volta album by Björk
album = pyapplemusicapi.search_album('Volta Björk')[0]

# Global Search 'Beatles'
items = pyapplemusicapi.search(query='beatles')
for item in items:
    print('[' + item.type + ']', item.artist, item.name, item.url, item.release_date)

# Search 'Angry Birds' game
item = pyapplemusicapi.search(query='angry birds', media='software')[0]
vars(item)

# Search 'Family Guy Season 1'
item = pyapplemusicapi.search_season('Family Guy Season 1')[0]
vars(item)

# Search 'Episode 5 of Family Guy Season 1'
items = pyapplemusicapi.search_episode('Family Guy Season 1')
for ep in items:
    if ep.episode_number == 5:
        vars(ep)

Lookup by Apple Music ID

import pyapplemusicapi

# Lookup Achtung Baby album by U2
U2_ACHTUNGBABY_ID = 475390461
album = pyapplemusicapi.lookup(U2_ACHTUNGBABY_ID)

print(album.url)
print(album.artwork)

artist = album.artist
tracks = album.get_tracks()

# Lookup song One from Achtung Baby album by U2
U2_ONE_ID = 475391315
track = pyapplemusicapi.lookup(U2_ONE_ID)

artist = track.artist
album = track.get_album()

Lookup by UPC

import pyapplemusicapi

# Lookup Arcade EP by glitch_d using UPC
ARCADE_EP_UPC = 5057917815772
album = pyapplemusicapi.lookup_upc(ARCADE_EP_UPC)

print(album.url)
print(album.artwork)

artist = album.artist
tracks = album.get_tracks()

Tests

$ py.test tests

References

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyapplemusicapi-2.0.0.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

pyapplemusicapi-2.0.0-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file pyapplemusicapi-2.0.0.tar.gz.

File metadata

  • Download URL: pyapplemusicapi-2.0.0.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for pyapplemusicapi-2.0.0.tar.gz
Algorithm Hash digest
SHA256 0a1cc1b225090dc736c3f5febb5e921ac4ddd218e6a39cb6dbe74e9d379483fb
MD5 628b843109558ce5f86090284fbdbcc4
BLAKE2b-256 5a94cab816cf7f057d2f5d26383e0e36f8a690681e8b55cc3b547e9c2795fc58

See more details on using hashes here.

File details

Details for the file pyapplemusicapi-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: pyapplemusicapi-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for pyapplemusicapi-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9b05254d673a18b2de8e25817ea77b7d57847bccdc8bb74257726ba5c068c331
MD5 f37b041e75e308d98413e01270507216
BLAKE2b-256 9a288664c2ae8a102cf9559c9236898a05792881ae00b7ae643547860676d091

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page