Compare commits
No commits in common. "9842fbc06962e65e993e10aa21d1bbc3afd78ad0" and "89cc368f7c201a7e43f423ed00dd7c5f5ecad253" have entirely different histories.
9842fbc069
...
89cc368f7c
7
go.mod
7
go.mod
|
@ -1,8 +1,3 @@
|
|||
module cmus2obs
|
||||
|
||||
go 1.22.1
|
||||
|
||||
require (
|
||||
github.com/go-flac/flacpicture v0.3.0 // indirect
|
||||
github.com/go-flac/go-flac v1.0.0 // indirect
|
||||
)
|
||||
go 1.22.1
|
4
go.sum
4
go.sum
|
@ -1,4 +0,0 @@
|
|||
github.com/go-flac/flacpicture v0.3.0 h1:LkmTxzFLIynwfhHiZsX0s8xcr3/u33MzvV89u+zOT8I=
|
||||
github.com/go-flac/flacpicture v0.3.0/go.mod h1:DPbrzVYQ3fJcvSgLFp9HXIrEQEdfdk/+m0nQCzwodZI=
|
||||
github.com/go-flac/go-flac v1.0.0 h1:6qI9XOVLcO50xpzm3nXvO31BgDgHhnr/p/rER/K/doY=
|
||||
github.com/go-flac/go-flac v1.0.0/go.mod h1:WnZhcpmq4u1UdZMNn9LYSoASpWOCMOoxXxcWEHSzkW8=
|
53
main.go
53
main.go
|
@ -1,16 +1,12 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"os/exec"
|
||||
|
||||
"github.com/go-flac/flacpicture"
|
||||
"github.com/go-flac/go-flac"
|
||||
)
|
||||
|
||||
const TIMER = 2
|
||||
|
@ -35,58 +31,9 @@ func main() {
|
|||
title = "Unknown"
|
||||
}
|
||||
|
||||
filepath, err := getAttribute(remoteResp, "file ")
|
||||
if err != nil {
|
||||
log.Fatal(err.Error())
|
||||
}
|
||||
img := make([]byte, 0)
|
||||
if strings.HasSuffix(filepath, ".flac") {
|
||||
img, err = getFlacArt(filepath)
|
||||
if err != nil {
|
||||
img = defaultArt()
|
||||
}
|
||||
} else if strings.HasSuffix(filepath, ".mp3") {
|
||||
getMP3Art()
|
||||
} else {
|
||||
defaultArt()
|
||||
}
|
||||
|
||||
writeTxt("SongAlbum", album)
|
||||
writeTxt("SongArtist", artist)
|
||||
writeTxt("SongTitle", title)
|
||||
writeJpg("AlbumArt", img)
|
||||
}
|
||||
|
||||
func getFlacArt(s string) ([]byte, error) {
|
||||
f, err := flac.ParseFile(s)
|
||||
if err != nil {
|
||||
return nil, errors.New("can't open file")
|
||||
}
|
||||
for _, metadata := range f.Meta {
|
||||
if metadata.Type == flac.Picture {
|
||||
pic, err := flacpicture.ParseFromMetaDataBlock(*metadata)
|
||||
return pic.ImageData, err
|
||||
}
|
||||
}
|
||||
return nil, errors.New("no image found")
|
||||
}
|
||||
|
||||
func getMP3Art() {
|
||||
|
||||
}
|
||||
|
||||
func defaultArt() []byte {
|
||||
return nil
|
||||
}
|
||||
|
||||
func writeJpg(filename string, input []byte) {
|
||||
f, err := os.Create("./output/" + filename + ".jpg")
|
||||
if err != nil {
|
||||
log.Fatal(err.Error())
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
f.Write(input)
|
||||
}
|
||||
|
||||
func writeTxt(filename, input string) {
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 96 KiB |
|
@ -0,0 +1 @@
|
|||
LOVE /// DISCONNECT
|
|
@ -0,0 +1 @@
|
|||
♥ GOJII ♥
|
|
@ -0,0 +1 @@
|
|||
TOOTHPASTE FOREST ( SHADY ☆ MONK RMX )
|
Loading…
Reference in New Issue