mmusicc.util package¶
mmusicc.util.allocationmap module¶
Definitions for this documentation:
- TAG
- string of tag used in program (e.g. MetadataDict), also TAG display name.
- STRING(s)
- string used in the files for the TAGS. Can be a list to match different variants (e.g. comment, description).
- ID3
- frame names of ID3 tag standard
list of all recognized TAGs.
Type: list of tags
-
mmusicc.util.allocationmap.dict_tag2id3¶ dict mapping TAG to ID3.
Type: dict
-
mmusicc.util.allocationmap.dict_id32tag¶ dict mapping ID3 to TAG.
Type: dict
-
mmusicc.util.allocationmap.dict_tag2strs¶ dict mapping TAG to STRING(s).
Type: dict
-
mmusicc.util.allocationmap.dict_str2tag¶ dict mapping STRING to TAG.
Type: dict
-
mmusicc.util.allocationmap.init_allocationmap(path, force=False)[source]¶ Initialize allocation map from config file.
Creates dicts as lookup tables as global variables.
Parameters: - path (str) – path of yaml file containing a mapping for the allocation table
- force (bool, optional) – if True, initializes the allocationmap even if it is already initialized, otherwise skips. Defaults to False.
Convert a list of STRING(s) to list of TAGs.
Parameters: tags (list of str) – STRING(s). Returns: TAGs. Return type: list of str
mmusicc.util.metadatadict module¶
-
class
mmusicc.util.metadatadict.MetadataDict(init_value=None)[source]¶ Bases:
dictDictionary containing tags as keys, values can be reset.
Parameters: init_value (object, optional) – initial value of all values, defaults to None. -
import_builtin_dict(b_dict) → dict[source]¶ Import a dictionary into the MetadataDict, mapping TAGs.
Parameters: b_dict (dict) – any dictionary with tag, value pairs Returns: key value pairs that could’t be imported. Return type: list
-
-
mmusicc.util.metadatadict.metadatadict(b_dict) → mmusicc.util.metadatadict.MetadataDict[source]¶ Returns a MetadataDict from the dict, unknown tags are dropped
-
class
mmusicc.util.metadatadict.PairedText(role, name)[source]¶ Bases:
objectProxy object for mutagen.id3.PairedTextFrames. Experimental not used.
-
class
mmusicc.util.metadatadict.Empty[source]¶ Bases:
objectObject representing the emptiness of a existing tag without an value.
-
value= ''¶
-
-
class
mmusicc.util.metadatadict.PictureType[source]¶ Bases:
enum.EnumEnumeration of image types defined by the ID3 standard for the APIC frame, but also reused in WMA/FLAC/VorbisComment.
-
OTHER= 0¶ Other
-
FILE_ICON= 1¶ 32x32 pixels ‘file icon’ (PNG only)
-
OTHER_FILE_ICON= 2¶ Other file icon
-
COVER_FRONT= 3¶ Cover (front)
-
COVER_BACK= 4¶ Cover (back)
-
LEAFLET_PAGE= 5¶ Leaflet page
-
MEDIA= 6¶ Media (e.g. label side of CD)
-
LEAD_ARTIST= 7¶ Lead artist/lead performer/soloist
-
ARTIST= 8¶ Artist/performer
-
CONDUCTOR= 9¶ Conductor
-
BAND= 10¶ Band/Orchestra
-
COMPOSER= 11¶ Composer
-
LYRICIST= 12¶ Lyricist/text writer
-
RECORDING_LOCATION= 13¶ Recording Location
-
DURING_RECORDING= 14¶ During recording
-
DURING_PERFORMANCE= 15¶ During performance
-
SCREEN_CAPTURE= 16¶ Movie/video screen capture
-
FISH= 17¶ A bright coloured fish
-
ILLUSTRATION= 18¶ Illustration
-
BAND_LOGOTYPE= 19¶ Band/artist logotype
-
PUBLISHER_LOGOTYPE= 20¶ Publisher/Studio logotype
-
-
class
mmusicc.util.metadatadict.Div(key=None, list_metadata=None)[source]¶ Bases:
objectObject Representing a group different values. Provides rich comparison.
Still Under Construction.
Parameters: - key (str, optional) – Dictionary key which values to represent
- list_metadata (list<Metadata>, optional) – List of Metadata object containing the values.
-
mmusicc.util.metadatadict.scan_dictionary(dict_tags, dict_data, parse_text=False)[source]¶ Scan a dictionary (dict_tags) for tags and fill dict_data with them.
Parameters: - dict_tags (dict) – dictionary (tag_str: value) items to be imported.
- dict_data (dict) – dictionary to be filled with imported tag values.
- parse_text (bool) – if True, pass values to text_parser_get else return value as it is. Defaults to False.
Returns: - dictionary with all tags whose name could not be
associated with. Note: keys are casfolded.
Return type: dict<str, str>
mmusicc.util.misc module¶
-
mmusicc.util.misc.process_white_and_blacklist(whitelist, blacklist)[source]¶ creates a whitelist from one whitelist and one blacklist.
Blacklist is processed after whitelist and will remove whitelisted items.
Parameters: - whitelist (list of str) – whitelist of tags to be imported. Loads all tags if None.
- blacklist (list of str) – blacklist of tags not to be imported. These items are removed from the whitelist. If none, whitelist is returned unprocessed.
Returns: whitelist after applying blacklisting.
Return type: list<str>
-
mmusicc.util.misc.swap_base(root_a, path_a, root_b)[source]¶ removes the root part of path_a and attaches the remainder to root of root_b crating path_b.
Parameters: - root_a (pathlib.Path) – Root path of a.
- path_a (pathlib.Path) – Full path of a.
- root_b (pathlib.Path) – Root path of b.
Returns: Full path of path_b.
Return type: (pathlib.Path)
-
mmusicc.util.misc.get_the_right_one(list_path, match_path, drop_suffix=True)[source]¶ return the most matching path out of a list of (absolute) paths
with has the most common elements beginning at the leaves of the tree. Basically finds matching relative paths with unknown working directory. All string paths are automatically converted to pathlib Paths.
Parameters: - list_path (list of pathlib.Path or list of str) – list of paths to be compared.
- match_path (str or pathlib.Path) – path to be matched.
- drop_suffix (bool, optional) – if True, compare paths without extensions (if path points to a file). Defaults to True.
Returns: Path from list which matches the match_path the most.
Return type: pathlib.Path
- Exceptions:
- KeyError: if not matching entry has been found.
Example
>>> list_path = ['fuu/bar/mmusicc.flac', 'fuu/rab/mmusicc.ogg'] >>> match_path = 'root/bar/mmusicc.ogg' >>> get_the_right_one(list_path, match_path) 'fuu/bar/mmusicc.flac'
mmusicc.util.ffmpeg module¶
-
class
mmusicc.util.ffmpeg.FFmpeg(source, target, options=None, executable='ffmpeg')[source]¶ Bases:
objectWrapper for FFmpeg <https://www.ffmpeg.org/>.
Parameters: - source (pathlib.path) – path to source file
- target (pathlib.path) – path to target file
- options (str) – string containing options for ffmpeg as use in console (arguments separated by space)
- executable (str, optional) – path to ffmpeg executable. Defaults to ‘ffmpeg’: Can be overwritten in case e.g libav is used.
-
run()[source]¶ Execute ffmpeg command line. Log stderr output.
Raises: FFRuntimeError– in case ffmpeg command exits with a non-zero code.FFExecutableNotFoundError– in case the executable path passed as not valid.
mmusicc.util.importhelper module¶
Module adapted and copied from: https://github.com/quodlibet/quodlibet/blob/master/quodlibet/util/importhelper.py
-
mmusicc.util.importhelper.load_dir_modules(path, package)[source]¶ Load all modules and packages in path (recursive).
In case the module is already loaded, doesn’t reload it.
mmusicc.util.logger module¶
-
mmusicc.util.logger.copy_log_file(path_target)[source]¶ copy current log file of FileHandler to target path
Returns: actual path of target Return type: pathlib.Path
-
mmusicc.util.logger.get_log_file()[source]¶ Returns: path of file logged to by FileHandler Return type: pathlib.Path
-
mmusicc.util.logger.init_logger(level=25, file_path=None)[source]¶ Initialise Python Logger (function may be extended in future)
Parameters: - level (int) – log level for console output
- file_path (str or pathlib.Path or None) – file path of log file. If None a logfile with a unique name is created at the current working directory, which must be deleted manually. If path exits log is append to file. Defaults to None.
Returns: path of log file
Return type: pathlib.Path