Retrieved Items (aka ,,Caches’‘)

What is a Cache?

Basically every single bit of metadata returned from libglyr is a Cache. It is basically a result or it is sometimes referred to as an item. It encapsulates basic attributes like a bytearray of data, a checksum, an optional imageformat and some more.

What can I do with one?

Caches can be...

  • … committed to a local database (see next section)
  • … written to HD via it’s write() method.
  • … printed to stdout via print(), currently __repr__ is not implemented.

You can use the data property to get the actual metadata. This is always a bytestring, even with lyrics. You have to convert it to the desired encoding (e.g. utf-8) like this:

str(, 'utf-8')


This might throw an UnicodeError on non-utf8 input, or imagedata. Use the Query-Property force_utf8 to only retrieve valid utf-8 textitems.

The data property is settable. Setting will also cause the size and checksum to be adjusted.


Cache implements the __eq__ and __ne__ operator, which will compare only the data properties. This is meant to be a shortcut, since comparing data is usually the only thing you want to compare.


class plyr.Cache

A Cache is one result or item retrieved by libglyr

It encapsulates various properties like ,,data’‘, ,,checksum’’ or ,,image_format’’ and quite some more.

It can be instanciated directly, but there is no valid use to do so currently.


A 16 byte md5sum checksum in hexadecimal string-representation of the data field.

You usually should use update_checksum(), this is only if you already luckily have some correct checksum lying there by accident.


Actual data as bytestring. Also settable.


The type of data - this may differ from the get_type


Duration in seconds, only filled for “tracklist”, otherwise 0.


The format of the image, might be one of:

[png, jpeg, gif, tiff]

Did this item come from a local database?


A boolean. Set to true if this item contains image data.


Pretty print of the cache to stdout.

There is no __repr__ at the moment.


The name of the provider where this items was retrieved from.


The rating of this item, this is for you to set, libglyr will always set it to 0 by default. The only case where rating has a semantic meaning is for Database lookups:

If more than one item is requested, the items are returned sorted by the rating (highest rating first), and as second criteria by the timestamp, so the item with the highest rating, and the newest timestamp is always first.

This is useful to insert “dummies” to the db, in case some item was not found.


Size in bytes of data - this is not useful in Python, as you could do also:


This attribute is not settable, since you could screw things up.


The URL where this items was retrieved from.


If is_cached is True, a timestamp of the insertion, otherwise 0.


Update the checksum manually.

This should never be necessary in this wrapper though.


Write item content (data) to a valid path.

Path :Must be a valid path.

Table Of Contents

Previous topic

Building Queries

Next topic

Looking up Providers

This Page