mirror of
https://github.com/tcsenpai/swingmusic.git
synced 2025-07-03 08:10:12 +00:00
configure watchdog to accept a list of dirs to watch
- fix PlayingFrom component not working with album - fix types issues on PlayingFrom component
This commit is contained in:
parent
97b61970c5
commit
3882317cb6
@ -60,7 +60,6 @@ class RemoveDuplicates:
|
|||||||
for t in self.tracklist
|
for t in self.tracklist
|
||||||
if t.uniq_hash not in uniq_hashes
|
if t.uniq_hash not in uniq_hashes
|
||||||
]
|
]
|
||||||
pprint(uniq_hashes[:5])
|
|
||||||
tracks = UseBisection(self.tracklist, "uniq_hash", uniq_hashes)()
|
tracks = UseBisection(self.tracklist, "uniq_hash", uniq_hashes)()
|
||||||
|
|
||||||
return tracks
|
return tracks
|
||||||
|
@ -3,6 +3,7 @@ This library contains the classes and functions related to the watchdog file wat
|
|||||||
"""
|
"""
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
|
from typing import List
|
||||||
|
|
||||||
from app import instances
|
from app import instances
|
||||||
from app.helpers import create_hash
|
from app.helpers import create_hash
|
||||||
@ -19,29 +20,39 @@ class OnMyWatch:
|
|||||||
Contains the methods for initializing and starting watchdog.
|
Contains the methods for initializing and starting watchdog.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
directory = os.path.expanduser("~")
|
home_dir = os.path.expanduser("~")
|
||||||
|
dirs = [home_dir]
|
||||||
|
observers: List[Observer] = []
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.observer = Observer()
|
self.observer = Observer()
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
event_handler = Handler()
|
event_handler = Handler()
|
||||||
self.observer.schedule(event_handler, self.directory, recursive=True)
|
|
||||||
|
for dir in self.dirs:
|
||||||
|
print("something")
|
||||||
|
self.observer.schedule(event_handler, os.path.realpath(dir), recursive=True)
|
||||||
|
self.observers.append(self.observer)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.observer.start()
|
self.observer.start()
|
||||||
|
print("something something")
|
||||||
except OSError:
|
except OSError:
|
||||||
log.error("Could not start watchdog.")
|
log.error("Could not start watchdog.")
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
time.sleep(5)
|
time.sleep(1)
|
||||||
except:
|
except KeyboardInterrupt:
|
||||||
self.observer.stop()
|
for o in self.observers:
|
||||||
|
o.unschedule_all()
|
||||||
|
o.stop()
|
||||||
print("Observer Stopped")
|
print("Observer Stopped")
|
||||||
|
|
||||||
self.observer.join()
|
for o in self.observers:
|
||||||
|
o.join()
|
||||||
|
|
||||||
|
|
||||||
def add_track(filepath: str) -> None:
|
def add_track(filepath: str) -> None:
|
||||||
@ -82,6 +93,7 @@ class Handler(PatternMatchingEventHandler):
|
|||||||
"""
|
"""
|
||||||
Fired when a supported file is created.
|
Fired when a supported file is created.
|
||||||
"""
|
"""
|
||||||
|
print("💠 created file 💠")
|
||||||
self.files_to_process.append(event.src_path)
|
self.files_to_process.append(event.src_path)
|
||||||
|
|
||||||
def on_deleted(self, event):
|
def on_deleted(self, event):
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
"""
|
"""
|
||||||
Contains all the models for objects generation and typing.
|
Contains all the models for objects generation and typing.
|
||||||
"""
|
"""
|
||||||
import random
|
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from dataclasses import field
|
from dataclasses import field
|
||||||
from typing import List
|
from typing import List
|
||||||
|
@ -86,7 +86,12 @@ function updateQueue(track: Track) {
|
|||||||
queue.play(index);
|
queue.play(index);
|
||||||
break;
|
break;
|
||||||
case "AlbumView":
|
case "AlbumView":
|
||||||
queue.playFromAlbum(track.album, track.albumartist, props.tracks);
|
queue.playFromAlbum(
|
||||||
|
track.album,
|
||||||
|
track.albumartist,
|
||||||
|
track.albumhash,
|
||||||
|
props.tracks
|
||||||
|
);
|
||||||
queue.play(index);
|
queue.play(index);
|
||||||
break;
|
break;
|
||||||
case "PlaylistView":
|
case "PlaylistView":
|
||||||
@ -148,7 +153,7 @@ function getTracks() {
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.context-on {
|
.contexton {
|
||||||
background-color: $gray4;
|
background-color: $gray4;
|
||||||
color: $white !important;
|
color: $white !important;
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,12 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { fromFolder, fromAlbum, fromPlaylist, fromSearch } from "../../../interfaces";
|
import {
|
||||||
|
fromFolder,
|
||||||
|
fromAlbum,
|
||||||
|
fromPlaylist,
|
||||||
|
fromSearch,
|
||||||
|
} from "../../../interfaces";
|
||||||
import { FromOptions } from "../../../composables/enums";
|
import { FromOptions } from "../../../composables/enums";
|
||||||
import { useRouter } from "vue-router";
|
import { useRouter } from "vue-router";
|
||||||
import { computed } from "@vue/reactivity";
|
import { computed } from "@vue/reactivity";
|
||||||
@ -42,7 +47,7 @@ const from = computed((): from => {
|
|||||||
case FromOptions.album:
|
case FromOptions.album:
|
||||||
return {
|
return {
|
||||||
icon: "album",
|
icon: "album",
|
||||||
text: props.from.name,
|
text: `${props.from.name} - ${props.from.albumartist}`,
|
||||||
};
|
};
|
||||||
case FromOptions.playlist:
|
case FromOptions.playlist:
|
||||||
return {
|
return {
|
||||||
@ -52,37 +57,36 @@ const from = computed((): from => {
|
|||||||
case FromOptions.search:
|
case FromOptions.search:
|
||||||
return {
|
return {
|
||||||
icon: "search",
|
icon: "search",
|
||||||
text: `Search results for: "${props.from.query}"`
|
text: `Search results for: "${props.from.query}"`,
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
function goToAlbum() {
|
function goToAlbum(from: fromAlbum) {
|
||||||
router.push({
|
router.push({
|
||||||
name: "AlbumView",
|
name: "AlbumView",
|
||||||
params: {
|
params: {
|
||||||
album: props.from.name,
|
hash: from.hash,
|
||||||
artist: props.from.albumartist,
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function goToFolder() {
|
function goToFolder(from: fromFolder) {
|
||||||
router.push({
|
router.push({
|
||||||
name: "FolderView",
|
name: "FolderView",
|
||||||
params: {
|
params: {
|
||||||
path: props.from.path,
|
path: from.path,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function goToPlaylist() {
|
function goToPlaylist(from: fromPlaylist) {
|
||||||
router.push({
|
router.push({
|
||||||
name: "PlaylistView",
|
name: "PlaylistView",
|
||||||
params: {
|
params: {
|
||||||
pid: props.from.playlistid,
|
pid: from.playlistid,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -90,13 +94,13 @@ function goToPlaylist() {
|
|||||||
function goTo() {
|
function goTo() {
|
||||||
switch (props.from.type) {
|
switch (props.from.type) {
|
||||||
case FromOptions.folder:
|
case FromOptions.folder:
|
||||||
goToFolder();
|
goToFolder(props.from);
|
||||||
break;
|
break;
|
||||||
case FromOptions.album:
|
case FromOptions.album:
|
||||||
goToAlbum();
|
goToAlbum(props.from);
|
||||||
break;
|
break;
|
||||||
case FromOptions.playlist:
|
case FromOptions.playlist:
|
||||||
goToPlaylist();
|
goToPlaylist(props.from);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -108,7 +112,7 @@ function goTo() {
|
|||||||
padding: 0.75rem;
|
padding: 0.75rem;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
position: relative;
|
position: relative;
|
||||||
transition: all .2s ease;
|
transition: all 0.2s ease;
|
||||||
background-color: $black;
|
background-color: $black;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
@ -121,7 +125,7 @@ function goTo() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.h {
|
.h {
|
||||||
font-size: .9rem;
|
font-size: 0.9rem;
|
||||||
margin-bottom: $small;
|
margin-bottom: $small;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
class="songlist-item rounded"
|
class="songlist-item rounded"
|
||||||
:class="[
|
:class="[
|
||||||
{ current: isCurrent },
|
{ current: isCurrent },
|
||||||
{ 'context-on': context_on },
|
{ contexton: context_on },
|
||||||
{
|
{
|
||||||
highlighted: isHighlighted,
|
highlighted: isHighlighted,
|
||||||
},
|
},
|
||||||
@ -134,7 +134,6 @@ function emitUpdate(track: Track) {
|
|||||||
text-align: left;
|
text-align: left;
|
||||||
gap: $small;
|
gap: $small;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
text-transform: capitalize;
|
|
||||||
|
|
||||||
@include tablet-landscape {
|
@include tablet-landscape {
|
||||||
grid-template-columns: 1.5rem 1.5fr 1fr 1fr 2.5rem;
|
grid-template-columns: 1.5rem 1.5fr 1fr 1fr 2.5rem;
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
{
|
{
|
||||||
currentInQueue: props.isCurrent,
|
currentInQueue: props.isCurrent,
|
||||||
},
|
},
|
||||||
{ 'context-on': context_on },
|
{ contexton: context_on },
|
||||||
]"
|
]"
|
||||||
@contextmenu="showContextMenu"
|
@contextmenu="showContextMenu"
|
||||||
>
|
>
|
||||||
@ -87,7 +87,7 @@ const playThis = (track: Track) => {
|
|||||||
background-color: $gray3;
|
background-color: $gray3;
|
||||||
}
|
}
|
||||||
|
|
||||||
.context-on {
|
.contexton {
|
||||||
background-color: $gray4;
|
background-color: $gray4;
|
||||||
color: $white !important;
|
color: $white !important;
|
||||||
}
|
}
|
||||||
|
@ -29,9 +29,14 @@ export default function play(
|
|||||||
break;
|
break;
|
||||||
case playSources.album:
|
case playSources.album:
|
||||||
store = store as typeof album;
|
store = store as typeof album;
|
||||||
const a = store();
|
const a_store = store();
|
||||||
|
|
||||||
useQueue.playFromAlbum(a.info.title, a.info.artist, a.tracks);
|
useQueue.playFromAlbum(
|
||||||
|
a_store.info.title,
|
||||||
|
a_store.info.artist,
|
||||||
|
a_store.info.hash,
|
||||||
|
a_store.tracks
|
||||||
|
);
|
||||||
useQueue.play();
|
useQueue.play();
|
||||||
break;
|
break;
|
||||||
case playSources.playlist:
|
case playSources.playlist:
|
||||||
|
@ -74,23 +74,24 @@ export interface Notif {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface fromFolder {
|
export interface fromFolder {
|
||||||
type: FromOptions;
|
type: FromOptions.folder;
|
||||||
path: string;
|
path: string;
|
||||||
name: string;
|
name: string;
|
||||||
}
|
}
|
||||||
export interface fromAlbum {
|
export interface fromAlbum {
|
||||||
type: FromOptions;
|
type: FromOptions.album;
|
||||||
name: string;
|
name: string;
|
||||||
|
hash: string;
|
||||||
albumartist: string;
|
albumartist: string;
|
||||||
}
|
}
|
||||||
export interface fromPlaylist {
|
export interface fromPlaylist {
|
||||||
type: FromOptions;
|
type: FromOptions.playlist;
|
||||||
name: string;
|
name: string;
|
||||||
playlistid: string;
|
playlistid: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface fromSearch {
|
export interface fromSearch {
|
||||||
type: FromOptions;
|
type: FromOptions.search;
|
||||||
query: string;
|
query: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,12 +7,12 @@ import { createApp } from "vue";
|
|||||||
|
|
||||||
import App from "./App.vue";
|
import App from "./App.vue";
|
||||||
import router from "./router";
|
import router from "./router";
|
||||||
import useCustomTransitions from "./transitions";
|
import CustomTransitions from "./transitions";
|
||||||
|
|
||||||
const app = createApp(App);
|
const app = createApp(App);
|
||||||
|
|
||||||
app.use(createPinia());
|
app.use(createPinia());
|
||||||
app.use(router);
|
app.use(router);
|
||||||
app.use(MotionPlugin, useCustomTransitions);
|
app.use(MotionPlugin, CustomTransitions);
|
||||||
|
|
||||||
app.mount("#app");
|
app.mount("#app");
|
||||||
|
@ -46,6 +46,8 @@ const defaultTrack = <Track>{
|
|||||||
image: "",
|
image: "",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type From = fromFolder | fromAlbum | fromPlaylist | fromSearch;
|
||||||
|
|
||||||
export default defineStore("Queue", {
|
export default defineStore("Queue", {
|
||||||
state: () => ({
|
state: () => ({
|
||||||
progressElem: HTMLElement,
|
progressElem: HTMLElement,
|
||||||
@ -59,7 +61,7 @@ export default defineStore("Queue", {
|
|||||||
prev: 0,
|
prev: 0,
|
||||||
currentid: "",
|
currentid: "",
|
||||||
playing: false,
|
playing: false,
|
||||||
from: <fromFolder>{} || <fromAlbum>{} || <fromPlaylist>{},
|
from: <From>{},
|
||||||
tracks: <Track[]>[defaultTrack],
|
tracks: <Track[]>[defaultTrack],
|
||||||
}),
|
}),
|
||||||
actions: {
|
actions: {
|
||||||
@ -178,10 +180,16 @@ export default defineStore("Queue", {
|
|||||||
};
|
};
|
||||||
this.setNewQueue(tracks);
|
this.setNewQueue(tracks);
|
||||||
},
|
},
|
||||||
playFromAlbum(aname: string, albumartist: string, tracks: Track[]) {
|
playFromAlbum(
|
||||||
|
aname: string,
|
||||||
|
albumartist: string,
|
||||||
|
albumhash: string,
|
||||||
|
tracks: Track[]
|
||||||
|
) {
|
||||||
this.from = <fromAlbum>{
|
this.from = <fromAlbum>{
|
||||||
type: FromOptions.album,
|
type: FromOptions.album,
|
||||||
name: aname,
|
name: aname,
|
||||||
|
hash: albumhash,
|
||||||
albumartist: albumartist,
|
albumartist: albumartist,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user