From 131fc379c34f4c25588bdbe75186e2b28be9137f Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Wed, 15 Mar 2023 12:51:33 -0400 Subject: [PATCH] Keep fixing primary artists issues --- tests/scrobbles_tests/test_views.py | 1 - vrobbler/apps/music/models.py | 20 ++++---- vrobbler/apps/scrobbles/export.py | 2 +- vrobbler/templates/music/album_list.html | 58 ++++++++++++------------ 4 files changed, 39 insertions(+), 42 deletions(-) diff --git a/tests/scrobbles_tests/test_views.py b/tests/scrobbles_tests/test_views.py index 9022184..c2ab42a 100644 --- a/tests/scrobbles_tests/test_views.py +++ b/tests/scrobbles_tests/test_views.py @@ -72,7 +72,6 @@ def test_scrobble_mopidy_same_track_different_album( content_type="application/json", ) - print(response.data) assert response.status_code == 200 assert response.data == {"scrobble_id": 2} scrobble = Scrobble.objects.last() diff --git a/vrobbler/apps/music/models.py b/vrobbler/apps/music/models.py index 70c8f6c..1803f64 100644 --- a/vrobbler/apps/music/models.py +++ b/vrobbler/apps/music/models.py @@ -193,7 +193,7 @@ class Album(TimeStampedModel): slug = get_allmusic_slug(self.name, self.album_artist.name) if not slug: logger.info( - f"No allmsuic link for {self} by {self.primary_artist}" + f"No allmsuic link for {self} by {self.album_artist}" ) return self.allmusic_id = slug @@ -202,9 +202,7 @@ class Album(TimeStampedModel): allmusic_data = scrape_data_from_allmusic(self.allmusic_link) if not allmusic_data: - logger.info( - f"No allmsuic data for {self} by {self.primary_artist}" - ) + logger.info(f"No allmsuic data for {self} by {self.album_artist}") return self.allmusic_review = allmusic_data["review"] @@ -213,8 +211,8 @@ class Album(TimeStampedModel): def scrape_theaudiodb(self) -> None: artist = "Various Artists" - if self.primary_artist: - artist = self.primary_artist.name + if self.album_artist: + artist = self.album_artist.name album_data = lookup_album_from_tadb(self.name, artist) if not album_data.get("theaudiodb_id"): logger.info(f"No data for {self} found in TheAudioDB") @@ -224,7 +222,7 @@ class Album(TimeStampedModel): def scrape_bandcamp(self, force=False) -> None: if not self.bandcamp_id or force: - slug = get_bandcamp_slug(self.primary_artist.name, self.name) + slug = get_bandcamp_slug(self.album_artist.name, self.name) if not slug: logger.info(f"No bandcamp link for {self}") return @@ -342,19 +340,19 @@ class Album(TimeStampedModel): @property def rym_link(self): - artist_slug = self.primary_artist.name.lower().replace(" ", "-") + artist_slug = self.album_artist.name.lower().replace(" ", "-") album_slug = self.name.lower().replace(" ", "-") return f"https://rateyourmusic.com/release/album/{artist_slug}/{album_slug}/" @property def bandcamp_link(self): - if self.bandcamp_id and self.primary_artist.bandcamp_id: - return f"https://{self.primary_artist.bandcamp_id}.bandcamp.com/album/{self.bandcamp_id}" + if self.bandcamp_id and self.album_artist.bandcamp_id: + return f"https://{self.album_artist.bandcamp_id}.bandcamp.com/album/{self.bandcamp_id}" return "" @property def bandcamp_search_link(self): - artist = self.primary_artist.name.lower() + artist = self.album_artist.name.lower() album = self.name.lower() return f"https://bandcamp.com/search?q={album} {artist}&item_type=a" diff --git a/vrobbler/apps/scrobbles/export.py b/vrobbler/apps/scrobbles/export.py index 05116e1..c5fb81c 100644 --- a/vrobbler/apps/scrobbles/export.py +++ b/vrobbler/apps/scrobbles/export.py @@ -52,7 +52,7 @@ def export_scrobbles(start_date=None, end_date=None, format="AS"): track = scrobble.track track_number = 0 # TODO Add track number track_rating = "S" # TODO implement ratings? - track_artist = track.artist or track.album.primary_artist + track_artist = track.artist or track.album.album_artist row = [ track_artist, track.album.name, diff --git a/vrobbler/templates/music/album_list.html b/vrobbler/templates/music/album_list.html index e24d105..f19070a 100644 --- a/vrobbler/templates/music/album_list.html +++ b/vrobbler/templates/music/album_list.html @@ -9,22 +9,22 @@

{% if view == 'grid' %} - View as List + View as List {% else %} - View as Grid + View as Grid {% endif %}

{% if page_obj.has_previous %} - prev + prev {% endif %} - - Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }} - + + Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }} + {% if page_obj.has_next %} - next + next {% endif %}

@@ -44,22 +44,22 @@
- - - - - - - - - {% for album in object_list %} - - - - - - {% endfor %} - + + + + + + + + + {% for album in object_list %} + + + + + + {% endfor %} +
ScrobblesAlbumArtist
{{album.scrobbles.count}}{{album}}{{album.primary_artist}}
ScrobblesAlbumArtist
{{album.scrobbles.count}}{{album}}{{album.album_artist}}
@@ -68,15 +68,15 @@ -{% endblock %} +{% endblock %} \ No newline at end of file