Grl.Source¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Properties¶
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w |
Threshold to use auto-split of queries |
||
r/w/c |
Plugin source belongs to |
||
r/w/c |
Source rank |
||
r/w/c |
A description of the source |
||
r/w/c |
Icon representing the source |
||
r/w/c |
The identifier of the source |
||
r/w/c |
The name of the source |
||
[ |
r/w/c |
String array of tags relevant this source |
|
r/w/c |
List of supported media types |
Signals¶
- Inherited:
Name |
Short Description |
---|---|
Signals that the content in the source has changed. |
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
parent |
r |
Class Details¶
- class Grl.Source(**kwargs)¶
- Bases:
- Abstract:
Yes
- Structure:
- browse(container, keys, options, callback, *user_data)¶
- Parameters:
container (
Grl.Media
orNone
) – a container of data transfer objectsoptions (
Grl.OperationOptions
) – options wanted for that operationcallback (
Grl.SourceResultCb
) – the user defined callbackuser_data (
object
orNone
) – the user data to pass in the callback
- Returns:
the operation identifier
- Return type:
Browse from media elements through an available list.
This method is asynchronous.
New in version 0.2.0.
- browse_sync(container, keys, options)¶
- Parameters:
container (
Grl.Media
orNone
) – a container of data transfer objectsoptions (
Grl.OperationOptions
) – options wanted for that operation
- Raises:
- Returns:
a
GLib.List
withGrl.Media
elements. After useGObject.Object.unref
() every element and g_list_free() the list.- Return type:
Browse media elements through an available list.
This method is synchronous.
New in version 0.2.0.
- get_auto_split_threshold()¶
- Returns:
the assigned threshold, or 0 if there is no threshold
- Return type:
Gets how much elements the source is able to handle in a single request.
See
Grl.Source.set_auto_split_threshold
()New in version 0.2.0.
- get_caps(operation)¶
- Parameters:
operation (
Grl.SupportedOps
) – a supported operation. Even though the type allows to specify several operations, only one should be provided here.- Returns:
The capabilities
- Return type:
Get the capabilities of self for operation.
New in version 0.2.0.
- get_media_from_uri(uri, keys, options, callback, *user_data)¶
- Parameters:
uri (
str
) – A URI that can be used to identify a media resourcekeys ([
int
]) – A list of keys to resolveoptions (
Grl.OperationOptions
) – options wanted for that operationcallback (
Grl.SourceResolveCb
) – the user defined callbackuser_data (
object
orNone
) – the user data to pass in the callback
- Returns:
the operation identifier
- Return type:
Creates an instance of
Grl.Media
representing the media resource exposed at uri.It is recommended to call
Grl.Source.test_media_from_uri
() before invoking this to check whether the target source can theoretically do the resolution.This method is asynchronous.
New in version 0.2.0.
- get_media_from_uri_sync(uri, keys, options)¶
- Parameters:
uri (
str
) – A URI that can be used to identify a media resourcekeys ([
int
]) – a list of keys to resolveoptions (
Grl.OperationOptions
) – options wanted for that operation
- Raises:
- Returns:
a filled
Grl.Media
- Return type:
Creates an instance of
Grl.Media
representing the media resource exposed at uri.It is recommended to call
Grl.Source.test_media_from_uri
() before invoking this to check whether the target source can theoretically do the resolution.This method is synchronous.
New in version 0.2.0.
- get_plugin()¶
- Returns:
the plugin this source belongs to
- Return type:
New in version 0.2.0.
- get_supported_media()¶
- Returns:
a
Grl.SupportedMedia
value- Return type:
Gets the supported type of medias self can deal with.
New in version 0.3.0.
- may_resolve(media, key_id, missing_keys)¶
- Parameters:
- Returns:
True
if there’s a possibility that self resolves key_id for media,False
otherwise.- Return type:
Checks whether key_id may be resolved with self for media, so that the caller can avoid calling
Grl.Source.resolve
() if it can be known in advance it will fail.If the resolution is known to be impossible because more keys are needed in media, and missing_keys is not
None
, it is populated with the list of GrlKeyID that would be needed.This function is synchronous and should not block.
New in version 0.2.0.
- notify_change(media, change_type, location_unknown)¶
- Parameters:
media (
Grl.Media
orNone
) – the media which has changed, orNone
to use the root container.change_type (
Grl.SourceChangeType
) – the type of changelocation_unknown (
bool
) – if change has happened in media or any descendant
Emits “content-changed” signal to notify subscribers that a change ocurred in self.
See
Grl.Source.notify_change_list
() function.This function is intended to be used only by plugins.
New in version 0.2.0.
- notify_change_list(changed_medias, change_type, location_unknown)¶
- Parameters:
changed_medias ([
Grl.Media
]) – the list of medias that have changedchange_type (
Grl.SourceChangeType
) – the type of changelocation_unknown (
bool
) – if change has happpened in media or any descendant
Emits “content-changed” signal to notify subscribers that a change ocurred in self.
The function will take ownership of changed medias and it should not be manipulated in any way by the caller after invoking this function. If that is needed, the caller must ref the array in advance.
See
Grl.Source
::content-changed
signal.This function is intended to be used only by plugins.
New in version 0.2.0.
- notify_change_start()¶
- Raises:
- Returns:
True
if initialization has succeed.- Return type:
Starts emitting
::content-changed
signals when self discovers changes in the content. This instructs self to setup the machinery needed to be aware of changes in the content.New in version 0.2.0.
- notify_change_stop()¶
- Raises:
- Returns:
True
if stop has succeed.- Return type:
This will drop emission of
::content-changed
signals from self. When this is done self should stop the machinery required for it to track changes in the content.New in version 0.2.0.
- query(query, keys, options, callback, *user_data)¶
- Parameters:
query (
str
) – the query to processoptions (
Grl.OperationOptions
) – options wanted for that operationcallback (
Grl.SourceResultCb
) – the user defined callbackuser_data (
object
orNone
) – the user data to pass in the callback
- Returns:
the operation identifier
- Return type:
Execute a specialized query (specific for each provider) on a media repository.
It is different from
Grl.Source.search
() semantically, because the query implies a carefully crafted string, rather than a simple string to search.This method is asynchronous.
New in version 0.2.0.
- query_sync(query, keys, options)¶
- Parameters:
query (
str
) – the query to processoptions (
Grl.OperationOptions
) – options wanted for that operation
- Raises:
- Returns:
a
GLib.List
withGrl.Media
elements. After useGObject.Object.unref
() every element and g_list_free() the list.- Return type:
Execute a specialized query (specific for each provider) on a media repository.
This method is synchronous.
New in version 0.2.0.
- remove(media, callback, *user_data)¶
- Parameters:
media (
Grl.Media
) – a data transfer objectcallback (
Grl.SourceRemoveCb
) – the user defined callbackuser_data (
object
orNone
) – the user data to pass in the callback
Remove a media from the self repository.
This method is asynchronous.
New in version 0.2.0.
- remove_sync(media)¶
- Parameters:
media (
Grl.Media
) – a data transfer object- Raises:
Remove a media from the self repository.
This method is synchronous.
New in version 0.2.0.
- resolve(media, keys, options, callback, *user_data)¶
- Parameters:
options (
Grl.OperationOptions
) – options to pass to this operationcallback (
Grl.SourceResolveCb
) – the user defined callbackuser_data (
object
orNone
) – the user data to pass in the callback
- Returns:
the operation identifie
- Return type:
This method is intended to fetch the requested keys of metadata of a given media to the media source.
This method is asynchronous.
New in version 0.2.0.
- resolve_sync(media, keys, options)¶
- Parameters:
options (
Grl.OperationOptions
) – options to pass to this operation
- Raises:
- Returns:
a filled
Grl.Media
- Return type:
This method is intended to fetch the requested keys of metadata of a given media to the media source.
This method is synchronous.
New in version 0.2.0.
- search(text, keys, options, callback, *user_data)¶
- Parameters:
text (
str
) – the text to searchoptions (
Grl.OperationOptions
) – options wanted for that operationcallback (
Grl.SourceResultCb
) – the user defined callbackuser_data (
object
orNone
) – the user data to pass in the callback
- Returns:
the operation identifier
- Return type:
Search for the text string in a source for data identified with that string.
If text is
None
then no text filter will be applied, and thus, no media items from self will be filtered. If self does not supportNone
-text search operations it should notiy the client by settingGrl.CoreError.SEARCH_NULL_UNSUPPORTED
in callback's error parameter.This method is asynchronous.
New in version 0.2.0.
- search_sync(text, keys, options)¶
- Parameters:
text (
str
) – the text to searchoptions (
Grl.OperationOptions
) – options wanted for that operation
- Raises:
- Returns:
a
GLib.List
withGrl.Media
elements. After useGObject.Object.unref
() every element and g_list_free() the list.- Return type:
Search for the text string in a source for data identified with that string.
If text is
None
then no text filter will be applied, and thus, no media items from self will be filtered. If self does not supportNone
-text search operations it should notiy the client by settingGrl.CoreError.SEARCH_NULL_UNSUPPORTED
in the error parameter.This method is synchronous.
New in version 0.2.0.
- set_auto_split_threshold(threshold)¶
- Parameters:
threshold (
int
) – the threshold to set
Sets how much elements the source is able to handle in a single request.
If user, during a search or browsing operation, asks for more elements than the threshold, the request will be automatically splitted in chunks, so up to threshold elements will be asked in each request.
Source will act as if user were asking just a chunk, and user won’t notice that the request was chunked.
This function is intended to be used only by plugins.
New in version 0.2.0.
- slow_keys()¶
-
Similar to
Grl.Source.supported_keys
(), but these keys are marked as slow because of the amount of traffic/processing needed to fetch them.New in version 0.2.0.
- store(parent, media, flags, callback, *user_data)¶
- Parameters:
parent (
Grl.Media
orNone
) – a parent to store the data transfer objectsmedia (
Grl.Media
) – a data transfer objectflags (
Grl.WriteFlags
) – flags to configure specific behaviour of the operationcallback (
Grl.SourceStoreCb
) – the user defined callbackuser_data (
object
orNone
) – the user data to pass in the callback
Store the media into the parent container
This method is asynchronous.
New in version 0.3.0.
- store_metadata(media, keys, flags, callback, *user_data)¶
- Parameters:
media (
Grl.Media
) – theGrl.Media
object that we want to operate on.keys ([
int
] orNone
) – a list of #GrlKeyID whose values we want to change.flags (
Grl.WriteFlags
) – Flags to configure specific behaviors of the operation.callback (
Grl.SourceStoreCb
) – the callback to execute when the operation is finished.
Get the values for keys from media and store it permanently. After calling this method, future queries that return this media object shall return this new values for the selected keys.
This function is asynchronous and uses the Glib’s main loop.
New in version 0.2.0.
- store_metadata_sync(media, keys, flags)¶
- Parameters:
media (
Grl.Media
) – theGrl.Media
object that we want to operate onkeys ([
int
] orNone
) – a list of #GrlKeyID whose values we want to changeflags (
Grl.WriteFlags
) – Flags to configure specific behaviors of the operation.
- Raises:
- Returns:
- Return type:
[
int
]
Update keys values from media in the self. After calling this method, future queries that return this media object shall return this new value for the selected key.
This function is synchronous.
New in version 0.2.0.
- store_sync(parent, media, flags)¶
- Parameters:
- Raises:
Store the media into the parent container.
This method is synchronous.
New in version 0.3.0.
- supported_keys()¶
-
Get a list of #GrlKeyID, which describe a metadata types that this source can fetch and store.
New in version 0.2.0.
- supported_operations()¶
- Returns:
a bitwise mangle with the supported operations by the source
- Return type:
By default the derived objects of
Grl.Source
can only resolve.New in version 0.2.0.
- test_media_from_uri(uri)¶
- Parameters:
uri (
str
) – A URI that can be used to identify a media resource- Returns:
True
if it can,False
otherwise.This method is synchronous.
- Return type:
Tests whether self can instantiate a
Grl.Media
object representing the media resource exposed at uri.New in version 0.2.0.
- writable_keys()¶
-
Similar to
Grl.Source.supported_keys
(), but these keys are marked as writable, meaning the source allows the client to provide new values for these keys that will be stored permanently.New in version 0.2.0.
- do_browse(bs) virtual¶
- Parameters:
bs (
Grl.SourceBrowseSpec
) –
- do_get_caps(operation) virtual¶
- Parameters:
operation (
Grl.SupportedOps
) – a supported operation. Even though the type allows to specify several operations, only one should be provided here.- Returns:
The capabilities
- Return type:
Get the capabilities of source for operation.
New in version 0.2.0.
- do_may_resolve(media, key_id, missing_keys) virtual¶
- Parameters:
- Returns:
True
if there’s a possibility that source resolves key_id for media,False
otherwise.- Return type:
Checks whether key_id may be resolved with source for media, so that the caller can avoid calling
Grl.Source.resolve
() if it can be known in advance it will fail.If the resolution is known to be impossible because more keys are needed in media, and missing_keys is not
None
, it is populated with the list of GrlKeyID that would be needed.This function is synchronous and should not block.
New in version 0.2.0.
- do_media_from_uri(mfus) virtual¶
- Parameters:
mfus (
Grl.SourceMediaFromUriSpec
) –
- do_notify_change_start() virtual¶
-
Starts emitting
::content-changed
signals when source discovers changes in the content. This instructs source to setup the machinery needed to be aware of changes in the content.New in version 0.2.0.
- do_notify_change_stop() virtual¶
-
This will drop emission of
::content-changed
signals from source. When this is done source should stop the machinery required for it to track changes in the content.New in version 0.2.0.
- do_query(qs) virtual¶
- Parameters:
qs (
Grl.SourceQuerySpec
) –
- do_remove(rs) virtual¶
- Parameters:
rs (
Grl.SourceRemoveSpec
) –
- do_resolve(ms) virtual¶
- Parameters:
ms (
Grl.SourceResolveSpec
) –
- do_search(ss) virtual¶
- Parameters:
ss (
Grl.SourceSearchSpec
) –
- do_slow_keys() virtual¶
-
Similar to
Grl.Source.supported_keys
(), but these keys are marked as slow because of the amount of traffic/processing needed to fetch them.New in version 0.2.0.
- do_store(ss) virtual¶
- Parameters:
ss (
Grl.SourceStoreSpec
) –
- do_store_metadata(sms) virtual¶
- Parameters:
sms (
Grl.SourceStoreMetadataSpec
) –
- do_supported_keys() virtual¶
-
Get a list of #GrlKeyID, which describe a metadata types that this source can fetch and store.
New in version 0.2.0.
- do_supported_operations() virtual¶
- Return type:
- do_test_media_from_uri(uri) virtual¶
- Parameters:
uri (
str
) – A URI that can be used to identify a media resource- Returns:
True
if it can,False
otherwise.This method is synchronous.
- Return type:
Tests whether source can instantiate a
Grl.Media
object representing the media resource exposed at uri.New in version 0.2.0.
- do_writable_keys() virtual¶
-
Similar to
Grl.Source.supported_keys
(), but these keys are marked as writable, meaning the source allows the client to provide new values for these keys that will be stored permanently.New in version 0.2.0.
Signal Details¶
- Grl.Source.signals.content_changed(source, changed_medias, change_type, location_unknown)¶
- Signal Name:
content-changed
- Flags:
- Parameters:
source (
Grl.Source
) – The object which received the signalchanged_medias ([
Grl.Media
]) – aGLib.PtrArray
with the medias that changed or a common ancestor of them of typeGrl.Media
.change_type (
Grl.SourceChangeType
) – the kind of change that ocurredlocation_unknown (
bool
) –True
if the change happened in media itself or in one of its direct children (when media is aGrl.Media
).False
otherwise
Signals that the content in the source has changed. changed_medias is the list of elements that have changed. Usually these medias are of type
Grl.Media
container, meaning that the content of that container has changed.If location_unknown is
True
it means the source cannot establish where the change happened: could be either in the container, in any child, or in any other descendant of the container in the hierarchy.Both change_type and location_unknown are applied to all elements in the list.
For the cases where the source can only signal that a change happened, but not where, it would use a list with the the root container (
None
id) and set location_unknown asTrue
.New in version 0.2.0.
Property Details¶
- Grl.Source.props.auto_split_threshold¶
-
Transparently split queries with count requests bigger than a certain threshold into smaller queries.
New in version 0.2.0.
- Grl.Source.props.plugin¶
- Name:
plugin
- Type:
- Default Value:
- Flags:
Plugin the source belongs to
New in version 0.2.0.
- Grl.Source.props.rank¶
-
Source rank
New in version 0.2.0.
- Grl.Source.props.source_desc¶
-
A description of the source
New in version 0.2.0.
- Grl.Source.props.source_id¶
-
The identifier of the source.
New in version 0.2.0.
- Grl.Source.props.source_name¶
-
The name of the source.
New in version 0.2.0.
- Grl.Source.props.source_tags¶
-
A string array of tags relevant this source.
The tags are arbitrary, and applications should just pass over the tags it does not understand. Applications would usually use this to either group sources together, or hide certain sources: a radio application would filter for
Grl.MediaType.AUDIO
inGrl.Source
::supported-media
as well as “radio” being listed in the tags.To avoid irrelevant content being listed in applications, sources such as generic video sites should not be tagged as “cinema” or “tv” as they contain a lot of content that’s not either of those.
This is a list of commonly used values:
“cinema”, or “tv” The content served is from cinema or TV sources. For example, a source for movie trailers would select the former, a source for streaming live TV would select the latter.
“radio” The content served is from streaming radios.
“music” The content served is music, for example, music stores such as Jamendo or Magnatune.
“country:country-code” The content is mostly relevant to users from a particular country, such as a national broadcaster. For example, BBC content would be tagged as “country:uk”. Country codes should be an ISO-639-1 or ISO-639-2 code.
“protocol:protocol-name” The content browsing or searching uses a particular protocol, such as DLNA/UPnP or DMAP/DAAP. This makes it easier to whitelist or blacklist sources rather than matching the implementation specific source ID. Examples are “protocol:dlna” and “protocol:dmap”.
“localhost”, or “localuser” The content is served from the machine the application is running on, or by an application the user is running. Applications might choose to avoid showing the user’s own data in their interfaces, or integrate it in the user’s local collection.
“net:local”, or “net:internet” The source requires a connection to the local network, or a connection to the Internet. Sources with those tags will be automatically hidden from the application’s reach when such networks aren’t available, or we’re not connected to a network.
“net:plaintext” The source makes requests over plain text, non-encrypted, network channels, such as using HTTP to do searches or lookups. Applications would usually disable those by default, so that privacy is respected by default, and no data is leaked unintentionally.
New in version 0.2.10.
- Grl.Source.props.supported_media¶
- Name:
supported-media
- Type:
- Default Value:
Grl.SupportedMedia.AUDIO
|Grl.SupportedMedia.VIDEO
|Grl.SupportedMedia.IMAGE
|Grl.SupportedMedia.ALL
- Flags:
List of supported media types by this source.
New in version 0.2.3.