TotemPlParser.Parser¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
|
|
|
|
|
Properties¶
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w |
Whether or not to enable debugging output |
||
r/w |
Whether or not to disable parsing of unsafe locations |
||
r/w |
Whether or not to force parsing the file if the playlist looks unsupported |
||
r/w/c |
Whether or not to process URIs further |
Signals¶
- Inherited:
Name |
Short Description |
---|---|
The |
|
The |
|
The |
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
parent |
r |
Class Details¶
- class TotemPlParser.Parser(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
All the fields in the
TotemPlParser.Parser
structure are private and should never be accessed directly.- classmethod can_parse_from_data(data, len, debug)¶
- Parameters:
- Returns:
True
if data can be parsed- Return type:
Checks if the first len bytes of data can be parsed.
- classmethod can_parse_from_filename(filename, debug)¶
- Parameters:
- Returns:
True
if filename can be parsed- Return type:
Checks if the file can be parsed. Files can be parsed if:
they have a special mimetype, or
they have a mimetype which could be a video or a playlist.
- classmethod can_parse_from_uri(uri, debug)¶
- Parameters:
- Returns:
True
if uri could be parsed- Return type:
Checks if the remote URI can be parsed. Note that this does not actually try to open the remote URI, or deduce its mime-type from filename, as this would bring too many false positives.
- classmethod new()¶
- Returns:
a new
TotemPlParser.Parser
- Return type:
Creates a
TotemPlParser.Parser
object.
- classmethod parse_date(date_str, debug)¶
- Parameters:
- Returns:
the date in seconds, or -1 on error
- Return type:
Parses the given date string and returns it as a
gint64
denoting the date in seconds since the UNIX Epoch.
- classmethod parse_duration(duration, debug)¶
- Parameters:
- Returns:
the duration in seconds, or -1 on error
- Return type:
Parses the given duration string and returns it as a
gint64
denoting the duration in seconds.
- add_ignored_glob(glob)¶
- Parameters:
glob (
str
) – a glob to ignore
Adds a glob to the list of mimetypes to ignore, so that any URI of that glob is ignored during playlist parsing.
New in version 3.26.4.
- add_ignored_mimetype(mimetype)¶
- Parameters:
mimetype (
str
) – the mimetype to ignore
Adds a mimetype to the list of mimetypes to ignore, so that any URI of that mimetype is ignored during playlist parsing.
- add_ignored_scheme(scheme)¶
- Parameters:
scheme (
str
) – the scheme to ignore
Adds a scheme to the list of schemes to ignore, so that any URI using that scheme is ignored during playlist parsing.
- parse(uri, fallback)¶
- Parameters:
- Returns:
- Return type:
Parses a playlist given by the absolute URI uri. This method is synchronous, and will block on (e.g.) network requests to slow servers.
TotemPlParser.Parser.parse_async
() is recommended instead.Return values are as
TotemPlParser.Parser.parse_with_base
().
- parse_async(uri, fallback, cancellable, callback, *user_data)¶
- Parameters:
uri (
str
) – the URI of the playlist to parsefallback (
bool
) –True
if the parser should add the playlist URI to the end of the playlist on parse failurecancellable (
Gio.Cancellable
orNone
) – optionalGio.Cancellable
object, orNone
callback (
Gio.AsyncReadyCallback
orNone
) – aGio.AsyncReadyCallback
to call when parsing is finisheduser_data (
object
orNone
) – data to pass to the callback function
Starts asynchronous parsing of a playlist given by the absolute URI uri. self and uri are both reffed/copied when this function is called, so can safely be freed after this function returns.
For more details, see
TotemPlParser.Parser.parse
(), which is the synchronous version of this function.When the operation is finished, callback will be called. You can then call
TotemPlParser.Parser.parse_finish
() to get the results of the operation.
- parse_finish(async_result)¶
- Parameters:
async_result (
Gio.AsyncResult
) – aGio.AsyncResult
- Raises:
- Returns:
- Return type:
Finishes an asynchronous playlist parsing operation started with
TotemPlParser.Parser.parse_async
() orTotemPlParser.Parser.parse_with_base_async
().If parsing of the playlist is cancelled part-way through,
TotemPlParser.ParserResult.CANCELLED
is returned when this function is called.
- parse_with_base(uri, base, fallback)¶
- Parameters:
- Returns:
- Return type:
Parses a playlist given by the absolute URI uri, using base to resolve relative paths where appropriate.
- parse_with_base_async(uri, base, fallback, cancellable, callback, *user_data)¶
- Parameters:
uri (
str
) – the URI of the playlist to parsebase (
str
orNone
) – the base path for relative filenames, orNone
fallback (
bool
) –True
if the parser should add the playlist URI to the end of the playlist on parse failurecancellable (
Gio.Cancellable
orNone
) – optionalGio.Cancellable
object, orNone
callback (
Gio.AsyncReadyCallback
orNone
) – aGio.AsyncReadyCallback
to call when parsing is finisheduser_data (
object
orNone
) – data to pass to the callback function
Starts asynchronous parsing of a playlist given by the absolute URI uri, using base to resolve relative paths where appropriate. self and uri are both reffed/copied when this function is called, so can safely be freed after this function returns.
For more details, see
TotemPlParser.Parser.parse_with_base
(), which is the synchronous version of this function.When the operation is finished, callback will be called. You can then call
TotemPlParser.Parser.parse_finish
() to get the results of the operation.
- save(playlist, dest, title, type)¶
- Parameters:
playlist (
TotemPlParser.Playlist
) – aTotemPlParser.Playlist
title (
str
) – the playlist titletype (
TotemPlParser.ParserType
) – aTotemPlParser.ParserType
for the outputted playlist
- Raises:
- Returns:
True
on success- Return type:
Writes the playlist held by self and playlist out to the path pointed by dest. The playlist is written in the format type and is given the title title.
If the output file is a directory the
Gio.IOErrorEnum.IS_DIRECTORY
error will be returned, and if the file is some other form of non-regular file then aGio.IOErrorEnum.NOT_REGULAR_FILE
error will be returned. Some file systems don’t allow all file names, and may return aGio.IOErrorEnum.INVALID_FILENAME
error, and if the name is too long,Gio.IOErrorEnum.FILENAME_TOO_LONG
will be returned. Other errors are possible too, and depend on what kind of filesystem the file is on.In extreme cases, a
Gio.IOErrorEnum.INVALID_ARGUMENT
error can be returned, if parts of the playlist to be written are too long.If writing a PLA playlist and there is an error converting a URI’s encoding, a code from
GLib.ConvertError
will be returned.
- save_async(playlist, dest, title, type, cancellable, callback, *user_data)¶
- Parameters:
playlist (
TotemPlParser.Playlist
) – aTotemPlParser.Playlist
title (
str
) – the playlist titletype (
TotemPlParser.ParserType
) – aTotemPlParser.ParserType
for the outputted playlistcancellable (
Gio.Cancellable
orNone
) – aGio.Cancellable
, orNone
callback (
Gio.AsyncReadyCallback
orNone
) – aGio.AsyncReadyCallback
to call when saving has finisheduser_data (
object
orNone
) – data to pass to the callback function
Starts asynchronous version of
TotemPlParser.Parser.save
(). For more details seeTotemPlParser.Parser.save
().When the operation is finished, callback will be called. You can then call
TotemPlParser.Parser.save_finish
() to get the results of the operation.
- save_finish(async_result)¶
- Parameters:
async_result (
Gio.AsyncResult
) – aGio.AsyncResult
- Raises:
- Returns:
- Return type:
Finishes an asynchronous playlist saving operation started with
TotemPlParser.Parser.save_async
().If saving of the playlist is cancelled part-way through,
Gio.IOErrorEnum.CANCELLED
will be returned when this function is called.
Signal Details¶
- TotemPlParser.Parser.signals.entry_parsed(parser, uri, metadata)¶
- Signal Name:
entry-parsed
- Flags:
- Parameters:
parser (
TotemPlParser.Parser
) – The object which received the signaluri (
str
) – the URI of the entry parsedmetadata ({
str
:str
}) – aGLib.HashTable
of metadata relating to the entry added
The
::entry-parsed
signal is emitted when a new entry is parsed.
- TotemPlParser.Parser.signals.playlist_ended(parser, uri)¶
- Signal Name:
playlist-ended
- Flags:
- Parameters:
parser (
TotemPlParser.Parser
) – The object which received the signaluri (
str
) – the URI of the playlist that finished parsing.
The
::playlist-ended
signal is emitted when a playlist is finished parsing. It is only called whenTotemPlParser.Parser
::playlist-started
has been called for that playlist.
- TotemPlParser.Parser.signals.playlist_started(parser, uri, metadata)¶
- Signal Name:
playlist-started
- Flags:
- Parameters:
parser (
TotemPlParser.Parser
) – The object which received the signaluri (
str
) – the URI of the new playlist startedmetadata ({
str
:str
}) – aGLib.HashTable
of metadata relating to the playlist that started.
The
::playlist-started
signal is emitted when a playlist parsing has started. This signal isn’t emitted for all types of playlists, but can be relied on to be called for playlists which support playlist metadata, such as title.
Property Details¶
- TotemPlParser.Parser.props.disable_unsafe¶
-
If
True
, the parser will not parse unsafe locations, such as local devices and local files if the playlist isn’t local. This is useful if the library is parsing a playlist from a remote location such as a website.