mirror of
https://shylinux.com/x/icebergs
synced 2025-04-25 17:18:05 +08:00
opt chrome
This commit is contained in:
parent
c43212865a
commit
069808d74b
68
misc/chrome/operate.go
Normal file
68
misc/chrome/operate.go
Normal file
@ -0,0 +1,68 @@
|
||||
package chrome
|
||||
|
||||
import (
|
||||
"shylinux.com/x/ice"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/web"
|
||||
"shylinux.com/x/icebergs/core/wiki"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
type operate struct {
|
||||
reload string `name:"reload" help:"刷新"`
|
||||
list string `name:"list wid tid url auto" help:"操作"`
|
||||
}
|
||||
|
||||
func (o operate) send(m *ice.Message, arg ...interface{}) *ice.Message {
|
||||
return m.Cmdy(web.SPACE, "chrome", "chrome", arg)
|
||||
}
|
||||
|
||||
func (o operate) Inputs(m *ice.Message, arg ...string) {
|
||||
switch arg[0] {
|
||||
case mdb.ZONE:
|
||||
o.send(m.Spawn()).Table(func(index int, value map[string]string, head []string) {
|
||||
o.send(m.Spawn(), value[WID]).Table(func(index int, value map[string]string, head []string) {
|
||||
m.Push(mdb.ZONE, kit.ParseURL(value[URL]).Host)
|
||||
})
|
||||
}).Sort(mdb.ZONE)
|
||||
}
|
||||
}
|
||||
func (o operate) Spide(m *ice.Message, arg ...string) {
|
||||
if len(arg) < 2 {
|
||||
o.send(m, arg)
|
||||
return
|
||||
}
|
||||
o.send(m, arg[:2], "spide").Table(func(index int, value map[string]string, head []string) {
|
||||
switch value[mdb.TYPE] {
|
||||
case wiki.VIDEO:
|
||||
m.PushVideos(mdb.SHOW, value[mdb.LINK])
|
||||
case wiki.IMG:
|
||||
m.PushImages(mdb.SHOW, value[mdb.LINK])
|
||||
default:
|
||||
m.Push(mdb.SHOW, "")
|
||||
}
|
||||
}).Cut("show,type,name,link")
|
||||
}
|
||||
func (o operate) Reload(m *ice.Message, arg ...string) {
|
||||
o.send(m, arg[:2], "user.reload", ice.TRUE).ProcessHold()
|
||||
}
|
||||
func (o operate) List(m *ice.Message, arg ...string) {
|
||||
switch len(arg) {
|
||||
case 3:
|
||||
o.send(m, arg[:2], "user.jumps", arg[2])
|
||||
case 2:
|
||||
m.Action(o.Reload)
|
||||
o.Spide(m, arg...)
|
||||
m.StatusTimeCount()
|
||||
default:
|
||||
o.send(m, arg)
|
||||
}
|
||||
}
|
||||
|
||||
const (
|
||||
WID = "wid"
|
||||
TID = "tid"
|
||||
URL = "url"
|
||||
)
|
||||
|
||||
func init() { ice.CodeCtxCmd(operate{}) }
|
20
misc/chrome/video.go
Normal file
20
misc/chrome/video.go
Normal file
@ -0,0 +1,20 @@
|
||||
package chrome
|
||||
|
||||
import (
|
||||
"shylinux.com/x/ice"
|
||||
)
|
||||
|
||||
type video struct {
|
||||
operate
|
||||
|
||||
play string `name:"play" help:"播放"`
|
||||
next string `name:"next" help:"下一集"`
|
||||
list string `name:"list tags='ul.stui-content__playlist.column10.clearfix li a' rate=1.5 skip=140 next=2520 auto play next" help:"操作"`
|
||||
}
|
||||
|
||||
func (v video) List(m *ice.Message, arg ...string) {
|
||||
m.DisplayStory("video.js")
|
||||
m.Echo("hello world")
|
||||
}
|
||||
|
||||
func init() { ice.CodeCtxCmd(video{}) }
|
Loading…
x
Reference in New Issue
Block a user