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}
|
scrobbleinfo = {**rawscrobble}
|
||||||
if fix:
|
if fix:
|
||||||
scrobbleinfo['track_artists'],scrobbleinfo['track_title'] = cla.fullclean(scrobbleinfo['track_artists'],scrobbleinfo['track_title'])
|
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())
|
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)
|
artists = get_artists_of_albums(set(row.id for row in rows),dbconn=dbconn)
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
"artists":artists[row.id],
|
"artists":artists.get(row.id),
|
||||||
"albumtitle":row.albtitle,
|
"albumtitle":row.albtitle,
|
||||||
}
|
}
|
||||||
for row in rows
|
for row in rows
|
||||||
@ -443,7 +443,7 @@ def get_artist_id(artistname,create_new=True,dbconn=None):
|
|||||||
@connection_provider
|
@connection_provider
|
||||||
def get_album_id(albumdict,create_new=True,dbconn=None):
|
def get_album_id(albumdict,create_new=True,dbconn=None):
|
||||||
ntitle = normalize_name(albumdict['albumtitle'])
|
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))
|
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']]
|
title, artists = clean(track['title']), [clean(a) for a in track['artists']]
|
||||||
superfolder = "tracks/"
|
superfolder = "tracks/"
|
||||||
elif album:
|
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/"
|
superfolder = "albums/"
|
||||||
elif artist:
|
elif artist:
|
||||||
artist = clean(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")}
|
filterkeys = {"artist":keys.get("artist")}
|
||||||
if "associated" in keys: filterkeys["associated"] = True
|
if "associated" in keys: filterkeys["associated"] = True
|
||||||
elif type == "album":
|
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:
|
else:
|
||||||
filterkeys = {}
|
filterkeys = {}
|
||||||
|
|
||||||
@ -96,7 +96,7 @@ def internal_to_uri(keys):
|
|||||||
urikeys.append("artist",a)
|
urikeys.append("artist",a)
|
||||||
urikeys.append("title",keys["track"]["title"])
|
urikeys.append("title",keys["track"]["title"])
|
||||||
elif "album" in keys:
|
elif "album" in keys:
|
||||||
for a in keys["album"]["artists"]:
|
for a in keys["album"].get("artists") or []:
|
||||||
urikeys.append("artist",a)
|
urikeys.append("artist",a)
|
||||||
urikeys.append("albumtitle",keys["album"]["albumtitle"])
|
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"),
|
"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),
|
"charts_display_tiles":(tp.Boolean(), "Display Chart Tiles", False),
|
||||||
"display_art_icons":(tp.Boolean(), "Display Album/Artist Icons", True),
|
"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!"),
|
"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),
|
"use_local_images":(tp.Boolean(), "Use Local Images", True),
|
||||||
#"local_image_rotate":(tp.Integer(), "Local Image Rotate", 3600),
|
#"local_image_rotate":(tp.Integer(), "Local Image Rotate", 3600),
|
||||||
|
@ -14,12 +14,12 @@
|
|||||||
|
|
||||||
{% set lastranks = {} %}
|
{% set lastranks = {} %}
|
||||||
{% for t in prevalbums %}
|
{% 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 %}
|
{% endfor %}
|
||||||
|
|
||||||
{% for t in charts %}
|
{% for t in charts %}
|
||||||
{% if "|".join(t.album.artists)+"||"+t.album.albumtitle in lastranks %}
|
{% if "|".join(t.album.artists or [])+"||"+t.album.albumtitle in lastranks %}
|
||||||
{% if t.update({'last_rank':lastranks["|".join(t.album.artists)+"||"+t.album.albumtitle]}) %}{% endif %}
|
{% if t.update({'last_rank':lastranks["|".join(t.album.artists or [])+"||"+t.album.albumtitle]}) %}{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -9,9 +9,13 @@
|
|||||||
{%- endmacro %}
|
{%- endmacro %}
|
||||||
|
|
||||||
{% macro links(entities) -%}
|
{% macro links(entities) -%}
|
||||||
{% for entity in entities -%}
|
{% if entities is none or entities == [] %}
|
||||||
{{ link(entity) }}{{ ", " if not loop.last }}
|
{{ settings["DEFAULT_ALBUM_ARTIST"] }}
|
||||||
{%- endfor %}
|
{% else %}
|
||||||
|
{% for entity in entities -%}
|
||||||
|
{{ link(entity) }}{{ ", " if not loop.last }}
|
||||||
|
{%- endfor %}
|
||||||
|
{% endif %}
|
||||||
{%- endmacro %}
|
{%- endmacro %}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user