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