musixmatch-master/build/lib/musixmatch/album.py
Go to the documentation of this file.
1 """
2 This module contains higher level classes to query Musixmatch API and build
3 simple dictionary-like objects representing an Album or an AlbumsCollection.
4 
5 >>> from musixmatch.album import Album, AlbumsCollection
6 >>> import musixmatch.api
7 >>>
8 >>> try:
9 ... album = Album(album_id=292)
10 ... collection = AlbumsCollection.fromArtist(country='it', page=1)
11 ... except musixmatch.api.Error, e:
12 ... pass
13 """
14 import musixmatch
15 __license__ = musixmatch.__license__
16 __author__ = musixmatch.__author__
17 
18 from musixmatch.base import Item, ItemsCollection
19 from musixmatch.ws import album, artist
20 
21 class Album(Item):
22  """
23  This class build a :py:class:`dict` like object representing an album. It
24  can get album information through the :py:class:`musixmatch.api.Method`
25  **album.get** or from an already well-formed :py:class:`dict`. Create an
26  Album object based on a given keyword argument:
27 
28  :param album_id: musiXmatch album ID
29  :param album_data: an already well-formed :py:class:`dict` of album data.
30 
31  Once information are collected, the following keys are available:
32 
33  :keyword album_id: musiXmatch album ID
34  :keyword album_name: album name
35  :keyword album_release_date: album release date
36  :keyword album_release_type: type of the album
37  :keyword album_coverart_100x100: coverart URL
38  :keyword artist_id: album artist musiXmatch ID
39  :keyword artist_name: album artist name
40  """
41  __api_method__ = album.get
42 
44  """
45  This class build a :py:class:`list` like object representing an albums
46  collection. It accepts :py:class:`dict` or :py:class:`Album` objects.
47  """
48  __allowedin__ = Album
49 
50  @classmethod
51  def fromArtist(cls, **keywords):
52  """
53  This classmethod builds an :py:class:`AlbumsCollection` from a
54  **artist.albums.get** :py:class:`musixmatch.api.Method` call.
55 
56  :param artist_id: album artist musiXmatch ID
57  :param g_album_name: group albums by name
58  :param s_release_date: sort albums by release date
59  :rtype: :py:class:`AlbumsCollection`
60  """
61  return cls.fromResponseMessage(artist.albums.get(**keywords))
62