2 This module contains higher level classes to query Musixmatch API and build 3 simple dictionary-like objects representing a Track or a TracksCollection. 5 >>> from musixmatch.track import Track, TracksCollection 6 >>> import musixmatch.api 9 ... track = Track(track_mbid=8976) 10 ... collection = TracksCollection.fromChart(country='us', page=1) 11 ... except musixmatch.api.Error, e: 15 __license__ = musixmatch.__license__
16 __author__ = musixmatch.__author__
18 from musixmatch
import api, lyrics, subtitle
26 This class builds a :py:class:`dict` like object representing a track. It 27 can get track information through the :py:class:`musixmatch.api.Method` 28 **track.get** or from an already well-formed :py:class:`dict`. Create a 29 Track object based on a given keyword argument: 31 :param track_id: musiXmatch track ID 32 :param musicbrainz_id: Musicbrainz track ID 33 :param track_echonest_id: Echonest track ID 34 :param track_data: an already well-formed :py:class:`dict` of track data 35 :raises: :py:exc:`musixmatch.api.Error` if :py:class:`musixmatch.api.ResponseStatusCode` is not 200 37 Once information are collected, the following keys are available: 39 :keyword track_id: musiXmatch track ID 40 :keyword track_mbid: Musicbrainz track ID 41 :keyword lyrics_id: musiXmatch lyrics ID 42 :keyword instrumental: wether the track is instrumental or not 43 :keyword subtitle_id: musiXmatch subtitle ID 44 :keyword track_name: track name 45 :keyword album_coverart_100x100: album cover URL 46 :keyword artist_id: musiXmatch artist ID 47 :keyword artist_mbid: Musicbrainz artist ID 48 :keyword artist_name: artist name 50 Keyword access have been overloaded thanks to the :py:meth:`get` method 51 which will eventually fetch the matching lyrics or subtitle. 53 __api_method__ = track.get
58 Returns a :py:class:`Track` based on the result of the 59 :py:class:`musiXmatch.api.Method` **matcher.track.get**. Accepts the 62 :param q_track: words to be searched among track titles 63 :param q_artist: words to be searched among artist names 67 def get(self, key, default=_marker):
69 If key is *lyrics* or *subtitle* try to query api for proper value, 70 and build an :py:class:`musixmatch.lyrics.Lyrics` or 71 :py:class:`musixmatch.subtitle.Subtitle`. Access to the above mentioned 72 keys may fail with :py:exc:`musixmatch.api.Error`. Once fetched, the 79 if key
in special
and not key
in self:
80 self[key] = special[key](track_id=self[
'track_id'])
81 value = dict.get(self, key, default)
91 Post feedback about lyrics for this track. **feedback** can be one of: 93 :keyword wrong_attribution: the lyrics shown are not by the artist that 95 :keyword bad_characters: there are strange characters and/or words 96 that are partially scrambled. 97 :keyword lines_too_long: the text for each verse is too long! 98 :keyword wrong_verses: there are some verses missing from the 99 beginning or at the end. 100 :keyword wrong_formatting: the text looks horrible, please fix it! 103 'wrong_attribution',
'bad_characters',
'lines_too_long',
104 'wrong_verses',
'wrong_formatting' ]
105 if feedback
in accepted:
106 message = track.lyrics.feedback.post(
107 track_id=self[
'track_id'],
108 lyrics_id=self[
'track_id'][
'lyrics'][
'lyrics_id'],
111 if not message.status_code:
112 raise api.Error(str(message.status_code))
114 raise TypeError,
'%r not in %r' % (feedback, accepted)
118 This class build a :py:class:`list` like object representing a tracks 119 collection. It accepts :py:class:`dict` or :py:class:`Track` objects. 121 __allowedin__ = Track
126 This classmethod builds an :py:class:`TracksCollection` from a 127 **album.tracks.get** :py:class:`musixmatch.api.Method` call. 129 :param album_id: musiXmatch album ID 136 This classmethod builds an :py:class:`TracksCollection` from a 137 **track.search** :py:class:`musixmatch.api.Method` call. 139 :param q: a string that will be searched in every data field 140 (q_track, q_artist, q_lyrics) 141 :param q_track: words to be searched among track titles 142 :param q_artist: words to be searched among artist names 143 :param q_track_artist: words to be searched among track titles or 145 :param q_lyrics: words to be searched into the lyrics 146 :param page: requested page of results 147 :param page_size: desired number of items per result page 148 :param f_has_lyrics: exclude tracks without an available lyrics 149 (automatic if q_lyrics is set) 150 :param f_artist_id: filter the results by the artist_id 151 :param f_artist_mbid: filter the results by the artist_mbid 152 :param quorum_factor: only works together with q and q_track_artist 153 parameter. Possible values goes from 0.1 to 154 0.9. A value of 0.9 means: 'match at least 90 155 percent of the words'. 162 This classmethod builds an :py:class:`TracksCollection` from a 163 **track.chart.get** :py:class:`musixmatch.api.Method` call. 165 :param page: requested page of results 166 :param page_size: desired number of items per result page 167 :param country: the country code of the desired country chart 168 :param f_has_lyrics: exclude tracks without an available lyrics 169 (automatic if q_lyrics is set) def postFeedback(self, feedback)
def fromChart(cls, keywords)
def fromResponseMessage(cls, message)
def fromResponseMessage(cls, message)
def fromAlbum(cls, keywords)
def __getitem__(self, key)
def get(self, key, default=_marker)
def fromMatcher(cls, keywords)
def fromSearch(cls, keywords)