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

Compare commits

..

No commits in common. "4cffc9971d19b7fee51ead4a016ab0ab3aaab6d6" and "d018a758c06cd3a2ff1941f5a967b9ed69712104" have entirely different histories.

13 changed files with 24 additions and 61 deletions

2
.github/FUNDING.yml vendored
View File

@ -1 +1 @@
custom: ["https://flattr.com/@Krateng", "https://paypal.me/krateng"]
custom: ["https://flattr.com/@Krateng", "https://paypal.me/krateng", "bitcoin:1krat8JMniJBTiHftMfR1LtF3Y1w5DAxx"]

View File

@ -151,13 +151,14 @@ def main(*args,**kwargs):
if "version" in kwargs:
print(info.VERSION)
return True
else:
try:
action, *args = args
action = actions[action]
except (ValueError, KeyError):
print("Valid commands: " + " ".join(a for a in actions))
return False
return
return action(*args,**kwargs)
return True

View File

@ -4,7 +4,7 @@
# you know what f*ck it
# this is hardcoded for now because of that damn project / package name discrepancy
# i'll fix it one day
VERSION = "3.0.2"
VERSION = "3.0.0"
HOMEPAGE = "https://github.com/krateng/maloja"

View File

@ -1,5 +1,4 @@
import os
import math
from bottle import response, static_file, request, FormsDict

View File

@ -46,7 +46,7 @@ class DatabaseNotBuilt(HTTPError):
def __init__(self):
super().__init__(
status=503,
body="The Maloja Database is being upgraded to Version 3. This could take quite a long time! (~ 2-5 minutes per 10 000 scrobbles)",
body="The Maloja Database is being upgraded to Version 3. This could take several minutes.",
headers={"Retry-After":120}
)

View File

@ -10,30 +10,24 @@ from ..pkg_global.conf import data_dir
profiler = cProfile.Profile()
FULL_PROFILE = False
def profile(func):
def newfunc(*args,**kwargs):
if FULL_PROFILE:
benchmarkfolder = data_dir['logs']("benchmarks")
os.makedirs(benchmarkfolder,exist_ok=True)
benchmarkfolder = data_dir['logs']("benchmarks")
os.makedirs(benchmarkfolder,exist_ok=True)
clock = Clock()
clock.start()
if FULL_PROFILE:
profiler.enable()
profiler.enable()
result = func(*args,**kwargs)
if FULL_PROFILE:
profiler.disable()
profiler.disable()
log(f"Executed {func.__name__} ({args}, {kwargs}) in {clock.stop():.2f}s",module="debug_performance")
if FULL_PROFILE:
try:
pstats.Stats(profiler).dump_stats(os.path.join(benchmarkfolder,f"{func.__name__}.stats"))
except:
pass
try:
pstats.Stats(profiler).dump_stats(os.path.join(benchmarkfolder,f"{func.__name__}.stats"))
except:
pass
return result

View File

@ -5,7 +5,6 @@ from threading import Thread
from importlib import resources
from css_html_js_minify import html_minify, css_minify
import datauri
import time
# server stuff
@ -35,7 +34,7 @@ from .dev.profiler import profile
PORT = malojaconfig["PORT"]
HOST = malojaconfig["HOST"]
THREADS = 16
THREADS = 12
BaseRequest.MEMFILE_MAX = 15 * 1024 * 1024
#STATICFOLDER = importlib.resources.path(__name__,"web/static")
@ -234,7 +233,6 @@ def static(path):
### DYNAMIC
@profile
def jinja_page(name):
if name in aliases: redirect(aliases[name])
keys = remove_identical(FormsDict.decode(request.query))
@ -294,31 +292,6 @@ def redirect_track(artists,title):
#####
# warning interception
import logging
class WaitressLogHandler():
def __init__(self):
self.lastwarned = 0
self.barrier = 5
self.level = 20
self.filters = []
def handle(self,record):
if record.name == 'waitress.queue':
now = time.time()
depth = record.args[0]
if depth > self.barrier:
log(f"Waitress Task Queue Depth at {depth}")
self.lastwarned = now
self.barrier = max(depth,self.barrier+5)
elif now - self.lastwarned > 5:
self.barrier = max(5,self.barrier-5)
else:
log(f"Waitress: {record.msg % record.args}")
logging.getLogger().addHandler(WaitressLogHandler())
def run_server():
log("Starting up Maloja server...")
@ -326,7 +299,6 @@ def run_server():
Thread(target=database.start_db).start()
try:
#run(webserver, host=HOST, port=MAIN_PORT, server='waitress')
log(f"Listening on {HOST}:{PORT}")

