Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5a3eb7a8c8 | |||
| e63ca13d57 | |||
| b3d3098fe0 |
@ -1,6 +1,6 @@
|
|||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "vrobbler"
|
name = "vrobbler"
|
||||||
version = "0.11.10"
|
version = "0.11.11"
|
||||||
description = ""
|
description = ""
|
||||||
authors = ["Colin Powell <colin@unbl.ink>"]
|
authors = ["Colin Powell <colin@unbl.ink>"]
|
||||||
|
|
||||||
|
|||||||
@ -43,24 +43,14 @@ def get_or_create_artist(name: str, mbid: str = None) -> Artist:
|
|||||||
|
|
||||||
def get_or_create_album(name: str, artist: Artist, mbid: str = None) -> Album:
|
def get_or_create_album(name: str, artist: Artist, mbid: str = None) -> Album:
|
||||||
album = None
|
album = None
|
||||||
album_created = False
|
album_dict = lookup_album_dict_from_mb(name, artist_name=artist.name)
|
||||||
albums = Album.objects.filter(name__iexact=name)
|
mbid = mbid or album_dict['mb_id']
|
||||||
if albums.count() == 1:
|
|
||||||
album = albums.first()
|
|
||||||
else:
|
|
||||||
for potential_album in albums:
|
|
||||||
if artist in album.artist_set.all():
|
|
||||||
album = potential_album
|
|
||||||
if not album:
|
|
||||||
album_created = True
|
|
||||||
album = Album.objects.create(name=name, musicbrainz_id=mbid)
|
|
||||||
album.save()
|
|
||||||
album.artists.add(artist)
|
|
||||||
|
|
||||||
if album_created or not mbid:
|
logger.debug(f'Looking up album {name} and mbid: {mbid}')
|
||||||
album_dict = lookup_album_dict_from_mb(
|
|
||||||
album.name, artist_name=artist.name
|
album = Album.objects.filter(musicbrainz_id=mbid).first()
|
||||||
)
|
if not album:
|
||||||
|
album = Album.objects.create(name=name, musicbrainz_id=mbid)
|
||||||
album.year = album_dict["year"]
|
album.year = album_dict["year"]
|
||||||
album.musicbrainz_id = album_dict["mb_id"]
|
album.musicbrainz_id = album_dict["mb_id"]
|
||||||
album.musicbrainz_releasegroup_id = album_dict["mb_group_id"]
|
album.musicbrainz_releasegroup_id = album_dict["mb_group_id"]
|
||||||
@ -75,6 +65,7 @@ def get_or_create_album(name: str, artist: Artist, mbid: str = None) -> Album:
|
|||||||
)
|
)
|
||||||
album.artists.add(artist)
|
album.artists.add(artist)
|
||||||
album.fetch_artwork()
|
album.fetch_artwork()
|
||||||
|
|
||||||
return album
|
return album
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -475,20 +475,39 @@ class ChartRecordView(TemplateView):
|
|||||||
context_data["artist_charts"] = {}
|
context_data["artist_charts"] = {}
|
||||||
|
|
||||||
if not date:
|
if not date:
|
||||||
|
limit = 20
|
||||||
artist_params = {'user': user, 'media_type': 'Artist'}
|
artist_params = {'user': user, 'media_type': 'Artist'}
|
||||||
context_data['current_artist_charts'] = {
|
context_data['current_artist_charts'] = {
|
||||||
"today": live_charts(**artist_params, chart_period="today"),
|
"today": live_charts(
|
||||||
"week": live_charts(**artist_params, chart_period="week"),
|
**artist_params, chart_period="today", limit=limit
|
||||||
"month": live_charts(**artist_params, chart_period="month"),
|
),
|
||||||
"all": live_charts(**artist_params),
|
"week": live_charts(
|
||||||
|
**artist_params, chart_period="week", limit=limit
|
||||||
|
),
|
||||||
|
"month": live_charts(
|
||||||
|
**artist_params, chart_period="month", limit=limit
|
||||||
|
),
|
||||||
|
"year": live_charts(
|
||||||
|
**artist_params, chart_period="year", limit=limit
|
||||||
|
),
|
||||||
|
"all": live_charts(**artist_params, limit=limit),
|
||||||
}
|
}
|
||||||
|
|
||||||
track_params = {'user': user, 'media_type': 'Track'}
|
track_params = {'user': user, 'media_type': 'Track'}
|
||||||
context_data['current_track_charts'] = {
|
context_data['current_track_charts'] = {
|
||||||
"today": live_charts(**track_params, chart_period="today"),
|
"today": live_charts(
|
||||||
"week": live_charts(**track_params, chart_period="week"),
|
**track_params, chart_period="today", limit=limit
|
||||||
"month": live_charts(**track_params, chart_period="month"),
|
),
|
||||||
"all": live_charts(**track_params),
|
"week": live_charts(
|
||||||
|
**track_params, chart_period="week", limit=limit
|
||||||
|
),
|
||||||
|
"month": live_charts(
|
||||||
|
**track_params, chart_period="month", limit=limit
|
||||||
|
),
|
||||||
|
"year": live_charts(
|
||||||
|
**track_params, chart_period="year", limit=limit
|
||||||
|
),
|
||||||
|
"all": live_charts(**track_params, limit=limit),
|
||||||
}
|
}
|
||||||
return context_data
|
return context_data
|
||||||
|
|
||||||
|
|||||||
@ -67,7 +67,7 @@
|
|||||||
<li class="nav-item" role="presentation">
|
<li class="nav-item" role="presentation">
|
||||||
<button class="nav-link {% if forloop.first %}active{% endif %}" id="artist-{{chart_name}}-tab" data-bs-toggle="tab" data-bs-target="#artist-{{chart_name}}"
|
<button class="nav-link {% if forloop.first %}active{% endif %}" id="artist-{{chart_name}}-tab" data-bs-toggle="tab" data-bs-target="#artist-{{chart_name}}"
|
||||||
type="button" role="tab" aria-controls="home" aria-selected="true">
|
type="button" role="tab" aria-controls="home" aria-selected="true">
|
||||||
{{chart_name}}
|
{% if chart_name == "all" %}All Time{% else %}{% if chart_name != "today" %}This {% endif %}{{chart_name|capfirst}}{% endif %}
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
@ -110,7 +110,7 @@
|
|||||||
<li class="nav-item" role="presentation">
|
<li class="nav-item" role="presentation">
|
||||||
<button class="nav-link {% if forloop.first %}active{% endif %}" id="track-{{chart_name}}-tab" data-bs-toggle="tab" data-bs-target="#track-{{chart_name}}"
|
<button class="nav-link {% if forloop.first %}active{% endif %}" id="track-{{chart_name}}-tab" data-bs-toggle="tab" data-bs-target="#track-{{chart_name}}"
|
||||||
type="button" role="tab" aria-controls="home" aria-selected="true">
|
type="button" role="tab" aria-controls="home" aria-selected="true">
|
||||||
{{chart_name}}
|
{% if chart_name == "all" %}All Time{% else %}{% if chart_name != "today" %}This {% endif %}{{chart_name|capfirst}}{% endif %}
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|||||||
@ -88,7 +88,7 @@
|
|||||||
<ul class="nav nav-tabs" id="artistTab" role="tablist">
|
<ul class="nav nav-tabs" id="artistTab" role="tablist">
|
||||||
{% for chart_name in current_artist_charts.keys %}
|
{% for chart_name in current_artist_charts.keys %}
|
||||||
<li class="nav-item" role="presentation">
|
<li class="nav-item" role="presentation">
|
||||||
<button class="nav-link {% if forloop.first %}active{% endif %}"
|
<button class="nav-link {% if forloop.counter == 2 %}active{% endif %}"
|
||||||
id="artist-{{chart_name}}-tab" data-bs-toggle="tab" data-bs-target="#artist-{{chart_name}}"
|
id="artist-{{chart_name}}-tab" data-bs-toggle="tab" data-bs-target="#artist-{{chart_name}}"
|
||||||
type="button" role="tab" aria-controls="home" aria-selected="true">
|
type="button" role="tab" aria-controls="home" aria-selected="true">
|
||||||
{% if chart_name == "all" %}All Time{% else %}{% if chart_name != "today" %}This {% endif %}{{chart_name|capfirst}}{% endif %}
|
{% if chart_name == "all" %}All Time{% else %}{% if chart_name != "today" %}This {% endif %}{{chart_name|capfirst}}{% endif %}
|
||||||
@ -99,7 +99,7 @@
|
|||||||
|
|
||||||
<div class="tab-content" id="artistTabContent" class="maloja-chart">
|
<div class="tab-content" id="artistTabContent" class="maloja-chart">
|
||||||
{% for chart_name, artists in current_artist_charts.items %}
|
{% for chart_name, artists in current_artist_charts.items %}
|
||||||
<div class="tab-pane fade {% if forloop.first %}show active{% endif %}" id="artist-{{chart_name}}" role="tabpanel" aria-labelledby="artist-{{chart_name}}-tab">
|
<div class="tab-pane fade {% if forloop.counter == 2 %}show active{% endif %}" id="artist-{{chart_name}}" role="tabpanel" aria-labelledby="artist-{{chart_name}}-tab">
|
||||||
<div style="display:block">
|
<div style="display:block">
|
||||||
<div style="float:left;">
|
<div style="float:left;">
|
||||||
<div class="image-wrapper" style="display:flex; flex-wrap: wrap; margin:0">
|
<div class="image-wrapper" style="display:flex; flex-wrap: wrap; margin:0">
|
||||||
@ -208,7 +208,7 @@
|
|||||||
<div class="image-wrapper" class="image-wrapper" style="width:33;">
|
<div class="image-wrapper" class="image-wrapper" style="width:33;">
|
||||||
<div class="caption-small">#13 {{artists.12.name}}</div>
|
<div class="caption-small">#13 {{artists.12.name}}</div>
|
||||||
{% if artists.12thumbnail %}
|
{% if artists.12thumbnail %}
|
||||||
<a href="{{artists.12.get_absolute_url}}"><img lt="{{artists.13.name}}" src="{{artists.12.thumbnail.url}}" width="100px"></a>
|
<a href="{{artists.12.get_absolute_url}}"><img lt="{{artists.12.name}}" src="{{artists.12.thumbnail.url}}" width="100px"></a>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a href="{{artists.12.get_absolute_url}}"><img lt="{{artists.12.name}}" src="{% static "images/artist-placeholder.jpg" %}" width="100px"></a>
|
<a href="{{artists.12.get_absolute_url}}"><img lt="{{artists.12.name}}" src="{% static "images/artist-placeholder.jpg" %}" width="100px"></a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -234,7 +234,7 @@
|
|||||||
<ul class="nav nav-tabs" id="trackTab" role="tablist">
|
<ul class="nav nav-tabs" id="trackTab" role="tablist">
|
||||||
{% for chart_name in current_track_charts.keys %}
|
{% for chart_name in current_track_charts.keys %}
|
||||||
<li class="nav-item" role="presentation">
|
<li class="nav-item" role="presentation">
|
||||||
<button class="nav-link {% if forloop.first %}active{% endif %}" id="track-{{chart_name}}-tab" data-bs-toggle="tab"
|
<button class="nav-link {% if forloop.counter == 2 %}active{% endif %}" id="track-{{chart_name}}-tab" data-bs-toggle="tab"
|
||||||
data-bs-target="#track-{{chart_name}}" type="button" role="tab" aria-controls="home" aria-selected="true">
|
data-bs-target="#track-{{chart_name}}" type="button" role="tab" aria-controls="home" aria-selected="true">
|
||||||
{% if chart_name == "all" %}All Time{% else %}{% if chart_name != "today" %}This {% endif %}{{chart_name|capfirst}}{% endif %}
|
{% if chart_name == "all" %}All Time{% else %}{% if chart_name != "today" %}This {% endif %}{{chart_name|capfirst}}{% endif %}
|
||||||
</button>
|
</button>
|
||||||
@ -244,7 +244,7 @@
|
|||||||
|
|
||||||
<div class="tab-content" id="trackTabContent" class="maloja-chart">
|
<div class="tab-content" id="trackTabContent" class="maloja-chart">
|
||||||
{% for chart_name, tracks in current_track_charts.items %}
|
{% for chart_name, tracks in current_track_charts.items %}
|
||||||
<div class="tab-pane fade {% if forloop.first %}show active{% endif %}" id="track-{{chart_name}}" role="tabpanel" aria-labelledby="track-{{chart_name}}-tab">
|
<div class="tab-pane fade {% if forloop.counter == 2 %}show active{% endif %}" id="track-{{chart_name}}" role="tabpanel" aria-labelledby="track-{{chart_name}}-tab">
|
||||||
<div style="display:block">
|
<div style="display:block">
|
||||||
<div style="float:left;">
|
<div style="float:left;">
|
||||||
<div class="image-wrapper" style="display:flex; flex-wrap: wrap; margin:0">
|
<div class="image-wrapper" style="display:flex; flex-wrap: wrap; margin:0">
|
||||||
@ -313,7 +313,7 @@
|
|||||||
<div class="image-wrapper" class="image-wrapper" style="width:33;">
|
<div class="image-wrapper" class="image-wrapper" style="width:33;">
|
||||||
<div class="caption-small">#8 {{tracks.7.title}}</div>
|
<div class="caption-small">#8 {{tracks.7.title}}</div>
|
||||||
{% if tracks.7.album.cover_image %}
|
{% if tracks.7.album.cover_image %}
|
||||||
<a href="{{track.7.get_absolute_url}}"><img lt="{{tracks.7.title}}" src="{{tracks.7.album.cover_image.url}}" width="100px"></a>
|
<a href="{{tracks.7.get_absolute_url}}"><img lt="{{tracks.7.title}}" src="{{tracks.7.album.cover_image.url}}" width="100px"></a>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a href="{{tracks.7.get_absolute_url}}"><img lt="{{tracks.7.title}}" src="{% static 'images/track-placeholder.jpg' %}" width="100px"></a>
|
<a href="{{tracks.7.get_absolute_url}}"><img lt="{{tracks.7.title}}" src="{% static 'images/track-placeholder.jpg' %}" width="100px"></a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -321,7 +321,7 @@
|
|||||||
<div class="image-wrapper" class="image-wrapper" style="width:33;">
|
<div class="image-wrapper" class="image-wrapper" style="width:33;">
|
||||||
<div class="caption-small">#9 {{tracks.8.title}}</div>
|
<div class="caption-small">#9 {{tracks.8.title}}</div>
|
||||||
{% if tracks.8.album.cover_image %}
|
{% if tracks.8.album.cover_image %}
|
||||||
<a href="{{track.8.get_absolute_url}}"><img lt="{{tracks.8.title}}" src="{{tracks.8.album.cover_image.url}}" width="100px"></a>
|
<a href="{{tracks.8.get_absolute_url}}"><img lt="{{tracks.8.title}}" src="{{tracks.8.album.cover_image.url}}" width="100px"></a>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a href="{{tracks.8.get_absolute_url}}"><img lt="{{tracks.8.title}}" src="{% static 'images/track-placeholder.jpg' %}" width="100px"></a>
|
<a href="{{tracks.8.get_absolute_url}}"><img lt="{{tracks.8.title}}" src="{% static 'images/track-placeholder.jpg' %}" width="100px"></a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -329,7 +329,7 @@
|
|||||||
<div class="image-wrapper" class="image-wrapper" style="width:33;">
|
<div class="image-wrapper" class="image-wrapper" style="width:33;">
|
||||||
<div class="caption-small">#10 {{tracks.9.title}}</div>
|
<div class="caption-small">#10 {{tracks.9.title}}</div>
|
||||||
{% if tracks.9.album.cover_image %}
|
{% if tracks.9.album.cover_image %}
|
||||||
<a href="{{track.9.get_absolute_url}}"><img lt="{{tracks.9.title}}" src="{{tracks.9.album.cover_image.url}}" width="100px"></a>
|
<a href="{{tracks.9.get_absolute_url}}"><img lt="{{tracks.9.title}}" src="{{tracks.9.album.cover_image.url}}" width="100px"></a>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a href="{{tracks.9.get_absolute_url}}"><img lt="{{tracks.9.title}}" src="{% static 'images/track-placeholder.jpg' %}" width="100px"></a>
|
<a href="{{tracks.9.get_absolute_url}}"><img lt="{{tracks.9.title}}" src="{% static 'images/track-placeholder.jpg' %}" width="100px"></a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -345,7 +345,7 @@
|
|||||||
<div class="image-wrapper" class="image-wrapper" style="width:33;">
|
<div class="image-wrapper" class="image-wrapper" style="width:33;">
|
||||||
<div class="caption-small">#12 {{tracks.11.title}}</div>
|
<div class="caption-small">#12 {{tracks.11.title}}</div>
|
||||||
{% if tracks.11.album.cover_image %}
|
{% if tracks.11.album.cover_image %}
|
||||||
<a href="{{track.11.get_absolute_url}}"><img lt="{{tracks.11.title}}" src="{{tracks.11.album.cover_image.url}}" width="100px"></a>
|
<a href="{{tracks.11.get_absolute_url}}"><img lt="{{tracks.11.title}}" src="{{tracks.11.album.cover_image.url}}" width="100px"></a>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a href="{{tracks.11.get_absolute_url}}"><img lt="{{tracks.11.title}}" src="{% static 'images/track-placeholder.jpg' %}" width="100px"></a>
|
<a href="{{tracks.11.get_absolute_url}}"><img lt="{{tracks.11.title}}" src="{% static 'images/track-placeholder.jpg' %}" width="100px"></a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -353,7 +353,7 @@
|
|||||||
<div class="image-wrapper" class="image-wrapper" style="width:33;">
|
<div class="image-wrapper" class="image-wrapper" style="width:33;">
|
||||||
<div class="caption-small">#13 {{tracks.12.title}}</div>
|
<div class="caption-small">#13 {{tracks.12.title}}</div>
|
||||||
{% if tracks.12.album.cover_image %}
|
{% if tracks.12.album.cover_image %}
|
||||||
<a href="{{track.12.get_absolute_url}}"><img lt="{{tracks.12.title}}" src="{{tracks.12.album.cover_image.url}}" width="100px"></a>
|
<a href="{{tracks.12.get_absolute_url}}"><img lt="{{tracks.12.title}}" src="{{tracks.12.album.cover_image.url}}" width="100px"></a>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a href="{{tracks.12.get_absolute_url}}"><img lt="{{tracks.12.title}}" src="{% static 'images/track-placeholder.jpg' %}" width="100px"></a>
|
<a href="{{tracks.12.get_absolute_url}}"><img lt="{{tracks.12.title}}" src="{% static 'images/track-placeholder.jpg' %}" width="100px"></a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -361,7 +361,7 @@
|
|||||||
<div class="image-wrapper" class="image-wrapper" style="width:33;">
|
<div class="image-wrapper" class="image-wrapper" style="width:33;">
|
||||||
<div class="caption-small">#14 {{tracks.13.title}}</div>
|
<div class="caption-small">#14 {{tracks.13.title}}</div>
|
||||||
{% if tracks.13.album.cover_image %}
|
{% if tracks.13.album.cover_image %}
|
||||||
<a href="{{track.13.get_absolute_url}}"><img lt="{{tracks.13.title}}" src="{{tracks.13.album.cover_image.url}}" width="100px"></a>
|
<a href="{{tracks.13.get_absolute_url}}"><img lt="{{tracks.13.title}}" src="{{tracks.13.album.cover_image.url}}" width="100px"></a>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a href="{{tracks.13.get_absolute_url}}"><img lt="{{tracks.13.title}}" src="{% static 'images/track-placeholder.jpg' %}" width="100px"></a>
|
<a href="{{tracks.13.get_absolute_url}}"><img lt="{{tracks.13.title}}" src="{% static 'images/track-placeholder.jpg' %}" width="100px"></a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
Reference in New Issue
Block a user