This repository was archived by the owner on Oct 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxml.go
57 lines (52 loc) · 1.38 KB
/
xml.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
57
package main
import (
"encoding/xml"
"fmt"
"strings"
)
type Commit struct {
XMLName xml.Name `xml:"i"`
ChatServer string `xml:"chatserver"`
ChatID string `xml:"chatid"`
Mission int `xml:"mission"`
MaxLimit int `xml:"maxlimit"`
State int `xml:"state"`
RealName int `xml:"real_name"`
Source string `xml:"source"`
Comments []Comment `xml:"d"`
}
type Comment struct {
P string `xml:"p,attr"`
Content string `xml:",chardata"`
}
type ParsedComment struct {
Time float64
Type int
FontSize int
Color int
SendTime int64
PoolType int
MidHash string
Dmid int64
Content string
}
func parsePAttribute(p string) (float64, int, int, int, int64, int, string, int64) {
parts := strings.Split(p, ",")
if len(parts) < 8 {
return 0, 0, 0, 0, 0, 0, "", 0
}
var time float64
var danmakuType, fontSize, color, poolType int
var sendTime int64
var midHash string
var dmid int64
_, _ = fmt.Sscanf(parts[0], "%f", &time)
_, _ = fmt.Sscanf(parts[1], "%d", &danmakuType)
_, _ = fmt.Sscanf(parts[2], "%d", &fontSize)
_, _ = fmt.Sscanf(parts[3], "%d", &color)
_, _ = fmt.Sscanf(parts[4], "%d", &sendTime)
_, _ = fmt.Sscanf(parts[5], "%d", &poolType)
_, _ = fmt.Sscanf(parts[6], "%s", &midHash)
_, _ = fmt.Sscanf(parts[7], "%d", &dmid)
return time, danmakuType, fontSize, color, sendTime, poolType, midHash, dmid
}