mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Improved support for artistless albums
This commit is contained in:
parent
add7991604
commit
4d1f810e92
@ -132,7 +132,8 @@ def rawscrobble_to_scrobbledict(rawscrobble, fix=True, client=None):
|
||||
scrobbleinfo = {**rawscrobble}
|
||||
if fix:
|
||||
scrobbleinfo['track_artists'],scrobbleinfo['track_title'] = cla.fullclean(scrobbleinfo['track_artists'],scrobbleinfo['track_title'])
|
||||
scrobbleinfo['album_artists'] = cla.parseArtists(scrobbleinfo['album_artists'])
|
||||
if scrobbleinfo.get('album_artists'):
|
||||
scrobbleinfo['album_artists'] = cla.parseArtists(scrobbleinfo['album_artists'])
|
||||
scrobbleinfo['scrobble_time'] = scrobbleinfo.get('scrobble_time') or int(datetime.datetime.now(tz=datetime.timezone.utc).timestamp())
|
||||
|
||||
|
||||
|
@ -240,7 +240,7 @@ def albums_db_to_dict(rows,dbconn=None):
|
||||
artists = get_artists_of_albums(set(row.id for row in rows),dbconn=dbconn)
|
||||
return [
|
||||
{
|
||||
"artists":artists[row.id],
|
||||
"artists":artists.get(row.id),
|
||||
"albumtitle":row.albtitle,
|
||||
}
|
||||
for row in rows
|
||||
@ -443,7 +443,7 @@ def get_artist_id(artistname,create_new=True,dbconn=None):
|
||||
@connection_provider
|
||||
def get_album_id(albumdict,create_new=True,dbconn=None):
|
||||
ntitle = normalize_name(albumdict['albumtitle'])
|
||||
artist_ids = [get_artist_id(a,dbconn=dbconn) for a in albumdict['artists']]
|
||||
artist_ids = [get_artist_id(a,dbconn=dbconn) for a in albumdict.get('artists') or []]
|
||||
artist_ids = list(set(artist_ids))
|
||||
|
||||
|
||||
|
@ -226,7 +226,7 @@ def get_all_possible_filenames(artist=None,track=None,album=None):
|
||||
title, artists = clean(track['title']), [clean(a) for a in track['artists']]
|
||||
superfolder = "tracks/"
|
||||
elif album:
|
||||
title, artists = clean(album['albumtitle']), [clean(a) for a in album['artists']]
|
||||
title, artists = clean(album['albumtitle']), [clean(a) for a in album.get('artists') or []]
|
||||
superfolder = "albums/"
|
||||
elif artist:
|
||||
artist = clean(artist)
|
||||
|
@ -28,7 +28,7 @@ def uri_to_internal(keys,forceTrack=False,forceArtist=False,forceAlbum=False,api
|
||||
filterkeys = {"artist":keys.get("artist")}
|
||||
if "associated" in keys: filterkeys["associated"] = True
|
||||
elif type == "album":
|
||||
filterkeys = {"album":{"artists":keys.getall("artist"),"albumtitle":keys.get("title") or keys.get("albumtitle")}}
|
||||
filterkeys = {"album":{"artists":keys.getall("artist"),"albumtitle":keys.get("albumtitle") or keys.get("title")}}
|
||||
else:
|
||||
filterkeys = {}
|
||||
|
||||
@ -96,7 +96,7 @@ def internal_to_uri(keys):
|
||||
urikeys.append("artist",a)
|
||||
urikeys.append("title",keys["track"]["title"])
|
||||
elif "album" in keys:
|
||||
for a in keys["album"]["artists"]:
|
||||
for a in keys["album"].get("artists") or []:
|
||||
urikeys.append("artist",a)
|
||||
urikeys.append("albumtitle",keys["album"]["albumtitle"])
|
||||
|
||||
|
@ -192,6 +192,7 @@ malojaconfig = Configuration(
|
||||
"default_step_pulse":(tp.Choice({'year':'Year','month':"Month",'week':'Week','day':'Day'}), "Default Pulse Step", "month"),
|
||||
"charts_display_tiles":(tp.Boolean(), "Display Chart Tiles", False),
|
||||
"display_art_icons":(tp.Boolean(), "Display Album/Artist Icons", True),
|
||||
"default_album_artist":(tp.String(), "Default Albumartist", "Various Artists"),
|
||||
"discourage_cpu_heavy_stats":(tp.Boolean(), "Discourage CPU-heavy stats", False, "Prevent visitors from mindlessly clicking on CPU-heavy options. Does not actually disable them for malicious actors!"),
|
||||
"use_local_images":(tp.Boolean(), "Use Local Images", True),
|
||||
#"local_image_rotate":(tp.Integer(), "Local Image Rotate", 3600),
|
||||
|
@ -14,12 +14,12 @@
|
||||
|
||||
{% set lastranks = {} %}
|
||||
{% for t in prevalbums %}
|
||||
{% if lastranks.update({"|".join(t.album.artists)+"||"+t.album.albumtitle:t.rank}) %}{% endif %}
|
||||
{% if lastranks.update({"|".join(t.album.artists or [])+"||"+t.album.albumtitle:t.rank}) %}{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{% for t in charts %}
|
||||
{% if "|".join(t.album.artists)+"||"+t.album.albumtitle in lastranks %}
|
||||
{% if t.update({'last_rank':lastranks["|".join(t.album.artists)+"||"+t.album.albumtitle]}) %}{% endif %}
|
||||
{% if "|".join(t.album.artists or [])+"||"+t.album.albumtitle in lastranks %}
|
||||
{% if t.update({'last_rank':lastranks["|".join(t.album.artists or [])+"||"+t.album.albumtitle]}) %}{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
@ -9,9 +9,13 @@
|
||||
{%- endmacro %}
|
||||
|
||||
{% macro links(entities) -%}
|
||||
{% for entity in entities -%}
|
||||
{{ link(entity) }}{{ ", " if not loop.last }}
|
||||
{%- endfor %}
|
||||
{% if entities is none or entities == [] %}
|
||||
{{ settings["DEFAULT_ALBUM_ARTIST"] }}
|
||||
{% else %}
|
||||
{% for entity in entities -%}
|
||||
{{ link(entity) }}{{ ", " if not loop.last }}
|
||||
{%- endfor %}
|
||||
{% endif %}
|
||||
{%- endmacro %}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user