subler.tools module¶
A collection of tools to help ease the pain of tagging metadata
-
class
subler.tools.
AtomCollection
[source]¶ Bases:
dict
A dictionary collection of
Atom
instances. When a tag is added, the tag for it is used as the key to the dictionary, the value for which is anAtom
instance. When you key back on an item already in the dictionary the value of thatAtom
is returned. Thus, if you know a key ‘Artist’ exists, you can get the value of that tag by doingmy_collection['Artist']
-
subler.tools.
tag_dict
(d, source, **kwargs)[source]¶ Normally, you are only allowed to tag using a list of
Atom
objects. This function will allow you to provide a dict of metadata to be tagged via aSubler
instance. Note: the sameAtom
limitations of valid tags will still applyParameters: - d – A dict of Atom data
- source – The source file you wish to write the metadata to
- **kwargs –
Any other keyword args you would like passed to
Subler
. Note: if you provide a ‘metadata’ field it will be merged with the data stored in d
Tools Examples¶
Below are some examples of how one might make use of the functions provided within the tools module.
AtomCollection Examples¶
AtomCollection
‘s can be used to store Atom data in a dict
representation.
>>> from subler import Subler
>>> from subler.tools import AtomCollection
>>> metadata = AtomCollection()
>>> metadata['TV Show'] = 'Firefly'
>>> metadata['TV Episode #'] = 1
>>> metadata['Genre'] = 'Drama'
>>> s = Subler('/Users/Me/Movies/Firefly/S1/S1E1.m4v', media_kind='TV Show',
... metadata=metadata.atoms)
>>> s.tag()
tag_dict Examples¶
If you’d prefer to not deal with Atom
instances or an
AtomCollection
for managing your metadata, you can
optionally store your data in a stock Python dict instance and still easily
tag your metadata
>>> from subler.tools import tag_dict
>>> metadata = {'TV Show': 'Firefly', 'TV Episode #': 1, 'Genre': 'Drama'}
>>> tag_dict(metadata, '/Users/Me/Movies/Firefly/S1/S1E1.m4v',
... media_kind='TV Show')