Skip to content

Commit

Permalink
RemoteCollectionLoader inherits from MusifyItem
Browse files Browse the repository at this point in the history
  • Loading branch information
geo-martino committed Jun 29, 2024
1 parent 4b624b3 commit f812954
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
6 changes: 6 additions & 0 deletions docs/release-history.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Release History
The format is based on `Keep a Changelog <https://keepachangelog.com/en>`_,
and this project adheres to `Semantic Versioning <https://semver.org/spec/v2.0.0.html>`_


1.1.0
=====

Expand All @@ -39,6 +40,9 @@ Changed
* :py:class:`.ItemDownloadHelper` only ever takes the first field when the singular name of a field is given
and many values are available for that field. e.g. only ever takes the first artist when multiple artists are present
and the requested field is 'artist' and not 'artists'
* :py:class:`.RemoteCollectionLoader` now inherits from :py:class:`.MusifyItem` interface.
The class already implemented all necessary methods for this interface and was always designed
to be an implementation of the :py:class:`.MusifyItem` interface.


1.0.2
Expand Down Expand Up @@ -72,6 +76,7 @@ Documentation
-------------
* Mark release as stable/production.


1.0.0
=====

Expand Down Expand Up @@ -183,6 +188,7 @@ Documentation
* Updated how-to section to reflect implementation of async logic to underlying code
* Created a how-to page for installation


0.9.2
=====

Expand Down
2 changes: 1 addition & 1 deletion musify/libraries/remote/core/object.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class RemoteCollection[T: RemoteObject](MusifyCollection[T], metaclass=ABCMeta):
__attributes_ignore__ = ("items", "track_total")


class RemoteCollectionLoader[T: RemoteObject](RemoteCollection[T], RemoteObject, metaclass=ABCMeta):
class RemoteCollectionLoader[T: RemoteObject](RemoteCollection[T], RemoteItem, metaclass=ABCMeta):
"""Generic class for storing a collection of remote objects that can be loaded from an API response."""

__slots__ = ()
Expand Down
9 changes: 6 additions & 3 deletions musify/processors/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from urllib.parse import quote
from webbrowser import open as webopen

from musify.base import MusifyItem
from musify.base import MusifyItem, MusifyObject
from musify.exception import MusifyEnumError
from musify.field import Field, Fields
from musify.libraries.core.collection import MusifyCollection
Expand Down Expand Up @@ -76,8 +76,11 @@ def _open_sites_for_item(self, item: MusifyItem, fields: Iterable[Field]) -> boo

if isinstance((value_many := getattr(item, field_name + "s", None)), (list, tuple)):
value = next(iter(value_many))
if isinstance(value, (tuple, set, list, dict)):
value = " ".join(value)

if isinstance(value, MusifyObject):
value = value.name
elif isinstance(value, (tuple, set, list, dict)):
value = " ".join(v.name if isinstance(v, MusifyObject) else v for v in value)

query_parts.append(str(value))

Expand Down

0 comments on commit f812954

Please sign in to comment.