update:sync mpv closing with discord status

This commit is contained in:
kokopi-dev
2025-12-21 21:08:02 +09:00
parent e671ad2cde
commit 977d4db39a

10
main.go
View File

@@ -68,7 +68,7 @@ func isInMusicFolder(fp string, musicFolders []string) bool {
home, _ := os.UserHomeDir()
folder = strings.Replace(folder, "~", home, 1)
}
if !filepath.IsAbs(folder) {
home, _ := os.UserHomeDir()
folder = filepath.Join(home, folder)
@@ -76,7 +76,7 @@ func isInMusicFolder(fp string, musicFolders []string) bool {
folder = filepath.Clean(folder)
filePath := filepath.Clean(fp)
if strings.HasPrefix(filePath, folder) {
return true
}
@@ -87,7 +87,7 @@ func isInMusicFolder(fp string, musicFolders []string) bool {
func main() {
var connected bool
var lastSong string
config, _:= config.GetConfig()
config, _ := config.GetConfig()
for {
if _, err := os.Stat(SOCKET_PATH); err == nil {
if !connected {
@@ -122,6 +122,10 @@ func main() {
}
} else {
fmt.Printf("✗ Connection broken, restart mpv to reconnect: %v\n", err)
if connected {
client.Logout()
connected = false
}
}
time.Sleep(5 * time.Second)