mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-03 20:13:02 +00:00
[server] fix watchdog
This commit is contained in:
@@ -347,7 +347,7 @@ def get_tags(fullpath: str) -> dict:
|
||||
"length": round(audio.info.length),
|
||||
"bitrate": round(int(audio.info.bitrate) / 1000),
|
||||
"filepath": fullpath,
|
||||
"folder": os.path.dirname(fullpath) + "/",
|
||||
"folder": os.path.dirname(fullpath),
|
||||
}
|
||||
|
||||
return tags
|
||||
|
||||
@@ -21,7 +21,7 @@ def create_folder(foldername: str) -> models.Folder:
|
||||
"""Create a single Folder object"""
|
||||
folder = {
|
||||
"name": foldername.split("/")[-1],
|
||||
"path": foldername + "/",
|
||||
"path": foldername,
|
||||
"trackcount": get_folder_track_count(foldername),
|
||||
}
|
||||
|
||||
@@ -48,11 +48,16 @@ def get_subdirs(foldername: str) -> List[models.Folder]:
|
||||
subdirs = set()
|
||||
|
||||
for folder in api.VALID_FOLDERS:
|
||||
str0 = folder.replace(foldername, "")
|
||||
str1 = str0.split("/")[0]
|
||||
if foldername in folder:
|
||||
str0 = folder.replace(foldername, "")
|
||||
|
||||
if str1 != "":
|
||||
subdirs.add(foldername + str1)
|
||||
try:
|
||||
str1 = str0.split("/")[1]
|
||||
except IndexError:
|
||||
str1 = None
|
||||
|
||||
if str1 is not None:
|
||||
subdirs.add(foldername + "/" + str1)
|
||||
|
||||
return [create_folder(dir) for dir in subdirs]
|
||||
|
||||
|
||||
@@ -59,20 +59,20 @@ def add_track(filepath: str) -> None:
|
||||
tags["image"] = album.image
|
||||
api.TRACKS.append(models.Track(tags))
|
||||
|
||||
folder = folderslib.create_folder(tags["folder"])
|
||||
print(f"💙💙 {tags['folder']}")
|
||||
print(folder)
|
||||
folder = tags["folder"]
|
||||
|
||||
if folder not in api.FOLDERS:
|
||||
api.FOLDERS.append(folder)
|
||||
print(f"added folder {folder.path}")
|
||||
if folder not in api.VALID_FOLDERS:
|
||||
api.VALID_FOLDERS.add(folder)
|
||||
f = folderslib.create_folder(folder)
|
||||
api.FOLDERS.append(f)
|
||||
|
||||
|
||||
def remove_track(filepath: str) -> None:
|
||||
"""
|
||||
Removes a track from the music dict.
|
||||
"""
|
||||
fpath = filepath.split("/")[-1]
|
||||
fname = filepath.split("/")[-1]
|
||||
fpath = filepath.replace(fname, "")
|
||||
|
||||
try:
|
||||
trackid = instances.songs_instance.get_song_by_path(filepath)["_id"]["$oid"]
|
||||
@@ -87,8 +87,9 @@ def remove_track(filepath: str) -> None:
|
||||
api.TRACKS.remove(track)
|
||||
|
||||
for folder in api.FOLDERS:
|
||||
if folder.path == filepath.replace(fpath, ""):
|
||||
if folder.path + "/" == fpath and folder.trackcount - 1 == 0:
|
||||
api.FOLDERS.remove(folder)
|
||||
api.VALID_FOLDERS.remove(folder.path)
|
||||
|
||||
|
||||
class Handler(PatternMatchingEventHandler):
|
||||
|
||||
@@ -6,7 +6,7 @@ import os
|
||||
|
||||
# paths
|
||||
CONFIG_FOLDER = ".alice"
|
||||
HOME_DIR = os.path.expanduser("~") + "/"
|
||||
HOME_DIR = os.path.expanduser("~")
|
||||
APP_DIR = os.path.join(HOME_DIR, CONFIG_FOLDER)
|
||||
THUMBS_PATH = os.path.join(APP_DIR, "images", "thumbnails")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user