1
0
mirror of https://github.com/krateng/maloja.git synced 2023-08-10 21:12:55 +03:00

Moved image handling to top level module

This commit is contained in:
krateng 2022-03-27 20:08:41 +02:00
parent be4ed055ff
commit 9f8e691924
22 changed files with 35 additions and 34 deletions

View File

@ -165,7 +165,6 @@ These solutions allow you to directly setup scrobbling to your Maloja server:
* [Multi Scrobbler](https://github.com/FoxxMD/multi-scrobbler) Desktop Application * [Multi Scrobbler](https://github.com/FoxxMD/multi-scrobbler) Desktop Application
* [Cmus-maloja-scrobbler](https://git.sr.ht/~xyank/cmus-maloja-scrobbler) Script * [Cmus-maloja-scrobbler](https://git.sr.ht/~xyank/cmus-maloja-scrobbler) Script
* [OngakuKiroku](https://github.com/Atelier-Shiori/OngakuKiroku) Desktop Application (Mac) * [OngakuKiroku](https://github.com/Atelier-Shiori/OngakuKiroku) Desktop Application (Mac)
* [Albula](https://github.com/krateng/albula) Music Server
* [Maloja Scrobbler](https://chrome.google.com/webstore/detail/maloja-scrobbler/cfnbifdmgbnaalphodcbandoopgbfeeh) Chromium Extension (also included in the repository) for Plex Web, Spotify, Bandcamp, Soundcloud or Youtube Music * [Maloja Scrobbler](https://chrome.google.com/webstore/detail/maloja-scrobbler/cfnbifdmgbnaalphodcbandoopgbfeeh) Chromium Extension (also included in the repository) for Plex Web, Spotify, Bandcamp, Soundcloud or Youtube Music
### Native API ### Native API

View File

@ -17,7 +17,7 @@ from ..globalconf import malojaconfig, data_dir
from ..__pkginfo__ import VERSION from ..__pkginfo__ import VERSION
from ..malojauri import uri_to_internal, compose_querystring, internal_to_uri from ..malojauri import uri_to_internal, compose_querystring, internal_to_uri
from .. import utilities from .. import images
from ._apikeys import api_key_correct, checkAPIkey from ._apikeys import api_key_correct, checkAPIkey
from . import apikeystore from . import apikeystore
@ -343,7 +343,7 @@ def add_picture(b64,artist:Multi=[],title=None):
if title is not None: keys.append("title",title) if title is not None: keys.append("title",title)
k_filter, _, _, _, _ = uri_to_internal(keys) k_filter, _, _, _, _ = uri_to_internal(keys)
if "track" in k_filter: k_filter = k_filter["track"] if "track" in k_filter: k_filter = k_filter["track"]
utilities.set_image(b64,**k_filter) images.set_image(b64,**k_filter)
@api.post("newrule") @api.post("newrule")

View File

@ -1,5 +1,5 @@
import re import re
#from . import utilities #from . import images
from doreah import tsv from doreah import tsv
from .globalconf import data_dir, malojaconfig from .globalconf import data_dir, malojaconfig

View File

@ -3,7 +3,7 @@ from bottle import request, response, FormsDict, HTTPError
# rest of the project # rest of the project
from ..cleanup import CleanerAgent, CollectorAgent from ..cleanup import CleanerAgent, CollectorAgent
from .. import utilities from .. import images
from ..malojatime import register_scrobbletime, time_stamps, ranges, alltime from ..malojatime import register_scrobbletime, time_stamps, ranges, alltime
from ..malojauri import uri_to_internal, internal_to_uri, compose_querystring from ..malojauri import uri_to_internal, internal_to_uri, compose_querystring
from ..thirdparty import proxy_scrobble_all from ..thirdparty import proxy_scrobble_all

View File

@ -272,8 +272,11 @@ data_directories = {
"clients":pthj(dir_settings['config']), "clients":pthj(dir_settings['config']),
"settings":pthj(dir_settings['config']), "settings":pthj(dir_settings['config']),
"css":pthj(dir_settings['config'],"custom_css"), "css":pthj(dir_settings['config'],"custom_css"),
"logs":pthj(dir_settings['logs']),
"cache":pthj(dir_settings['cache']), "config":dir_settings['config'],
"state":dir_settings['state'],
"logs":dir_settings['logs'],
"cache":dir_settings['cache'],
} }

View File

@ -1,6 +1,6 @@
from ..globalconf import data_dir, malojaconfig from .globalconf import data_dir, malojaconfig
from .. import thirdparty from . import thirdparty
from .. import database from . import database
from doreah import caching from doreah import caching
from doreah.logging import log from doreah.logging import log

View File

@ -1,7 +1,7 @@
from . import filters from . import filters
from ..globalconf import malojaconfig from ..globalconf import malojaconfig
from .. import database, malojatime, utilities, malojauri, thirdparty, __pkginfo__ from .. import database, malojatime, images, malojauri, thirdparty, __pkginfo__
from ..database import jinjaview from ..database import jinjaview
from doreah.regular import repeatdaily from doreah.regular import repeatdaily
@ -28,7 +28,7 @@ def update_jinja_environment():
"db": database, #TODO: move these to connection manager as well "db": database, #TODO: move these to connection manager as well
#"dbp":dbp, #"dbp":dbp,
"malojatime": malojatime, "malojatime": malojatime,
"utilities": utilities, "images": images,
"mlj_uri": malojauri, "mlj_uri": malojauri,
"settings": malojaconfig, "settings": malojaconfig,
"thirdparty": thirdparty, "thirdparty": thirdparty,

View File

@ -7,7 +7,7 @@ from doreah.io import col, ask
from ...globalconf import data_dir from ...globalconf import data_dir
from ...database.sqldb import add_scrobbles from ...database.sqldb import add_scrobbles
#from ...utilities import * #from ...images import *

View File

@ -19,7 +19,7 @@ from doreah import auth
# rest of the project # rest of the project
from . import database from . import database
from .database.jinjaview import JinjaDBConnection from .database.jinjaview import JinjaDBConnection
from .utilities import resolve_track_image, resolve_artist_image from .images import resolve_track_image, resolve_artist_image
from .malojauri import uri_to_internal, remove_identical from .malojauri import uri_to_internal, remove_identical
from .globalconf import malojaconfig, data_dir from .globalconf import malojaconfig, data_dir
from .jinjaenv.context import jinja_environment from .jinjaenv.context import jinja_environment

View File

@ -1 +0,0 @@
from .images import *

View File

@ -39,10 +39,10 @@
{% if adminmode %} {% if adminmode %}
<div <div
class="changeable-image" data-uploader="b64=>upload('{{ encodedartist }}',b64)" class="changeable-image" data-uploader="b64=>upload('{{ encodedartist }}',b64)"
style="background-image:url('{{ utilities.get_artist_image(artist) }}');" style="background-image:url('{{ images.get_artist_image(artist) }}');"
></div> ></div>
{% else %} {% else %}
<div style="background-image:url('{{ utilities.get_artist_image(artist) }}');"> <div style="background-image:url('{{ images.get_artist_image(artist) }}');">
</div> </div>
{% endif %} {% endif %}
</td> </td>

View File

@ -9,7 +9,7 @@
{% set pages = math.ceil(charts.__len__() / amountkeys.perpage) %} {% set pages = math.ceil(charts.__len__() / amountkeys.perpage) %}
{% if charts[0] is defined %} {% if charts[0] is defined %}
{% set topartist = charts[0].artist %} {% set topartist = charts[0].artist %}
{% set img = utilities.get_artist_image(topartist) %} {% set img = images.get_artist_image(topartist) %}
{% else %} {% else %}
{% set img = "/favicon.png" %} {% set img = "/favicon.png" %}
{% endif %} {% endif %}

View File

@ -11,7 +11,7 @@
{% set pages = math.ceil(charts.__len__() / amountkeys.perpage) %} {% set pages = math.ceil(charts.__len__() / amountkeys.perpage) %}
{% if charts[0] is defined %} {% if charts[0] is defined %}
{% set toptrack = charts[0].track %} {% set toptrack = charts[0].track %}
{% set img = utilities.get_track_image(toptrack) %} {% set img = images.get_track_image(toptrack) %}
{% else %} {% else %}
{% set img = "/favicon.png" %} {% set img = "/favicon.png" %}
{% endif %} {% endif %}

View File

@ -23,7 +23,7 @@
{% set rank = entry.rank %} {% set rank = entry.rank %}
<td> <td>
<a href="{{ links.url(artist) }}"> <a href="{{ links.url(artist) }}">
<div style='background-image:url("{{ utilities.get_artist_image(artist) }}")'> <div style='background-image:url("{{ images.get_artist_image(artist) }}")'>
<span class='stats'>#{{ rank }}</span> <span>{{ artist }}</span> <span class='stats'>#{{ rank }}</span> <span>{{ artist }}</span>
</div> </div>
</a> </a>

View File

@ -23,7 +23,7 @@
{% set rank = entry.rank %} {% set rank = entry.rank %}
<td> <td>
<a href="{{ links.url(track) }}"> <a href="{{ links.url(track) }}">
<div style='background-image:url("{{ utilities.get_track_image(track) }}")'> <div style='background-image:url("{{ images.get_track_image(track) }}")'>
<span class='stats'>#{{ rank }}</span> <span>{{ track.title }}</span> <span class='stats'>#{{ rank }}</span> <span>{{ track.title }}</span>
</div> </div>
</a> </a>

View File

@ -4,9 +4,9 @@
{% import 'snippets/filterdescription.jinja' as filterdesc %} {% import 'snippets/filterdescription.jinja' as filterdesc %}
{% if filterkeys.get('track') is not none %} {% if filterkeys.get('track') is not none %}
{% set img = utilities.get_track_image(filterkeys.track) %} {% set img = images.get_track_image(filterkeys.track) %}
{% elif filterkeys.get('artist') is not none %} {% elif filterkeys.get('artist') is not none %}
{% set img = utilities.get_artist_image(filterkeys.artist) %} {% set img = images.get_artist_image(filterkeys.artist) %}
{% else %} {% else %}
{% set img = "/favicon.png" %} {% set img = "/favicon.png" %}
{% endif %} {% endif %}

View File

@ -4,9 +4,9 @@
{% import 'snippets/filterdescription.jinja' as filterdesc %} {% import 'snippets/filterdescription.jinja' as filterdesc %}
{% if filterkeys.get('track') is not none %} {% if filterkeys.get('track') is not none %}
{% set img = utilities.get_track_image(filterkeys.track) %} {% set img = images.get_track_image(filterkeys.track) %}
{% elif filterkeys.get('artist') is not none %} {% elif filterkeys.get('artist') is not none %}
{% set img = utilities.get_artist_image(filterkeys.artist) %} {% set img = images.get_artist_image(filterkeys.artist) %}
{% else %} {% else %}
{% set img = "/favicon.png" %} {% set img = "/favicon.png" %}
{% endif %} {% endif %}

View File

@ -8,11 +8,11 @@
{% set pages = math.ceil(scrobbles.__len__() / amountkeys.perpage) %} {% set pages = math.ceil(scrobbles.__len__() / amountkeys.perpage) %}
{% if filterkeys.get('track') is not none %} {% if filterkeys.get('track') is not none %}
{% set img = utilities.get_track_image(filterkeys.track) %} {% set img = images.get_track_image(filterkeys.track) %}
{% elif filterkeys.get('artist') is not none %} {% elif filterkeys.get('artist') is not none %}
{% set img = utilities.get_artist_image(filterkeys.artist) %} {% set img = images.get_artist_image(filterkeys.artist) %}
{% elif scrobbles.__len__() > 0 %} {% elif scrobbles.__len__() > 0 %}
{% set img = utilities.get_track_image(scrobbles[0].track) %} {% set img = images.get_track_image(scrobbles[0].track) %}
{% else %} {% else %}
{% set img = "/favicon.png" %} {% set img = "/favicon.png" %}
{% endif %} {% endif %}

View File

@ -3,9 +3,9 @@
{% import 'snippets/links.jinja' as links %} {% import 'snippets/links.jinja' as links %}
{% if 'artists' in entity %} {% if 'artists' in entity %}
{% set img = utilities.get_track_image(entity) %} {% set img = images.get_track_image(entity) %}
{% else %} {% else %}
{% set img = utilities.get_artist_image(entity) %} {% set img = images.get_artist_image(entity) %}
{% endif %} {% endif %}
<td class='icon'><div style="background-image:url('{{ img }}')"></div></td> <td class='icon'><div style="background-image:url('{{ img }}')"></div></td>

View File

@ -6,7 +6,7 @@
{% set entries = dbc.get_top_artists(limitkeys,delimitkeys) %} {% set entries = dbc.get_top_artists(limitkeys,delimitkeys) %}
{% set repr = entries | find_representative('artist','scrobbles') %} {% set repr = entries | find_representative('artist','scrobbles') %}
{% set img = "/favicon.png" if repr is none else utilities.get_artist_image(repr.artist) %} {% set img = "/favicon.png" if repr is none else images.get_artist_image(repr.artist) %}
{% block content %} {% block content %}

View File

@ -6,7 +6,7 @@
{% set entries = dbc.get_top_tracks(filterkeys,limitkeys,delimitkeys) %} {% set entries = dbc.get_top_tracks(filterkeys,limitkeys,delimitkeys) %}
{% set repr = entries | find_representative('track','scrobbles') %} {% set repr = entries | find_representative('track','scrobbles') %}
{% set img = "/favicon.png" if repr is none else utilities.get_track_image(repr.track) %} {% set img = "/favicon.png" if repr is none else images.get_track_image(repr.track) %}
{% block content %} {% block content %}

View File

@ -33,10 +33,10 @@
{% if adminmode %} {% if adminmode %}
<div <div
class="changeable-image" data-uploader="b64=>upload('{{ encodedtrack }}',b64)" class="changeable-image" data-uploader="b64=>upload('{{ encodedtrack }}',b64)"
style="background-image:url('{{ utilities.get_track_image(track) }}');" style="background-image:url('{{ images.get_track_image(track) }}');"
></div> ></div>
{% else %} {% else %}
<div style="background-image:url('{{ utilities.get_track_image(track) }}');"> <div style="background-image:url('{{ images.get_track_image(track) }}');">
</div> </div>
{% endif %} {% endif %}
</td> </td>