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.Parserstructure are private and should never be accessed directly.- classmethod can_parse_from_data(data, len, debug)¶
- Parameters:
- Returns:
Trueif 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:
Trueif 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:
Trueif 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.Parserobject.
- 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
gint64denoting 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
gint64denoting 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) –Trueif the parser should add the playlist URI to the end of the playlist on parse failurecancellable (
Gio.CancellableorNone) – optionalGio.Cancellableobject, orNonecallback (
Gio.AsyncReadyCallbackorNone) – aGio.AsyncReadyCallbackto call when parsing is finisheduser_data (
objectorNone) – 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.CANCELLEDis 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 (
strorNone) – the base path for relative filenames, orNonefallback (
bool) –Trueif the parser should add the playlist URI to the end of the playlist on parse failurecancellable (
Gio.CancellableorNone) – optionalGio.Cancellableobject, orNonecallback (
Gio.AsyncReadyCallbackorNone) – aGio.AsyncReadyCallbackto call when parsing is finisheduser_data (
objectorNone) – 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.Playlisttitle (
str) – the playlist titletype (
TotemPlParser.ParserType) – aTotemPlParser.ParserTypefor the outputted playlist
- Raises:
- Returns:
Trueon 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_DIRECTORYerror will be returned, and if the file is some other form of non-regular file then aGio.IOErrorEnum.NOT_REGULAR_FILEerror will be returned. Some file systems don’t allow all file names, and may return aGio.IOErrorEnum.INVALID_FILENAMEerror, and if the name is too long,Gio.IOErrorEnum.FILENAME_TOO_LONGwill 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_ARGUMENTerror 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.ConvertErrorwill be returned.
- save_async(playlist, dest, title, type, cancellable, callback, *user_data)¶
- Parameters:
playlist (
TotemPlParser.Playlist) – aTotemPlParser.Playlisttitle (
str) – the playlist titletype (
TotemPlParser.ParserType) – aTotemPlParser.ParserTypefor the outputted playlistcancellable (
Gio.CancellableorNone) – aGio.Cancellable, orNonecallback (
Gio.AsyncReadyCallbackorNone) – aGio.AsyncReadyCallbackto call when saving has finisheduser_data (
objectorNone) – 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.CANCELLEDwill be returned when this function is called.
- do_entry_parsed(uri, metadata) virtual¶
-
the generic signal handler for the
TotemPlParser.Parser::entry-parsedsignal, which can be overridden by inheriting classes
- do_playlist_ended(uri) virtual¶
- Parameters:
uri (
str) –
the generic signal handler for the
TotemPlParser.Parser::playlist-endedsignal, which can be overridden by inheriting classes
- do_playlist_started(uri, metadata) virtual¶
-
the generic signal handler for the
TotemPlParser.Parser::playlist-startedsignal, which can be overridden by inheriting classes
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.HashTableof metadata relating to the entry added
The
::entry-parsedsignal 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-endedsignal is emitted when a playlist is finished parsing. It is only called whenTotemPlParser.Parser::playlist-startedhas 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.HashTableof metadata relating to the playlist that started.
The
::playlist-startedsignal 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.