mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-03 20:13:02 +00:00
connect quick scan
This commit is contained in:
+28
-29
@@ -6,7 +6,7 @@ from pydantic import BaseModel, Field
|
|||||||
from app.api.auth import admin_required
|
from app.api.auth import admin_required
|
||||||
|
|
||||||
from app.db.userdata import PluginTable
|
from app.db.userdata import PluginTable
|
||||||
from app.lib.index import index_everything
|
from app.lib.index import IndexEverything, index_everything
|
||||||
from app.logger import log
|
from app.logger import log
|
||||||
from app.settings import Info, SessionVarKeys
|
from app.settings import Info, SessionVarKeys
|
||||||
from app.store.albums import AlbumStore
|
from app.store.albums import AlbumStore
|
||||||
@@ -194,43 +194,43 @@ class SetSettingBody(BaseModel):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@api.post("/set")
|
# @api.post("/set")
|
||||||
@admin_required()
|
# @admin_required()
|
||||||
def set_setting(body: SetSettingBody):
|
# def set_setting(body: SetSettingBody):
|
||||||
"""
|
# """
|
||||||
Set a setting.
|
# Set a setting.
|
||||||
"""
|
# """
|
||||||
key = body.key
|
# key = body.key
|
||||||
value = body.value
|
# value = body.value
|
||||||
|
|
||||||
if key is None or value is None or key == "root_dirs":
|
# if key is None or value is None or key == "root_dirs":
|
||||||
return {"msg": "Invalid arguments!"}, 400
|
# return {"msg": "Invalid arguments!"}, 400
|
||||||
|
|
||||||
root_dir = sdb.get_root_dirs()
|
# root_dir = sdb.get_root_dirs()
|
||||||
|
|
||||||
if not root_dir:
|
# if not root_dir:
|
||||||
return {"msg": "No root directories set!"}, 400
|
# return {"msg": "No root directories set!"}, 400
|
||||||
|
|
||||||
if key not in mapp:
|
# if key not in mapp:
|
||||||
return {"msg": "Invalid key!"}, 400
|
# return {"msg": "Invalid key!"}, 400
|
||||||
|
|
||||||
if key == "artist_separators":
|
# if key == "artist_separators":
|
||||||
value = str(value).split(",")
|
# value = str(value).split(",")
|
||||||
value = set(value)
|
# value = set(value)
|
||||||
|
|
||||||
reload_all_for_set_setting()
|
# reload_all_for_set_setting()
|
||||||
|
|
||||||
# if value is a set, convert it to a string
|
# # if value is a set, convert it to a string
|
||||||
# (artist_separators)
|
# # (artist_separators)
|
||||||
if type(value) == set:
|
# if type(value) == set:
|
||||||
value = ",".join(value)
|
# value = ",".join(value)
|
||||||
|
|
||||||
return {"result": value}
|
# return {"result": value}
|
||||||
|
|
||||||
|
|
||||||
@background
|
@background
|
||||||
def run_populate():
|
def index_stuff():
|
||||||
# populate.Populate(instance_key=get_random_str())
|
IndexEverything()
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@@ -239,8 +239,7 @@ def trigger_scan():
|
|||||||
"""
|
"""
|
||||||
Triggers scan for new music
|
Triggers scan for new music
|
||||||
"""
|
"""
|
||||||
run_populate()
|
index_stuff()
|
||||||
|
|
||||||
return {"msg": "Scan triggered!"}
|
return {"msg": "Scan triggered!"}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user