XAUTOPF

Inheritance diagram of musify.libraries.local.playlist.xautopf

The XAutoPF implementation of a LocalPlaylist.

Classes:

SyncResultXAutoPF(start,Β start_included,Β ...)

Stores the results of a sync with a local XAutoPF playlist.

XAutoPF(path[,Β tracks,Β path_mapper])

For reading and writing data from MusicBee's auto-playlist format.

XMLPlaylistParser(path[,Β path_mapper])

class musify.libraries.local.playlist.xautopf.SyncResultXAutoPF(start, start_included, start_excluded, start_compared, start_limiter, start_sorter, final, final_included, final_excluded, final_compared, final_limiter, final_sorter)

Bases: Result

Stores the results of a sync with a local XAutoPF playlist.

Attributes:

start

The total number of tracks in the playlist before the sync.

start_included

The number of tracks that matched the include settings before the sync.

start_excluded

The number of tracks that matched the exclude settings before the sync.

start_compared

The number of tracks that matched all the Comparer settings before the sync.

start_limiter

Was a limiter present on the playlist before the sync.

start_sorter

Was a sorter present on the playlist before the sync.

final

The total number of tracks in the playlist after the sync.

final_included

The number of tracks that matched the include settings after the sync.

final_excluded

The number of tracks that matched the exclude settings after the sync.

final_compared

The number of tracks that matched all the Comparer settings after the sync.

final_limiter

Was a limiter present on the playlist after the sync.

final_sorter

Was a sorter present on the playlist after the sync.

start: int

The total number of tracks in the playlist before the sync.

start_included: int

The number of tracks that matched the include settings before the sync.

start_excluded: int

The number of tracks that matched the exclude settings before the sync.

start_compared: int

The number of tracks that matched all the Comparer settings before the sync.

start_limiter: bool

Was a limiter present on the playlist before the sync.

start_sorter: bool

Was a sorter present on the playlist before the sync.

final: int

The total number of tracks in the playlist after the sync.

final_included: int

The number of tracks that matched the include settings after the sync.

final_excluded: int

The number of tracks that matched the exclude settings after the sync.

final_compared: int

The number of tracks that matched all the Comparer settings after the sync.

final_limiter: bool

Was a limiter present on the playlist after the sync.

final_sorter: bool

Was a sorter present on the playlist after the sync.

class musify.libraries.local.playlist.xautopf.XAutoPF(path, tracks=(), path_mapper=PathMapper({}), *_, **__)

Bases: LocalPlaylist[FilterMatcher[LocalTrack, FilterDefinedList[LocalTrack], FilterDefinedList[LocalTrack], FilterComparers[LocalTrack]]]

For reading and writing data from MusicBee’s auto-playlist format.

Note: You must provide a list of tracks to search on initialisation for this playlist type.

Parameters:
  • path (str) – Absolute path of the playlist.

  • tracks (Collection[LocalTrack] (default: ())) – Optional. Available Tracks to search through for matches. If none are provided, no tracks will be loaded initially

  • path_mapper (PathMapper (default: PathMapper({}))) – Optionally, provide a PathMapper for paths stored in the playlist file. Useful if the playlist file contains relative paths and/or paths for other systems that need to be mapped to absolute, system-specific paths to be loaded and back again when saved.

Attributes:

valid_extensions

Extensions of files that can be loaded by this class.

default_xml

The initial values to use as the base XML when creating a new XAutoPF file from scratch.

description

Description of this playlist

limiter_deduplication

This setting controls whether duplicates should be filtered out before running limiter operations.

image_links

The images associated with this playlist in the form {<image name/type>: <image link>}

Methods:

load([tracks])

Read the playlist file and update the tracks in this playlist instance.

save([dry_run])

Write the tracks in this Playlist and its settings (if applicable) to file.

valid_extensions: frozenset[str] = frozenset({'.xautopf'})

Extensions of files that can be loaded by this class.

default_xml = {'SmartPlaylist': {'@ConsolidateAlbums': 'False', '@Layout': '4', '@LayoutGroupBy': '0', '@LiveUpdating': 'True', '@MusicLibraryPath': '', '@SaveStaticCopy': 'False', 'Source': {'@Type': '1', 'Description': None}}}