View File

@ -44,7 +44,7 @@ def upgrade_apikeys():
def upgrade_db(callback_add_scrobbles):
oldfolder = os.path.join(dir_settings['state'],"scrobbles")
newfolder = os.path.join(dir_settings['state'],".v2scrobbles")
newfolder = os.path.join(dir_settings['state'],".oldscrobbles")
os.makedirs(newfolder,exist_ok=True)
if os.path.exists(oldfolder):
scrobblefiles = [f for f in os.listdir(oldfolder) if f.endswith(".tsv")]
@ -67,7 +67,7 @@ def upgrade_db(callback_add_scrobbles):
scrobblelist = []
log(f"\tImporting from {sf} ({idx}/{len(scrobblefiles)}) - {len(scrobbles)} Scrobbles")
for scrobble in scrobbles:
timestamp, artists, title, album, duration, *_ = scrobble + [None,None]
timestamp, artists, title, album, duration = scrobble
if album in ('-',''): album = None
if duration in ('-',''): duration = None
scrobblelist.append({

View File

@ -3,10 +3,8 @@
<html>
<head>
<meta charset="UTF-8" />
<meta name="referrer" content="same-origin" />
<title>{% block title %}{% endblock %}</title>
<meta charset="UTF-8" />
<meta name="description" content='Maloja is a self-hosted music scrobble server.' />
<meta name="color-scheme" content="dark" />

View File

@ -65,7 +65,6 @@
With Admin Mode activated, you can:
<ul>
<li>manually scrobble from track pages</li>
<li>delete scrobbles</li>
<li>upload artist and track art by dropping a file on the existing image on an artist or track page</li>
<li>see more detailed error pages</li>
</ul>

View File

@ -2,14 +2,14 @@
{% import 'snippets/links.jinja' as links %}
{% if entity is mapping and 'artists' in entity %}
{% if 'artists' in entity %}
{% set img = images.get_track_image(entity) %}
{% else %}
{% set img = images.get_artist_image(entity) %}
{% endif %}
<td class='icon'><div style="background-image:url('{{ img }}')"></div></td>
{% if entity is mapping and 'artists' in entity %}
{% if "artists" in entity %}
{% if settings['TRACK_SEARCH_PROVIDER'] %}
<td class='searchProvider'>{{ links.link_search(entity) }}</td>
{% endif %}

View File

@ -1,5 +1,5 @@
{% macro link(entity) -%}
{% if entity is mapping and 'artists' in entity %}
{% if 'artists' in entity %}
{% set name = entity.title %}
{% else %}
{% set name = entity %}
@ -17,7 +17,7 @@
{% macro url(entity) %}
{% if entity is mapping and 'artists' in entity -%}
{% if 'artists' in entity -%}
{{ mlj_uri.create_uri("/track",{'track':entity}) }}
{%- else -%}
{{ mlj_uri.create_uri("/artist",{'artist':entity}) }}

View File

@ -1,6 +1,6 @@
[project]
name = "malojaserver"
version = "3.0.2"
version = "3.0.0"
description = "Self-hosted music scrobble database"
readme = "./README.md"
requires-python = ">=3.6"
@ -21,7 +21,7 @@ classifiers = [
dependencies = [
"bottle>=0.12.16",
"waitress>=1.3",
"doreah>=1.9.1, <2",
"doreah>=1.9.0, <2",
"nimrodel>=0.8.0",
"setproctitle>=1.1.10",
#"pyvips>=2.1.16",