Collectionο
Implements all collection types for a local library.
Classes:
|
Generic class for storing a collection of local tracks. |
|
|
|
Generic class for storing and filtering on a collection of local tracks with methods for enriching the attributes of this object from the attributes of the collection of tracks |
|
Object representing a collection of tracks in a folder on the local drive. |
|
Object representing a collection of tracks of an album. |
|
Object representing a collection of tracks by a single artist. |
|
Object representing a collection of tracks within a genre. |
- class musify.libraries.local.collection.LocalCollection(remote_wrangler=None)ο
Bases:
MusifyCollection
,Generic
Generic class for storing a collection of local tracks.
- Parameters:
remote_wrangler (
RemoteDataWrangler
(default:None
)) β Optionally, provide aRemoteDataWrangler
object for processing URIs on items. If given, the wrangler can be used when calling __get_item__ to get an item from the collection from its URI.
Attributes:
The tracks in this collection
The tracks in this collection
The total number of tracks in this collection
Timestamp of the last modified track in this collection
Timestamp of the track last added to the library in this collection
Timestamp of the last played track in this collection
Total number of plays of all tracks in this collection
The
MusifyLogger
for this objectA
RemoteDataWrangler
object for processing remote dataMethods:
save_tracks
([tags,Β replace,Β dry_run])Saves the tags of all tracks in this collection.
log_save_tracks_result
(results[,Β log_values])Log stats from the results of a
save_tracks
operationmerge_tracks
(tracks[,Β tags])Merge this collection with another collection or list of items by performing an inner join on a given set of tags
- property items: list[T]ο
The tracks in this collection
- abstract property tracks: list[T]ο
The tracks in this collection
- property track_total: intο
The total number of tracks in this collection
- property last_modified: datetimeο
Timestamp of the last modified track in this collection
- property last_added: datetime | Noneο
Timestamp of the track last added to the library in this collection
- property last_played: datetime | Noneο
Timestamp of the last played track in this collection
- property play_count: intο
Total number of plays of all tracks in this collection
- logger: MusifyLoggerο
The
MusifyLogger
for this object
- remote_wranglerο
A
RemoteDataWrangler
object for processing remote data
- async save_tracks(tags=LocalTrackField.ALL, replace=False, dry_run=True)ο
Saves the tags of all tracks in this collection. Use arguments from
LocalTrack.save()
- Parameters:
tags (UnitIterable[LocalTrackField] (default:
<LocalTrackField.ALL: 0>
)) β Tags to be updated.replace (bool (default:
False
)) β Destructively replace tags in each file.dry_run (bool (default:
True
)) β Run function, but do not modify the file on the disk.
- Returns:
dict[T, SyncResultTrack] β A map of the
LocalTrack
saved to its result as aSyncResultTrack
object only for tracks that were saved or would have been saved in the case of a dry run.
- log_save_tracks_result(results, log_values=False)ο
Log stats from the results of a
save_tracks
operation- Parameters:
results (Mapping[T, SyncResultTrack]) β The results to log.
log_values (bool (default:
False
)) β Log the values of the trackβs tags.
- Return type:
None
- merge_tracks(tracks, tags=Fields.ALL)ο
Merge this collection with another collection or list of items by performing an inner join on a given set of tags
- class musify.libraries.local.collection.BasicLocalCollection(name, tracks, remote_wrangler=None)ο
Bases:
LocalCollection
,Generic
Attributes:
The name of this collection
The tracks in this collection
Total duration of all items in this collection in seconds
- property nameο
The name of this collection
- property tracks: list[T]ο
The tracks in this collection
- property lengthο
Total duration of all items in this collection in seconds
- class musify.libraries.local.collection.LocalCollectionFiltered(tracks, name=None, remote_wrangler=None)ο
Bases:
LocalCollection
,Generic
Generic class for storing and filtering on a collection of local tracks with methods for enriching the attributes of this object from the attributes of the collection of tracks
- Parameters:
tracks (Collection[T]) β A list of loaded tracks.
name (str | None (default:
None
)) β The name of this collection. If given, the object only stores tracks that match the name given on the attribute of this object. If None, the list of tracks given are taken to be all the tracks contained in this collection.remote_wrangler (RemoteDataWrangler (default:
None
)) β Optionally, provide aRemoteDataWrangler
object for processing URIs on tracks. If given, the wrangler can be used when calling __get_item__ to get an item from the collection from its URI.
- Raises:
LocalCollectionError β If the given tracks contain more than one unique value for the attribute of this collection when name is None.
Attributes:
The name of the key property of this collection
The tracks in this collection
List of artists ordered by frequency of appearance on the tracks in this collection
- property nameο
The name of the key property of this collection
- property tracksο
The tracks in this collection
- property artists: list[str]ο
List of artists ordered by frequency of appearance on the tracks in this collection
- class musify.libraries.local.collection.LocalFolder(tracks=(), name=None, remote_wrangler=None)ο
Bases:
LocalCollectionFiltered
[LocalTrack
],Folder
[LocalTrack
]Object representing a collection of tracks in a folder on the local drive.
- Parameters:
tracks (
Collection
[LocalTrack
] (default:()
)) β A list of loaded tracks.name (
str
|None
(default:None
)) β The name of this folder. If given, the object only stores tracks that match the foldername
given. If None, the list of tracks given are taken to be all the tracks contained in this folder.remote_wrangler (
RemoteDataWrangler
(default:None
)) β Optionally, provide aRemoteDataWrangler
object for processing URIs on tracks. If given, the wrangler can be used when calling __get_item__ to get an item from the collection from its URI.
- Raises:
LocalCollectionError β If the given tracks contain more than one unique value for
folder
when name is None.
Attributes:
List of albums ordered by frequency of appearance on the tracks in this folder
List of genres ordered by frequency of appearance on the tracks in this collection
Folder is a compilation if over 50% of tracks are marked as compilation
Methods:
load_folder
(path[,Β remote_wrangler])Load tracks in a folder at the given
path
.- property albumsο
List of albums ordered by frequency of appearance on the tracks in this folder
- property genres: list[str]ο
List of genres ordered by frequency of appearance on the tracks in this collection
- property compilationο
Folder is a compilation if over 50% of tracks are marked as compilation
- async classmethod load_folder(path, remote_wrangler=None)ο
Load tracks in a folder at the given
path
.- Parameters:
path (
str
|Path
|None
) β The path of the folder to load.remote_wrangler (
RemoteDataWrangler
(default:None
)) β Optionally, provide aRemoteDataWrangler
object for processing URIs on tracks. If given, the wrangler can be used when calling __get_item__ to get an item from the collection from its URI.
- Return type:
Self
- class musify.libraries.local.collection.LocalAlbum(tracks, name=None, remote_wrangler=None)ο
Bases:
LocalCollectionFiltered
[LocalTrack
],Album
[LocalTrack
]Object representing a collection of tracks of an album.
- Parameters:
tracks (
Collection
[LocalTrack
]) β A list of loaded tracks.name (
str
|None
(default:None
)) β The name of this album. If given, the object only stores tracks that match the albumname
given. If None, the list of tracks given are taken to be all the tracks for this album.remote_wrangler (
RemoteDataWrangler
(default:None
)) β Optionally, provide aRemoteDataWrangler
object for processing URIs on tracks. If given, the wrangler can be used when calling __get_item__ to get an item from the collection from its URI.
- Raises:
LocalCollectionError β If the given tracks contain more than one unique value for
album
when name is None.
Attributes:
The most common artist on this album
List of genres ordered by frequency of appearance on the tracks in this collection
A
date
object representing the release date of this album.The most common release year of all tracks on this album
The most common release month of all tracks on this album
The most common release day of all tracks on this album
Album is a compilation if over 50% of tracks are marked as compilation
The images associated with this album in the form
{<image name/type>: <image link>}
Does this album have an image
Average rating of all tracks on this album
- property album_artistο
The most common artist on this album
- property genres: list[str]ο
List of genres ordered by frequency of appearance on the tracks in this collection
- property dateο
A
date
object representing the release date of this album. Determined by the most common release date of all tracks on this album.
- property yearο
The most common release year of all tracks on this album
- property monthο
The most common release month of all tracks on this album
- property dayο
The most common release day of all tracks on this album
- property compilationο
Album is a compilation if over 50% of tracks are marked as compilation
- property image_linksο
The images associated with this album in the form
{<image name/type>: <image link>}
- property has_imageο
Does this album have an image
- property ratingο
Average rating of all tracks on this album
- class musify.libraries.local.collection.LocalArtist(tracks, name=None, remote_wrangler=None)ο
Bases:
LocalCollectionFiltered
[LocalTrack
],Artist
[LocalTrack
]Object representing a collection of tracks by a single artist.
- Parameters:
tracks (
Collection
[LocalTrack
]) β A list of loaded tracks.name (
str
|None
(default:None
)) β The name of this artist. If given, the object only stores tracks that match the artistname
given. If None, the list of tracks given are taken to be all the tracks by this artist.remote_wrangler (
RemoteDataWrangler
(default:None
)) β Optionally, provide aRemoteDataWrangler
object for processing URIs on tracks. If given, the wrangler can be used when calling __get_item__ to get an item from the collection from its URI.
- Raises:
LocalCollectionError β If the given tracks contain more than one unique value for
artist
when name is None.
Attributes:
List of albums ordered by frequency of appearance on the tracks by this artist
List of genres ordered by frequency of appearance on the tracks in this collection
Average rating of all tracks by this artist
- property albumsο
List of albums ordered by frequency of appearance on the tracks by this artist
- property genres: list[str]ο
List of genres ordered by frequency of appearance on the tracks in this collection
- property ratingο
Average rating of all tracks by this artist
- class musify.libraries.local.collection.LocalGenres(tracks, name=None, remote_wrangler=None)ο
Bases:
LocalCollectionFiltered
[LocalTrack
],Genre
[LocalTrack
]Object representing a collection of tracks within a genre.
- Parameters:
tracks (
Collection
[LocalTrack
]) β A list of loaded tracks.name (
str
|None
(default:None
)) β The name of this genre. If given, the object only stores tracks that match the genrename
given. If None, the list of tracks given are taken to be all the tracks within this genre.remote_wrangler (
RemoteDataWrangler
(default:None
)) β Optionally, provide aRemoteDataWrangler
object for processing URIs on tracks. If given, the wrangler can be used when calling __get_item__ to get an item from the collection from its URI.
- Raises:
LocalCollectionError β If the given tracks contain more than one unique value for
genre
when name is None.
Attributes:
List of albums ordered by frequency of appearance on the tracks for this genre
List of related genres ordered by frequency of appearance on the tracks for this genre
- property albumsο
List of albums ordered by frequency of appearance on the tracks for this genre
List of related genres ordered by frequency of appearance on the tracks for this genre