package¶
mmusicc.metadata module¶
Base Module for all metadata interactions with files and the database.
Hint
how to doc metaclass properties and functions in class?
-
class
mmusicc.metadata.MetadataMeta(name, bases, nmspc)[source]¶ Bases:
typeMeta Object for Metadata class.
-
dry_run¶ Get or set. If True do everything as usual, but without writing data.
Type: bool
-
is_linked_database¶ Get True if a database is linked to class.
Type: bool
-
-
class
mmusicc.metadata.Metadata(file_path=None, read_tag=True)[source]¶ Bases:
objectClass containing Metadata Information,
either from a linked file or loaded from a database.
Parameters: - file_path (str or pathlib.Path, optional) – path to an supported audio file, can be set later with ‘link_audio_file()’ too. Defaults to None.
- read_tag (bool, optional) – enables automatic reading of metadata from file at class initialisation. Defaults to True.
-
file_path¶ Get file path of linked audio file.
Type: pathlib.Path
-
audio_file_linked¶ Get True if a audio file is linked to instance.
Type: bool
-
link_audio_file(file_path)[source]¶ Links audio file with given path to instance.
Parameters: file_path (str or pathlib.Path) – file path of audio file. Raises: FileNotFoundError– if file does not exist.
-
unprocessed_tag¶ Get file path of linked audio file.
Type: pathlib.Path
-
dict_data¶ Get the dict containing tags
Type: MetadataDict
Read metadata from linked audio file into dict meta.
Raises: Exception– if no file is linked
write metadata to linked audio file
Parameters: - remove_existing (bool, optional) – If true clear all tags on file before writing. Defaults to False.
- write_empty (bool) – if true write empty tags, exact effect depends on comment type. Either the tag entries will not exist or overwritten with None/Null/”“. Defaults to False.
Returns: 1 if data was saved to file, zero if nothing was changed on file.
Return type: int
Raises: Exception– if no file is linked
Imports metadata from another Metadata object.
Parameters: - source_meta (Metadata) – Metadata object containing the tags to be imported.
- whitelist (list of str, optional) – whitelist of tags to be imported. If None, loads all tags (except blacklisted). Defaults to None.
- blacklist (list of str, optional) – blacklist of tags not to be imported. Applied after whitelist. If None, no tags are blacklisted. Defaults to None.
- skip_none (bool, optional) – If True, don’t overwrite values in target, which are None in source. Defaults to True.
- clear_blacklisted (bool, optional) – Clear tags (set None) that are not in whitelist and/or in blacklist.
Imports metadata from the database.
Parameters: - primary_key (str, None) – unique identifier of the item which data has to be loaded. The save function only uses the absolute filepath atm. If value is None, a algorithm takes the path of the linked file works and works itself backward (beginning at the leave) in the key list of the DB until only one key is left, which is used. In other words, its acts like the keys are relative file path (with unknown working directory). Defaults to None.
- whitelist (list of str, optional) – whitelist of tags to be imported. If None, loads all tags (except blacklisted). Defaults to None.
- blacklist (list of str, optional) – blacklist of tags not to be imported. Applied after whitelist. If None, no tags are blacklisted. Defaults to None.
- skip_none (bool, optional) – If True, don’t overwrite values in target, which are None in source. Defaults to True.
- clear_blacklisted (bool, optional) – Clear tags (set None) that are not in whitelist and/or in blacklist.
- Raises – Exception: if no database linked to class
Saves all tags to database.
This is the secure way. Data not wanted does not have to be loaded, but all data can still be accessed in case it is needed again.
Raises: Exception– if no database linked to class
Automatic fill/autocomplete tags with in config file defined rules.
This future is intended to fix small consistency errors in metadata, like missing album artists or leading 0 before a single digit tracknumber.
-
class
mmusicc.metadata.GroupMetadata(list_metadata)[source]¶ Bases:
mmusicc.metadata.MetadataClass holding one ore many Metadata Objects. Subclasses Metadata and
overwrites Metadata functions so that you don’t have to care if you have one file or a list of files like an album. Tags in dict are a summary of the tags of individual values of the contained metadata. If all values of a tag are identical the value is in dict as it is, otherwise a Div object is created managing different values.
Parameters: list_metadata (list of Metadata or list of str or list of pathlib.Path) – list of Metadata objects or file paths. Note
Not all properties and functions of Metadata are supported (like file_path, obviously). Stick with the documented ones.
Super-Method applied to all Objects in list. See Metadata.
Super-Method applied to all Objects in list. See Metadata.
Super-Method applied to all Objects in list. See Metadata.
Super-Method applied to all Objects in list. See Metadata.
Parameters: - source_meta (GroupMetadata) – group metadata object.
- whitelist (list<str>, optional) – See Metadata.import_tags().
- blacklist (list<str>, optional) – See Metadata.import_tags().
- skip_none (bool, optional) – See Metadata.import_tags().
- clear_blacklisted (bool, optional) – See Metadata.import_tags().
Super-Method applied to all Objects in list. See Metadata.
Parameters: - whitelist (list<str>, optional) – See Metadata.import_tags().
- blacklist (list<str>, optional) – See Metadata.import_tags().
- skip_none (bool, optional) – See Metadata.import_tags().
- clear_blacklisted (bool, optional) – See Metadata.import_tags().
- primary_key (str, None) – no function .
Super-Method applied to all Objects in list. See Metadata.
-
audio_file_linked¶ Do not use this property. Only applies to Metadata.
-
unprocessed_tag¶ Super-Method applied to all Objects in list. See Metadata.
-
file_path¶ Do not use this property. Only applies to Metadata.
-
class
mmusicc.metadata.AlbumMetadata(path_album)[source]¶ Bases:
mmusicc.metadata.GroupMetadataSpecial case of GroupMetadata where Metadata list is created from a Folder/Album path. Skips non audio files.
Parameters: path_album – filepath of album or folder to be accessed as group.