[server] fix watchdog

This commit is contained in:
geoffrey45
2022-04-03 09:38:52 +03:00
parent eed8ef34bc
commit 42df577c1b
7 changed files with 29 additions and 43 deletions
+1 -1
View File
@@ -347,7 +347,7 @@ def get_tags(fullpath: str) -> dict:
"length": round(audio.info.length), "length": round(audio.info.length),
"bitrate": round(int(audio.info.bitrate) / 1000), "bitrate": round(int(audio.info.bitrate) / 1000),
"filepath": fullpath, "filepath": fullpath,
"folder": os.path.dirname(fullpath) + "/", "folder": os.path.dirname(fullpath),
} }
return tags return tags
+9 -4
View File
@@ -21,7 +21,7 @@ def create_folder(foldername: str) -> models.Folder:
"""Create a single Folder object""" """Create a single Folder object"""
folder = { folder = {
"name": foldername.split("/")[-1], "name": foldername.split("/")[-1],
"path": foldername + "/", "path": foldername,
"trackcount": get_folder_track_count(foldername), "trackcount": get_folder_track_count(foldername),
} }
@@ -48,11 +48,16 @@ def get_subdirs(foldername: str) -> List[models.Folder]:
subdirs = set() subdirs = set()
for folder in api.VALID_FOLDERS: for folder in api.VALID_FOLDERS:
if foldername in folder:
str0 = folder.replace(foldername, "") str0 = folder.replace(foldername, "")
str1 = str0.split("/")[0]
if str1 != "": try:
subdirs.add(foldername + str1) 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] return [create_folder(dir) for dir in subdirs]
+9 -8
View File
@@ -59,20 +59,20 @@ def add_track(filepath: str) -> None:
tags["image"] = album.image tags["image"] = album.image
api.TRACKS.append(models.Track(tags)) api.TRACKS.append(models.Track(tags))
folder = folderslib.create_folder(tags["folder"]) folder = tags["folder"]
print(f"💙💙 {tags['folder']}")
print(folder)
if folder not in api.FOLDERS: if folder not in api.VALID_FOLDERS:
api.FOLDERS.append(folder) api.VALID_FOLDERS.add(folder)
print(f"added folder {folder.path}") f = folderslib.create_folder(folder)
api.FOLDERS.append(f)
def remove_track(filepath: str) -> None: def remove_track(filepath: str) -> None:
""" """
Removes a track from the music dict. Removes a track from the music dict.
""" """
fpath = filepath.split("/")[-1] fname = filepath.split("/")[-1]
fpath = filepath.replace(fname, "")
try: try:
trackid = instances.songs_instance.get_song_by_path(filepath)["_id"]["$oid"] 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) api.TRACKS.remove(track)
for folder in api.FOLDERS: 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.FOLDERS.remove(folder)
api.VALID_FOLDERS.remove(folder.path)
class Handler(PatternMatchingEventHandler): class Handler(PatternMatchingEventHandler):
+1 -1
View File
@@ -6,7 +6,7 @@ import os
# paths # paths
CONFIG_FOLDER = ".alice" CONFIG_FOLDER = ".alice"
HOME_DIR = os.path.expanduser("~") + "/" HOME_DIR = os.path.expanduser("~")
APP_DIR = os.path.join(HOME_DIR, CONFIG_FOLDER) APP_DIR = os.path.join(HOME_DIR, CONFIG_FOLDER)
THUMBS_PATH = os.path.join(APP_DIR, "images", "thumbnails") THUMBS_PATH = os.path.join(APP_DIR, "images", "thumbnails")
+5 -27
View File
@@ -1,46 +1,24 @@
<template> <template>
<div class="folder-top flex"> <div class="folder-top flex">
<div class="fname"> <div class="fname">
<button class="play image" @click="playFolder(first_song)"> <button class="play image">
<div class="icon"></div> <div class="icon"></div>
Play Play
</button> </button>
<div class="text"> <div class="text">
<div class="icon image"></div> <div class="icon image"></div>
<div class="ellip"> <div class="ellip">
{{ path.split("/").splice(-2).join("") }} {{ folder.path.split("/").splice(-1).join("") }}
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</template> </template>
<script> <script setup lang="ts">
import perks from "@/composables/perks.js"; import useFStore from "../../stores/folder";
import { watch } from "@vue/runtime-core";
import useDebouncedRef from "@/composables/useDebouncedRef.js";
import Loader from "../shared/Loader.vue";
export default { const folder = useFStore();
props: ["path", "first_song"],
components: { Loader },
setup(props, { emit }) {
const query = useDebouncedRef("", 400);
function playFolder(song) {
perks.updateQueue(song, "folder");
}
watch(query, () => {
emit("search", query.value);
});
return {
playFolder,
query,
};
},
};
</script> </script>
<style lang="scss"> <style lang="scss">
@@ -13,7 +13,7 @@
v-for="artist in artists" v-for="artist in artists"
:key="artist" :key="artist"
:artist="artist" :artist="artist"
:color="232452" :color="ffffff00"
/> />
</div> </div>
</div> </div>
@@ -66,6 +66,7 @@ export default {
user-select: none; user-select: none;
background: linear-gradient(0deg, transparent, $black); background: linear-gradient(0deg, transparent, $black);
position: relative; position: relative;
background-color: #ffffff00;
.header { .header {
display: flex; display: flex;
+1
View File
@@ -14,6 +14,7 @@ export default defineStore("FolderDirs&Tracks", {
const { tracks, folders } = await fetchThem(path); const { tracks, folders } = await fetchThem(path);
this.path = path; this.path = path;
console.log(path)
this.dirs = folders; this.dirs = folders;
this.tracks = tracks; this.tracks = tracks;
}, },