Functions

date_time_from_iso8601 (date)

deinit ()

g_value_dup (value)

g_value_free (value)

g_value_hashtable_new ()

g_value_hashtable_new_direct ()

g_value_new (g_type)

init (argv)

init_get_option_group ()

log_configure (config)

metadata_key_get_desc (key)

metadata_key_get_name (key)

metadata_key_get_type (key)

multiple_get_media_from_uri (uri, keys, options, callback, *user_data)

multiple_search (sources, text, keys, options, callback, *user_data)

multiple_search_sync (sources, text, keys, options)

operation_cancel (operation_id)

operation_get_data (operation_id)

operation_set_data (operation_id, user_data)

operation_set_data_full (operation_id, user_data, destroy_func)

paging_translate (skip, count, max_page_size, page_size, page_number, internal_offset)

range_value_hashtable_insert (hash_table, key, min, max)

range_value_hashtable_new ()

Details

Grl.date_time_from_iso8601(date)
Parameters:

date (str) – a date expressed in iso8601 format

Returns:

a newly-allocated GLib.DateTime set to the time corresponding to date, or None if date could not be parsed properly.

Return type:

GLib.DateTime

New in version 0.2.0.

Grl.deinit()

Deinitializes the Grilo library.

Call this function after finalizing using Grilo, in order to free and clean up all the resources created.

New in version 0.2.8.

Grl.g_value_dup(value)
Parameters:

value (GObject.Value) – the GObject.Value to copy

Returns:

a duplicated GObject.Value

Return type:

GObject.Value

Grl.g_value_free(value)
Parameters:

value (GObject.Value) –

Grl.g_value_hashtable_new()
Returns:

a new hash table made to contain GValues.

Return type:

{str: GObject.Value}

Grl.g_value_hashtable_new_direct()
Returns:

a new hash table made to contain GValues.

Return type:

{object: GObject.Value}

Grl.g_value_new(g_type)
Parameters:

g_type (GObject.GType) –

Return type:

GObject.Value

Grl.init(argv)
Parameters:

argv ([str] or None) – list of arguments

Returns:

list of arguments

Return type:

argv: [str]

Initializes the Grilo library

New in version 0.1.6.

Grl.init_get_option_group()
Returns:

a pointer to Grilo’s option group. Should be dereferenced after use.

Return type:

GLib.OptionGroup

Returns a GLib.OptionGroup with Grilo’s argument specifications.

This function is useful if you want to integrate Grilo with other libraries that use the GOption commandline parser (see GLib.OptionContext.add_group() ).

New in version 0.1.6.

Grl.log_configure(config)
Parameters:

config (str) – A string describing the wanted log configuration

Configure a set of log domains. The default configuration is to display warning and error messages only for all the log domains.

The configuration string follows the following grammar:

config-list: config | config ',' config-list
config: domain ':' level
domain: '*' | [a-zA-Z0-9]+
level: '*' | '-' | named-level | num-level
named-level: "none" | "error" | "warning" | "message" | "info" | "debug"
num-level: [0-5]

examples:

  • “*:*”: maximum verbosity for all the log domains

  • “*:-”: don’t print any message

  • “media-source:debug,metadata-source:debug”: prints debug, info, message warning and error messages for the media-source and metadata-source log domains

It’s possible to override the log configuration at runtime by defining the GRL_DEBUG environment variable to a configuration string as described above

New in version 0.1.7.

Grl.metadata_key_get_desc(key)
Parameters:

key (int) – key to look up

Returns:

the description of the key

Return type:

str

Retrieves the description associated with the key

New in version 0.1.6.

Grl.metadata_key_get_name(key)
Parameters:

key (int) – key to look up

Returns:

The name of the key

Return type:

str

Retrieves the name associated with the key

New in version 0.1.6.

Grl.metadata_key_get_type(key)
Parameters:

key (int) – key to look up

Returns:

the expected value type

Return type:

GObject.GType

Retrieves the expected type for values associated with this key

New in version 0.2.0.

Grl.multiple_get_media_from_uri(uri, keys, options, callback, *user_data)
Parameters:
  • uri (str) – A URI that can be used to identify a media resource

  • keys ([int]) – List of metadata keys we want to obtain.

  • options (Grl.OperationOptions) – options wanted for that operation

  • callback (Grl.SourceResolveCb) – the user defined callback

  • user_data (object or None) – the user data to pass to the user callback

Goes though all available media sources until it finds one capable of constructing a Grl.Media object representing the media resource exposed by uri.

This method is asynchronous.

New in version 0.2.0.

Parameters:
Returns:

the operation identifier

Return type:

int

Search for text in all the sources specified in sources.

If text is None then None-text searchs will be used for each searchable plugin (see Grl.Source.search for more details).

This method is asynchronous.

New in version 0.2.0.

Grl.multiple_search_sync(sources, text, keys, options)
Parameters:
Raises:

GLib.Error

Returns:

a list with Grl.Media elements

Return type:

[Grl.Media]

Search for text in all the sources specified in sources.

This method is synchronous.

New in version 0.2.0.

Grl.operation_cancel(operation_id)
Parameters:

operation_id (int) – the identifier of a running operation

Cancel an operation.

Grl.operation_get_data(operation_id)
Parameters:

operation_id (int) – the identifier of a running operation

Returns:

The previously attached data.

Return type:

object or None

Obtains the previously attached data

Grl.operation_set_data(operation_id, user_data)
Parameters:
  • operation_id (int) – the identifier of a running operation

  • user_data (object or None) – the data to attach

Attach a pointer to the specific operation.

Grl.operation_set_data_full(operation_id, user_data, destroy_func)
Parameters:
  • operation_id (int) – the identifier of a running operation

  • user_data (object or None) – the data to attach

  • destroy_func (GLib.DestroyNotify or None) – function to release user_data when the operation terminates

Attach a pointer to the specific operation.

Note that the destroy_func callback is not called if user_data is None.

New in version 0.2.7.

Grl.paging_translate(skip, count, max_page_size, page_size, page_number, internal_offset)
Parameters:
  • skip (int) – number of elements to skip

  • count (int) – number of elements to retrieve

  • max_page_size (int) – maximum value for page size (0 for unlimited size)

  • page_size (int) – optimal page size

  • page_number (int) – page which contain the first element to retrieve (starting at 1)

  • internal_offset (int) – in the page_number, offset where first element can be found (starting at 0)

Grilo browsing implements a paging mechanism through skip and count values.

But there are some services (like Jamendo or Flickr) where paging is done through a page number and page size: user request all elements in a page, specifying in most cases what is the page size.

This function is a helper for this task, computing from skip and count what is the optimal value of page size (limited by max_page_size), which page should the user request, and where requested data start inside the page.

By optimal we mean that it computes those values so only one page is required to satisfy the data, using the smallest page size. If user is limiting page size, then more requests to services might be needed. But still page size will be an optimal value.

If page_size is None, then page size will be max_page_size. If the later is also 0, then page size will be GObject.G_MAXUINT.

New in version 0.1.6.

Grl.range_value_hashtable_insert(hash_table, key, min, max)
Parameters:
Grl.range_value_hashtable_new()
Returns:

a GLib.HashTable

Return type:

{object: Grl.RangeValue}