Browse Source

Add icons for music services

Colin Powell 2 năm trước cách đây
mục cha
commit
2811146656

+ 22 - 0
vrobbler/apps/music/models.py

@@ -77,6 +77,16 @@ class Artist(TimeStampedModel):
         img_filename = f"{self.name}_{self.uuid}.jpg"
         self.thumbnail.save(img_filename, File(img_temp))
 
+    @property
+    def rym_link(self):
+        artist_slug = self.name.lower().replace(' ', '-')
+        return f"https://rateyourmusic.com/artist/{artist_slug}/"
+
+    @property
+    def bandcamp_search_link(self):
+        artist = self.name.lower()
+        return f"https://bandcamp.com/search?q={artist}&item_type=b"
+
 
 class Album(TimeStampedModel):
     uuid = models.UUIDField(default=uuid4, editable=False, **BNULL)
@@ -246,6 +256,18 @@ class Album(TimeStampedModel):
             return f"https://www.theaudiodb.com/album/{self.theaudiodb_id}"
         return ""
 
+    @property
+    def rym_link(self):
+        artist_slug = self.primary_artist.name.lower().replace(' ', '-')
+        album_slug = self.name.lower().replace(' ', '-')
+        return f"https://rateyourmusic.com/release/album/{artist_slug}/{album_slug}/"
+
+    @property
+    def bandcamp_search_link(self):
+        artist = self.primary_artist.name.lower()
+        album = self.name.lower()
+        return f"https://bandcamp.com/search?q={album} {artist}&item_type=a"
+
 
 class Track(ScrobblableMixin):
     COMPLETION_PERCENT = getattr(settings, 'MUSIC_COMPLETION_PERCENT', 90)

BIN
vrobbler/apps/scrobbles/static/images/allmusic-logo.png


BIN
vrobbler/apps/scrobbles/static/images/bandcamp-logo.png


BIN
vrobbler/apps/scrobbles/static/images/musicbrainz-logo.png


BIN
vrobbler/apps/scrobbles/static/images/rateyourmusic-logo.jpg


BIN
vrobbler/apps/scrobbles/static/images/theaudiodb-logo.png


+ 8 - 1
vrobbler/templates/music/album_detail.html

@@ -1,5 +1,6 @@
 {% extends "base_list.html" %}
 {% load mathfilters %}
+{% load static %}
 
 {% block title %}{{object.name}}{% endblock %}
 
@@ -17,7 +18,13 @@
         <p>{{object.theaudiodb_description|safe|linebreaks|truncatewords:160}}</p>
         <hr/>
         {% endif %}
-        <p><a href="{{album.mb_link}}">Musicbrainz</a> {% if album.tadb_link %}| <a href="{{album.tadb_link}}">TheAudioDB</a>{% endif %} {% if album.allmusic_link %}| <a href="{{album.allmusic_link}}">AllMusic</a>{% endif %}</p>
+        <p style="float:right;">
+            <a href="{{album.mb_link}}"><img src="{% static "images/musicbrainz-logo.png" %}" width=35></a>
+            <a href="{{album.rym_link}}"><img src="{% static "images/rateyourmusic-logo.jpg" %}" width=35></a>
+            <a href="{{album.bandcamp_search_link}}"><img src="{% static "images/bandcamp-logo.png" %}" width=35></a>
+            {% if album.tadb_link %}<a href="{{album.tadb_link}}"><img src="{% static "images/theaudiodb-logo.png" %}" width=35></a>{% endif %}
+            {% if album.allmusic_link %}<a href="{{album.allmusic_link}}"><img src="{% static "images/allmusic-logo.png" %}" width=35></a>{% endif %}
+        </p>
     </div>
 </div>
 <div class="row">

+ 6 - 1
vrobbler/templates/music/artist_detail.html

@@ -1,5 +1,6 @@
 {% extends "base_list.html" %}
 {% load mathfilters %}
+{% load static %}
 
 {% block title %}{{object.name}}{% endblock %}
 
@@ -22,7 +23,11 @@
         <p>{{artist.biography|safe|linebreaks|truncatewords:160}}</p>
         <hr/>
         {% endif %}
-        <p><a href="{{artist.mb_link}}">Musicbrainz</a></p>
+        <p style="float:right;">
+            <a href="{{artist.mb_link}}"><img src="{% static "images/musicbrainz-logo.png" %}" width=35></a>
+            <a href="{{artist.rym_link}}"><img src="{% static "images/rateyourmusic-logo.jpg" %}" width=35></a>
+            <a href="{{artist.bandcamp_search_link}}"><img src="{% static "images/bandcamp-logo.png" %}" width=35></a>
+        </p>
     </div>
 </div>
 <div class="row">