fix watchdog

- remove creating album feature from watchdog (rely on the periodic function)
This commit is contained in:
geoffrey45
2022-07-02 20:10:13 +03:00
committed by Mungai Geoffrey
parent c9830842ed
commit 6fbf179f34
7 changed files with 37 additions and 57 deletions
+5 -19
View File
@@ -4,15 +4,15 @@ This library contains the classes and functions related to the watchdog file wat
import os import os
import time import time
from app.logger import logg from app.logger import get_logger
from app import instances from app import instances
from app import models from app.helpers import create_album_hash
from app.helpers import Get, create_album_hash
from app.lib.albumslib import create_album
from app.lib.taglib import get_tags from app.lib.taglib import get_tags
from watchdog.events import PatternMatchingEventHandler from watchdog.events import PatternMatchingEventHandler
from watchdog.observers import Observer from watchdog.observers import Observer
log = get_logger()
class OnMyWatch: class OnMyWatch:
""" """
@@ -31,7 +31,7 @@ class OnMyWatch:
try: try:
self.observer.start() self.observer.start()
except OSError: except OSError:
logg.error("Could not start watchdog.") log.error("Could not start watchdog.")
return return
try: try:
@@ -55,18 +55,6 @@ def add_track(filepath: str) -> None:
if tags is not None: if tags is not None:
hash = create_album_hash(tags["album"], tags["albumartist"]) hash = create_album_hash(tags["album"], tags["albumartist"])
tags["albumhash"] = hash tags["albumhash"] = hash
album = instances.album_instance.find_album_by_hash(hash)
all_tracks = Get.get_all_tracks()
all_tracks.append(models.Track(tags))
if album is None:
album_data = create_album(tags, all_tracks)
album = models.Album(album_data)
instances.album_instance.insert_album(album)
tags["image"] = album.image
instances.tracks_instance.insert_song(tags) instances.tracks_instance.insert_song(tags)
@@ -75,8 +63,6 @@ def remove_track(filepath: str) -> None:
Removes a track from the music dict. Removes a track from the music dict.
""" """
filepath = filepath + "k"
instances.tracks_instance.remove_song_by_filepath(filepath) instances.tracks_instance.remove_song_by_filepath(filepath)
+8 -12
View File
@@ -9,13 +9,12 @@
}" }"
> >
<div class="art"> <div class="art">
<div <img
class="image shadow-lg rounded" :src="imguri + album.image"
:style="{ alt=""
backgroundImage: `url(&quot;${imguri + album.image}&quot;)`,
}"
v-motion-slide-from-left v-motion-slide-from-left
></div> class="rounded shadow-lg"
/>
</div> </div>
<div class="info" :class="{ nocontrast: isLight() }"> <div class="info" :class="{ nocontrast: isLight() }">
<div class="top" v-motion-slide-from-top> <div class="top" v-motion-slide-from-top>
@@ -50,7 +49,7 @@
import useVisibility from "@/composables/useVisibility"; import useVisibility from "@/composables/useVisibility";
import useNavStore from "@/stores/nav"; import useNavStore from "@/stores/nav";
import useAlbumStore from "@/stores/pages/album"; import useAlbumStore from "@/stores/pages/album";
import { reactive, ref } from "vue"; import { ref } from "vue";
import { playSources } from "../../composables/enums"; import { playSources } from "../../composables/enums";
import { formatSeconds } from "../../composables/perks"; import { formatSeconds } from "../../composables/perks";
import { paths } from "../../config"; import { paths } from "../../config";
@@ -177,10 +176,6 @@ function theyContrast(color1: string, color2: string) {
</script> </script>
<style lang="scss"> <style lang="scss">
.album-h {
height: auto;
}
.a-header { .a-header {
display: grid; display: grid;
grid-template-columns: max-content 1fr; grid-template-columns: max-content 1fr;
@@ -197,9 +192,10 @@ function theyContrast(color1: string, color2: string) {
display: flex; display: flex;
align-items: flex-end; align-items: flex-end;
.image { img {
width: 15rem; width: 15rem;
height: 15rem; height: 15rem;
transition: all 0.2s ease-in-out;
} }
} }
+1 -6
View File
@@ -11,12 +11,7 @@
}" }"
> >
<div class="art"> <div class="art">
<div <img :src="imguri + track.image" alt="" class="l-image rounded" />
class="l-image image rounded"
:style="{
backgroundImage: `url(&quot;${imguri + track.image}&quot;)`,
}"
></div>
</div> </div>
</router-link> </router-link>
+2 -3
View File
@@ -8,9 +8,8 @@
<div class="r-search" v-show="tabs.current === tabs.tabs.search"> <div class="r-search" v-show="tabs.current === tabs.tabs.search">
<Search /> <Search />
</div> </div>
<div class="r-queue" v-show="tabs.current === tabs.tabs.queue"> <div class="r-queue" v-show="tabs.current === tabs.tabs.queue">
<UpNext /> <Queue />
</div> </div>
</div> </div>
</div> </div>
@@ -19,7 +18,7 @@
<script setup lang="ts"> <script setup lang="ts">
import Search from "./Search/Main.vue"; import Search from "./Search/Main.vue";
import UpNext from "./Queue.vue"; import Queue from "./Queue.vue";
import DashBoard from "./Home/Main.vue"; import DashBoard from "./Home/Main.vue";
import useTabStore from "../../stores/tabs"; import useTabStore from "../../stores/tabs";
+3 -3
View File
@@ -38,11 +38,11 @@ defineProps<{
cursor: pointer; cursor: pointer;
.artist-image { .artist-image {
width: 7em; width: 8em;
height: 7em; height: 8em;
border-radius: 60%; border-radius: 60%;
margin-bottom: $small; margin-bottom: $small;
background-size: 7rem 7rem; background-size: 8rem 8rem;
background-position: center; background-position: center;
background-repeat: no-repeat; background-repeat: no-repeat;
transition: all 0.5s ease-in-out; transition: all 0.5s ease-in-out;
+17 -13
View File
@@ -7,13 +7,12 @@
> >
<div class="index">{{ props.index }}</div> <div class="index">{{ props.index }}</div>
<div class="flex"> <div class="flex">
<div <div @click="emitUpdate(props.song)" class="thumbnail">
class="album-art image rounded" <img
:style="{ :src="imguri + props.song.image"
backgroundImage: `url(&quot;${imguri + props.song.image}&quot;`, alt=""
}" class="album-art image rounded"
@click="emitUpdate(props.song)" />
>
<div <div
class="now-playing-track image" class="now-playing-track image"
v-if="props.isPlaying && props.isCurrent" v-if="props.isPlaying && props.isCurrent"
@@ -226,20 +225,25 @@ function emitUpdate(track: Track) {
.flex { .flex {
position: relative; position: relative;
padding-left: 4rem;
align-items: center; align-items: center;
.thumbnail {
margin-right: $small;
display: flex;
}
.album-art { .album-art {
position: absolute;
left: $small;
width: 3rem; width: 3rem;
height: 3rem; height: 3rem;
margin-right: 1rem;
display: grid;
place-items: center;
cursor: pointer; cursor: pointer;
} }
.now-playing-track {
position: absolute;
left: $small;
top: $small;
}
.title { .title {
cursor: pointer; cursor: pointer;
word-break: break-all; word-break: break-all;
+1 -1
View File
@@ -3,8 +3,8 @@ import { focusElem } from "../composables/perks";
const tablist = { const tablist = {
home: "home", home: "home",
search: "search",
queue: "queue", queue: "queue",
search: "search",
}; };
export default defineStore("tabs", { export default defineStore("tabs", {