Skip to content

Commit

Permalink
Fix Album and Artist objects to match specification
Browse files Browse the repository at this point in the history
We were missing several optional fields and had added a non-exitant one
to Albums.

Signed-off-by: Eric B Munson <[email protected]>
  • Loading branch information
khers committed Jan 19, 2024
1 parent 8fcca1c commit 6059fab
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
##5.0.0

Fix Album object to align to open subsonic specification, also update Artist object

##4.0.7

Fix path handling for empty and trailing / cases.
Expand Down
2 changes: 1 addition & 1 deletion src/libopensonic/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@


#Semantic versioning string for the library
__version__ = '4.0.7'
__version__ = '5.0.0'
8 changes: 3 additions & 5 deletions src/libopensonic/media/album.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class AlbumInfo:
def __init__(self, info):
self._notes = get_key(info, 'notes')
self._mb_id = get_key(info, 'musicBrainzId')
self._lastfm_url = get_key(info, 'lastFmUrl')
self._small_url = get_key(info, 'smallImageUrl')
self._med_url = get_key(info, 'mediumImageUrl')
self._large_url = get_key(info, 'largeImageUrl')
Expand All @@ -37,12 +38,11 @@ class Album(MediaBase):
def __init__(self, info):
self._parent = get_key(info, 'parent')
self._album = get_key(info, 'album')
self._title = get_key(info, 'title')
self._name = self.get_required_key(info, 'name')
self._is_dir = get_key(info, 'isDir')
self._song_count = self.get_required_key(info, 'songCount')
self._song_count = int(self.get_required_key(info, 'songCount'))
self._created = self.get_required_key(info, 'created')
self._duration = self.get_required_key(info, 'duration')
self._duration = int(self.get_required_key(info, 'duration'))
self._play_count = get_key(info, 'playCount')
self._artist_id = get_key(info, 'artistId')
self._artist = get_key(info, 'artist')
Expand All @@ -61,7 +61,6 @@ def __init__(self, info):
def to_dict(self):
ret = super().to_dict()
ret['album'] = self._album
ret['title'] = self._title
ret['name'] = self._name
ret['isDir'] = self._is_dir
ret['songCount'] = self._song_count
Expand All @@ -82,7 +81,6 @@ def to_dict(self):

parent = property(lambda s: s._parent)
album = property(lambda s: s._album)
title = property(lambda s: s._title)
name = property(lambda s: s._name)
is_dir = property(lambda s: s._is_dir)
song_count = property(lambda s: s._song_count)
Expand Down
11 changes: 10 additions & 1 deletion src/libopensonic/media/artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def __init__(self, info):
self._small_url = get_key(info, 'smallImageUrl')
self._med_url = get_key(info, 'mediumImageUrl')
self._large_url = get_key(info, 'largeImageUrl')
self._lastfm_url = get_key(info, 'lastFmUrl')
self._similar_artists = []
if 'similarArtists' in info:
for entry in info['similarArtists']:
Expand All @@ -39,7 +40,8 @@ def to_dict(self):
'musicBrainzId': self._mb_id,
'smallImageUrl': self._small_url,
'mediumImageUrl': self._med_url,
'largeImageUrl': self._large_url
'largeImageUrl': self._large_url,
'lastFmUrl': self._lastfm_url
}
if self._similar_artists:
ret['similarArtists'] = [entry.to_dict() for entry in self._similar_artists]
Expand All @@ -50,6 +52,7 @@ def to_dict(self):
small_url = property(lambda s: s._small_url)
med_url = property(lambda s: s._med_url)
large_url = property(lambda s:s._large_url)
lastfm_url = property(lambda s:s._lastfm_url)
similar_artists = property(lambda s:s._similar_artists)


Expand All @@ -69,7 +72,9 @@ def __init__(self, info):
self._album_count = get_key(info, 'albumCount')
self._starred = get_key(info, 'starred')
self._name = self.get_required_key(info, 'name')
self._sort_name = self.get_required_key(info, 'sortName')
self._info = None
self._artist_image_url = get_key(info, 'artistImageUrl')
self._sort_name = get_key(info, 'sortName')
self._roles = get_key(info, 'roles')
self._albums = []
Expand All @@ -82,7 +87,9 @@ def to_dict(self):
ret = super().to_dict()
ret['albumCount'] = self._album_count
ret['starred'] = self._starred
ret['sortName'] = self._sort_name
ret['name'] = self._name
ret['artistImageUrl'] = self._artist_image_url
if self._info is not None:
ret['info'] = self._info.to_dict()
ret['sortName'] = self._sort_name
Expand All @@ -92,8 +99,10 @@ def to_dict(self):
return ret

album_count = property(lambda s: s._album_count)
artist_image_url = property(lambda s: s._artist_image_url)
starred = property(lambda s: s._starred)
name = property(lambda s: s._name)
sort_name = property(lambda s: s._sort_name)
albums = property(lambda s: s._albums)
def set_info(self, info: ArtistInfo):
self._info = info
Expand Down

0 comments on commit 6059fab

Please sign in to comment.