XAUTOPFο
The XAutoPF implementation of a LocalPlaylist.
Classes:
|
Stores the results of a sync with a local XAutoPF playlist. |
|
For reading and writing data from MusicBee's auto-playlist format. |
|
- 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:
ResultStores the results of a sync with a local XAutoPF playlist.
Attributes:
The total number of tracks in the playlist before the sync.
The number of tracks that matched the include settings before the sync.
The number of tracks that matched the exclude settings before the sync.
The number of tracks that matched all the
Comparersettings before the sync.Was a limiter present on the playlist before the sync.
Was a sorter present on the playlist before the sync.
The total number of tracks in the playlist after the sync.
The number of tracks that matched the include settings after the sync.
The number of tracks that matched the exclude settings after the sync.
The number of tracks that matched all the
Comparersettings after the sync.Was a limiter present on the playlist after the sync.
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
Comparersettings 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
Comparersettings 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.
-
start:
- class musify.libraries.local.playlist.xautopf.XAutoPF(path, path_mapper=PathMapper({}), remote_wrangler=None)ο
Bases:
LocalPlaylist[FilterMatcher[LocalTrack,FilterDefinedList[LocalTrack],FilterDefinedList[LocalTrack],FilterComparers[LocalTrack]]]For reading and writing data from MusicBeeβs auto-playlist format.
- Parameters:
path (
str|Path) β Absolute path of the playlist. If the playlistpathgiven does not exist, a new playlist will be created onsave()path_mapper (
PathMapper(default:PathMapper({}))) β Optionally, provide aPathMapperfor 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.remote_wrangler (
RemoteDataWrangler(default:None)) β Not used by this object.
Attributes:
Extensions of files that can be loaded by this class.
The initial values to use as the base XML when creating a new XAutoPF file from scratch.
Description of this playlist
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>}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.
- property image_linksο
The images associated with this playlist in the form
{<image name/type>: <image link>}
- async 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. If no tracks are given, the playlist will be loaded empty.- Returns:
Selfβ Self
- async 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 aSyncResultXAutoPFobject.
- class musify.libraries.local.playlist.xautopf.XMLPlaylistParser(path, path_mapper=PathMapper({}))ο
Bases:
File,PrettyPrinterAttributes:
Map of MusicBee field key name to Field enum
Map of Field enum to MusicBee field key name
Settings for custom sort codes.
The default/manual sort code
The default setting to use for the GroupBy setting
The path to the file.
The smart playlist data part of the loaded XML playlist data
The source data part of the loaded XML playlist data
The description value of the XML playlist data
Maps paths stored in the playlist file.
A map representation of the loaded XML playlist data
This setting controls whether duplicates should be filtered out before running limiter operations.
Methods:
load()Load
xmlobject from the disksave([dry_run])Save
xmlobject to the diskInitialise and return a
FilterMatcherobject from loaded XML playlist data.parse_matcher([matcher])Update the loaded
xmlobject by parsing the givenmatcherto its XML playlist representation.parse_exception_paths(matcher,Β items,Β original)Parse the exception paths (i.e. include/exclude attributes) for the given
matcherto its XML playlist representation.Initialise and return a
ItemLimiterobject from loaded XML playlist data.parse_limiter([limiter,Β deduplicate])Update the loaded
xmlobject by parsing the givenlimiterto its XML playlist representation.Initialise and return a
ItemLimiterobject from loaded XML playlist data.parse_sorter([sorter])Update the loaded
xmlobject by parsing the givensorterto 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: Pathο
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
- async load()ο
Load
xmlobject from the disk- Return type:
None
- async save(dry_run=True, *_, **__)ο
Save
xmlobject to the disk- Return type:
None
- get_matcher()ο
Initialise and return a
FilterMatcherobject from loaded XML playlist data.- Return type:
FilterMatcher[LocalTrack,FilterDefinedList[LocalTrack],FilterDefinedList[LocalTrack],FilterComparers[LocalTrack]]
- parse_matcher(matcher=None)ο
Update the loaded
xmlobject by parsing the givenmatcherto 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
matcherto its XML playlist representation. Does not extract any other attributes from thematcher.- Parameters:
matcher (
FilterMatcher|None) β TheFilterMatcherto 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
ItemLimiterobject 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
xmlobject by parsing the givenlimiterto its XML playlist representation.- Return type:
None
- get_sorter()ο
Initialise and return a
ItemLimiterobject 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
xmlobject by parsing the givensorterto 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