Skip to main content

Spotimeta - Spotify metadata search and lookup

Introduction

Spotimeta is a simple library for getting data from Spotify’s metadata API. Available functions is searching for artists, albums and tracks, as well as looking up the same based on Spotify URIs. The data is returned as simple python dictionaries.

NOTE:

This product uses a SPOTIFY API but is not endorsed, certified or otherwise approved in any way by Spotify. Spotify is the registered trade mark of the Spotify Group.

For more information about the metadata API, see

http://developer.spotify.com/en/metadata-api/overview/

Examples

>>> import spotimeta

Search for a track

>>> search = spotimeta.search_track("Trip back to childhood")
>>> search["total_results"]
1

Print the artist of that track

>>> artist = search["result"][0]["artist"]
>>> artist["name"]
u'St-Petersburg Ska-Jazz Review'

Look up more information about that artist:

>>> lookup = spotimeta.lookup(artist["href"], detail=1)
>>> for album in lookup["result"]["albums"]:
...     album["name"]
u'Too Good To Be True'
u'Too Good To Be True'
u'Live At The Red Club'

It’s also possible to look up metadata using spotify URLs:

>>> track = spotimeta.lookup("http://open.spotify.com/track/3Z8cX6y0SeJIsI3yxoaQ8K")
>>> print track["result"]["artist"]["name"], "-", track["result"]["name"]
Kings Of Leon - Closer

For anything but the simples use-cases one should use caching. Caching is enabled by making a Metadata instance and passing it something that is a mapping type. For instance a dictionary:

>>> metacache = {}
>>> metadata = spotimeta.Metadata(cache=metacache)

The metadata instance has exactly the same methods as the module itself. Caching happens automatically as long as there is a cache object set.

>>> data = metadata.lookup("spotify:track:3kofFW93aMr28qx1BKps7A")
>>> data = metadata.lookup("spotify:track:3kofFW93aMr28qx1BKps7A")

This will only cause a single request. Data is cached for as long as the Expiry header on the first request says it should.

Todo

  • Sphinxify docs

  • Testcases for search, not just search parser

  • Deal with all the fixmes

Changelog

See the CHANGELOG file

Contact

The author is Rune Halvorsen <runefh@gmail.com>. The project resides at http://bitbucket.org/runeh/spotimeta . If you find bugs, or have feature requests, please report them in the project site issue tracker. Patches very welcome.

Also, see AUTHORS file for full list of contributors

License

This software is licensed under the New BSD License. See the LICENCE file in the top distribution directory for the full license text.

Release files for spotimeta 0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for spotimeta 0.2
File Size Uploaded
spotimeta-0.2.tar.gz 8.1 kB Details

Release files / spotimeta-0.2.tar.gz

Download URL spotimeta-0.2.tar.gz
Size 8.1 kB
Tags Source
SHA-256 checksum
How to use checksums
a6f698848119c24a61fa4bd154446ffff2f49b6830d39b92f728607c5950a9a7
BLAKE2b-256 checksum
How to use checksums
7ef42c2444207bc84d3812adf968d77b3201bbdb65e1d0d721f8ec76a0f48d4a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.2 This release

1 release file

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page