The initial values to use as the base XML when creating a new XAutoPF file from scratch. Certain settings in the β€˜Source’ key relating to processors that this program recognises will be set on initialisation. Hence, any default values assigned to these keys will be overridden.

property description

Description of this playlist

property limiter_deduplication: bool

This setting controls whether duplicates should be filtered out before running limiter operations.

The images associated with this playlist in the form {<image name/type>: <image link>}

load(tracks=())

Read the playlist file and update the tracks in this playlist instance.

Parameters:

tracks (Collection[LocalTrack] (default: ())) – Available Tracks to search through for matches.

Returns:

list[LocalTrack] – Ordered list of tracks in this playlist

save(dry_run=True, *_, **__)

Write the tracks in this Playlist and its settings (if applicable) to file.

Parameters:

dry_run (bool (default: True)) – Run function, but do not modify the file on the disk.

Returns:

SyncResultXAutoPF – The results of the sync as a SyncResultXAutoPF object.

class musify.libraries.local.playlist.xautopf.XMLPlaylistParser(path, path_mapper=PathMapper({}))

Bases: File, PrettyPrinter

Attributes:

name_field_map

Map of MusicBee field key name to Field enum

field_name_map

Map of Field enum to MusicBee field key name

defined_sort

Settings for custom sort codes.

default_sort

The default/manual sort code

default_group_by

The default setting to use for the GroupBy setting

path

The path to the file.

xml_smart_playlist

The smart playlist data part of the loaded XML playlist data

xml_source

The source data part of the loaded XML playlist data

description

The description value of the XML playlist data

path_mapper

Maps paths stored in the playlist file.

xml

A map representation of the loaded XML playlist data

limiter_deduplication

This setting controls whether duplicates should be filtered out before running limiter operations.

Methods:

load()

Load xml object from the disk

save([dry_run])

Save xml object to the disk

get_matcher()

Initialise and return a FilterMatcher object from loaded XML playlist data.

parse_matcher([matcher])

Update the loaded xml object by parsing the given matcher to its XML playlist representation.

parse_exception_paths(matcher,Β items,Β original)

Parse the exception paths (i.e. include/exclude attributes) for the given matcher to its XML playlist representation.

get_limiter()

Initialise and return a ItemLimiter object from loaded XML playlist data.

parse_limiter([limiter,Β deduplicate])

Update the loaded xml object by parsing the given limiter to its XML playlist representation.

get_sorter()

Initialise and return a ItemLimiter object from loaded XML playlist data.

parse_sorter([sorter])

Update the loaded xml object by parsing the given sorter to its XML playlist representation.

as_dict()

Return a dictionary representation of the key attributes of this object.

name_field_map = {'Album': Fields.ALBUM, 'Album Artist': Fields.ALBUM_ARTIST, 'ArtistPeople': Fields.ARTIST, 'BeatsPerMin': Fields.BPM, 'BitDepth': Fields.BIT_DEPTH, 'Comment': Fields.COMMENTS, 'DiscCount': Fields.DISC_TOTAL, 'DiscNo': Fields.DISC_NUMBER, 'FileBitrate': Fields.BIT_RATE, 'FileChannels': Fields.CHANNELS, 'FileDateAdded': Fields.DATE_ADDED, 'FileDateModified': Fields.DATE_MODIFIED, 'FileDuration': Fields.LENGTH, 'FileExtension': Fields.EXT, 'FileKind': Fields.TYPE, 'FileLastPlayed': Fields.LAST_PLAYED, 'FileName': Fields.FILENAME, 'FilePath': Fields.PATH, 'FilePlayCount': Fields.PLAY_COUNT, 'FileSampleRate': Fields.SAMPLE_RATE, 'FolderName': Fields.FOLDER, 'GenreSplits': Fields.GENRES, 'None': None, 'Rating': Fields.RATING, 'Title': Fields.TITLE, 'TrackCount': Fields.TRACK_TOTAL, 'TrackNo': Fields.TRACK_NUMBER, 'Year': Fields.YEAR}

