2 This module contains tha base classes for the Musixmatch API generated content: 4 * :py:class:`musixmatch.artist.Artist` 5 * :py:class:`musixmatch.artist.Album` 6 * :py:class:`musixmatch.track.Track` 7 * :py:class:`musixmatch.lyrics.Lyrics` 8 * :py:class:`musixmatch.subtitle.Subtitle` 11 __license__ = musixmatch.__license__
12 __author__ = musixmatch.__author__
14 from musixmatch
import api
19 The very base (abstract) class of the musixmatch package. I want all 20 classes to implement :py:meth:`__str__` and :py:meth:`__repr__`. 22 Casting an :py:class:`Base` into a :py:class:`str` returns a pretty printed 23 (maybe using :py:mod:`pprint`) string representing the object. 25 Using :py:func:`repr` on an :py:class:`Base` returns an evaluable string 26 representing the instance, whenever it is reasonable. 28 :py:class:`Base` instances are hashable. 34 Returns the label that should be used as keyword in the 35 :py:class:`musixmatch.api.JsonResponseMessage` body. 37 return getattr(cls,
'__label__', cls.__name__.lower())
42 Returns the :py:class:`musixmatch.api.Method` that should be used to 43 build the object. Defaults to *label.get* where *label* is the result 46 api_method = getattr(cls,
'__api_method__',
'%s.%s' % (cls.
label(),
'get'))
52 raise NotImplementedError
55 raise NotImplementedError
59 This is the base class for any entity in musixmatch package. Even if 60 response messages may have XML format, the JSON representation will be the 61 main data format, so the :py:class:`dict` sounds like the best base class. 62 It fetches the item data by guessing the :py:class:`musixmatch.api.Method` 63 and building the query based on a given keyword argument. Positional 64 argument is meant to be used by collection classes. Use only keyword 69 def __init__(self, dictionary=None, **keywords):
71 dict.update(self, dictionary)
77 return pprint.pformat(dict(self),4,1)
80 return '%s(%r)' % (type(self).__name__, dict(self))
83 return int(self[
'%s_id' % self.
label()])
88 Returns an object instance, built from a 89 :py:class:`musixmatch.api.ResponseMessage` 91 if not message.status_code:
98 Returns an object instance, built from a :py:class:`dict` 101 dict.update(item, dictionary, **keywords)
106 This is the base class for collections of items, like search results, or 107 charts. It behaves like :py:class:`list`, but enforce new items to be 108 instance of appropriate class checking against :py:meth:`allowedin`. 117 items = [ repr(i)
for i
in self ]
118 return '%s(%s)' % (type(self).__name__,
', '.join(items))
121 return list.__str__(self)
124 collection = self.
copy()
125 collection.extend(iterable)
129 raise NotImplementedError
132 raise NotImplementedError
135 raise NotImplementedError
138 raise NotImplementedError
141 raise NotImplementedError
148 return list.__getitem__(self, i)
149 elif type(i)
is slice:
150 collection = type(self)()
151 list.extend(collection, list.__getitem__(self, i))
160 for item
in iterable:
164 return int(item
in self)
167 """Returns a shallow copy of the collection.""" 168 collection = type(self)()
169 list.extend(collection, self)
173 return list.index(self, item, *indices[:2])
177 if not isinstance(item, allowed):
178 item = allowed.fromDictionary(item)
180 list.insert(self, key, item)
184 Returns self, paged by **page_size**. That is, a list of 185 sub-collections which contain "at most" **page_size** items. 187 return [ self.
page(i,page_size)
190 def page(self, page_index, page_size=3):
192 Returns a specific page, considering pages that contain "at most" 196 i = page_index * page_size
197 list.extend(page, self[i:i+page_size])
202 A generator of pages, considering pages that contain "at most" 205 for i
in xrange(self.
pages(page_size)):
206 yield self.
page(i, page_size)
210 Returns the number of pages, considering pages that contain "at most" 213 pages, more = divmod(
len(self), page_size)
214 return more
and pages + 1
or pages
219 Returns an object instance, built on a 220 :py:class:`musixmatch.api.ResponseMessage` 222 if not message.status_code:
223 raise api.Error(str(message.status_code))
224 list_label = cls.
label()
226 items = [ i[item_label]
for i
in message[
'body'][list_label] ]
232 Returns the allowed content class. Defaults to :py:class:`Item` 239 return '%s_list' % item_name
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFilterBuffer structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining list
def fromResponseMessage(cls, message)
def fromResponseMessage(cls, message)
def __add__(self, iterable)
def paged(self, page_size=3)
def fromDictionary(cls, dictionary, keywords)
def __init__(self, dictionary=None, keywords)
def pages(self, page_size=3)
def extend(self, iterable)
def pager(self, page_size=3)
def index(self, item, indices)
def __iadd__(self, iterable)
def __setitem__(self, key, item)
def insert(self, key, item)
def page(self, page_index, page_size=3)
def __setslice__(self, indices)
def __init__(self, items)
def __getslice__(self, i=0, j=-1)