-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_win.go
56 lines (46 loc) · 1000 Bytes
/
main_win.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// +build windows
package NeteaseMusicPlaying
import (
"database/sql"
"encoding/json"
"fmt"
_ "github.com/mattn/go-sqlite3"
"log"
"os"
"strings"
)
var db *sql.DB
var HistoryFilePath string
var Playing = &HistoryStruct{}
func init() {
HistoryFilePath = strings.Join([]string{
os.Getenv("TMP"),
"..",
"Packages",
"1F8B0F94.122165AE053F_j2p0p5q0044a6",
"LocalState",
"_cloudmusic.sqlite",
}, string(os.PathSeparator))
log.Println(HistoryFilePath)
f, err := os.Open(HistoryFilePath)
if err == nil || os.IsExist(err) {
log.Println("splite 3 db file is exist")
defer f.Close()
} else {
log.Fatalln("splite 3 db file is Not Exist!")
}
db, err = sql.Open("sqlite3", HistoryFilePath)
if err != nil {
panic(err)
}
}
func Update() {
sqlStmt := `
SELECT resourcedata FROM playhistory
ORDER BY updatetime DESC LIMIT 1;`
var data = ""
row := db.QueryRow(sqlStmt)
_ = row.Scan(&data)
_ = json.Unmarshal([]byte(data), &Playing)
fmt.Printf("%+v\n", Playing)
}