Map of MusicBee field key name to Field enum

field_name_map = {Fields.ALBUM: 'Album', Fields.ALBUM_ARTIST: 'Album Artist', Fields.ARTIST: 'ArtistPeople', Fields.BIT_DEPTH: 'BitDepth', Fields.BIT_RATE: 'FileBitrate', Fields.BPM: 'BeatsPerMin', Fields.CHANNELS: 'FileChannels', Fields.COMMENTS: 'Comment', Fields.DATE_ADDED: 'FileDateAdded', Fields.DATE_MODIFIED: 'FileDateModified', Fields.DISC_NUMBER: 'DiscNo', Fields.DISC_TOTAL: 'DiscCount', Fields.EXT: 'FileExtension', Fields.FILENAME: 'FileName', Fields.FOLDER: 'FolderName', Fields.GENRES: 'GenreSplits', Fields.LAST_PLAYED: 'FileLastPlayed', Fields.LENGTH: 'FileDuration', Fields.PATH: 'FilePath', Fields.PLAY_COUNT: 'FilePlayCount', Fields.RATING: 'Rating', Fields.SAMPLE_RATE: 'FileSampleRate', Fields.TITLE: 'Title', Fields.TRACK_NUMBER: 'TrackNo', Fields.TRACK_TOTAL: 'TrackCount', Fields.TYPE: 'FileKind', Fields.YEAR: 'Year', None: 'None'}

Map of Field enum to MusicBee field key name

defined_sort: dict[int, Mapping[Field, bool]] = {6: {Fields.FILENAME: False, Fields.ALBUM: False, Fields.DISC_NUMBER: False, Fields.TRACK_NUMBER: False}}

Settings for custom sort codes.

default_sort = 78

The default/manual sort code

default_group_by = 'track'

The default setting to use for the GroupBy setting

property path: str

The path to the file.

property xml_smart_playlist: dict[str, Any]

The smart playlist data part of the loaded XML playlist data

property xml_source: dict[str, Any]

The source data part of the loaded XML playlist data

property description

The description value of the XML playlist data

path_mapper

Maps paths stored in the playlist file.

xml: dict[str, Any]

A map representation of the loaded XML playlist data

load()

Load xml object from the disk

Return type:

None

save(dry_run=True, *_, **__)

Save xml object to the disk

Return type:

None

get_matcher()

Initialise and return a FilterMatcher object from loaded XML playlist data.

Return type:

FilterMatcher[LocalTrack, FilterDefinedList[LocalTrack], FilterDefinedList[LocalTrack], FilterComparers[LocalTrack]]

parse_matcher(matcher=None)

Update the loaded xml object by parsing the given matcher to its XML playlist representation. Does not extract exception paths (i.e. include/exclude attributes).

Return type:

None

parse_exception_paths(matcher, items, original)

Parse the exception paths (i.e. include/exclude attributes) for the given matcher to its XML playlist representation. Does not extract any other attributes from the matcher.

Parameters:
  • matcher (FilterMatcher | None) – The FilterMatcher to parse.

  • items (list[File]) – The items to export.

  • original (list[File | MusifyItem]) – The original items matched from the settings in the original file.

Return type:

None

get_limiter()

Initialise and return a ItemLimiter object from loaded XML playlist data.

Return type:

ItemLimiter | None

property limiter_deduplication: bool

This setting controls whether duplicates should be filtered out before running limiter operations.

parse_limiter(limiter=None, deduplicate=False)

Update the loaded xml object by parsing the given limiter to its XML playlist representation.

Return type:

None

get_sorter()

Initialise and return a ItemLimiter object from loaded XML playlist data.

Return type:

ItemSorter | None

valid_extensions: frozenset[str]

Extensions of files that can be loaded by this class.

parse_sorter(sorter=None)

Update the loaded xml object by parsing the given sorter to its XML playlist representation.

Return type:

None

as_dict()

Return a dictionary representation of the key attributes of this object.

The results of this function are used to produce the following:
  • A JSON representation of the object when calling json()

  • The string representation of the object when calling str() on the object

  • The representation of the object when calling repr() on the object