mirror of
https://github.com/AynaLivePlayer/AynaLivePlayer.git
synced 2025-12-17 07:28:20 +08:00
local search algorithm optimization/diange medal permission/
This commit is contained in:
@@ -25,5 +25,6 @@ func main() {
|
|||||||
controller.ClosePlugins(plugins...)
|
controller.ClosePlugins(plugins...)
|
||||||
controller.Destroy()
|
controller.Destroy()
|
||||||
_ = config.SaveToConfigFile(config.ConfigPath)
|
_ = config.SaveToConfigFile(config.ConfigPath)
|
||||||
|
//i18n.SaveTranslation()
|
||||||
logger.Logger.Info("================Program End================")
|
logger.Logger.Info("================Program End================")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -224,6 +224,18 @@
|
|||||||
"en": "Basic Diange Configuration",
|
"en": "Basic Diange Configuration",
|
||||||
"zh-CN": "点歌基本设置"
|
"zh-CN": "点歌基本设置"
|
||||||
},
|
},
|
||||||
|
"plugin.diange.medal.level": {
|
||||||
|
"en": "Level",
|
||||||
|
"zh-CN": "等级"
|
||||||
|
},
|
||||||
|
"plugin.diange.medal.name": {
|
||||||
|
"en": "Name",
|
||||||
|
"zh-CN": "牌子名"
|
||||||
|
},
|
||||||
|
"plugin.diange.medal.perm": {
|
||||||
|
"en": "Medal Permission",
|
||||||
|
"zh-CN": "牌子点歌权限"
|
||||||
|
},
|
||||||
"plugin.diange.permission": {
|
"plugin.diange.permission": {
|
||||||
"en": "Permission",
|
"en": "Permission",
|
||||||
"zh-CN": "点歌权限"
|
"zh-CN": "点歌权限"
|
||||||
@@ -348,6 +360,10 @@
|
|||||||
"en": "Stop",
|
"en": "Stop",
|
||||||
"zh-CN": "停止"
|
"zh-CN": "停止"
|
||||||
},
|
},
|
||||||
|
"plugin.webinfo.server_preview": {
|
||||||
|
"en": "Server Preview",
|
||||||
|
"zh-CN": "效果预览"
|
||||||
|
},
|
||||||
"plugin.webinfo.server_status": {
|
"plugin.webinfo.server_status": {
|
||||||
"en": "Server Status",
|
"en": "Server Status",
|
||||||
"zh-CN": "服务器状态"
|
"zh-CN": "服务器状态"
|
||||||
@@ -363,10 +379,6 @@
|
|||||||
"plugin.webinfo.title": {
|
"plugin.webinfo.title": {
|
||||||
"en": "Web Output",
|
"en": "Web Output",
|
||||||
"zh-CN": "Web输出"
|
"zh-CN": "Web输出"
|
||||||
},
|
|
||||||
"plugin.webinfo.server_preview": {
|
|
||||||
"en": "Server Preview",
|
|
||||||
"zh-CN":"效果预览"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ type Diange struct {
|
|||||||
UserPermission bool
|
UserPermission bool
|
||||||
PrivilegePermission bool
|
PrivilegePermission bool
|
||||||
AdminPermission bool
|
AdminPermission bool
|
||||||
|
MedalName string
|
||||||
|
MedalPermission int
|
||||||
QueueMax int
|
QueueMax int
|
||||||
UserCoolDown int
|
UserCoolDown int
|
||||||
CustomCMD string
|
CustomCMD string
|
||||||
@@ -117,6 +119,10 @@ func (d *Diange) Execute(command string, args []string, danmu *liveclient.DanmuM
|
|||||||
l().Trace("privilege permission check: ", perm)
|
l().Trace("privilege permission check: ", perm)
|
||||||
perm = perm || (d.AdminPermission && (danmu.User.Admin))
|
perm = perm || (d.AdminPermission && (danmu.User.Admin))
|
||||||
l().Trace("admin permission check: ", perm)
|
l().Trace("admin permission check: ", perm)
|
||||||
|
// if use medal check
|
||||||
|
if d.MedalName != "" && d.MedalPermission >= 0 {
|
||||||
|
perm = perm || ((danmu.User.Medal.Name == d.MedalName) && danmu.User.Medal.Level >= d.MedalPermission)
|
||||||
|
}
|
||||||
if !perm {
|
if !perm {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -147,6 +153,17 @@ func (d *Diange) CreatePanel() fyne.CanvasObject {
|
|||||||
widget.NewCheckWithData(i18n.T("plugin.diange.privilege"), binding.BindBool(&d.PrivilegePermission)),
|
widget.NewCheckWithData(i18n.T("plugin.diange.privilege"), binding.BindBool(&d.PrivilegePermission)),
|
||||||
widget.NewCheckWithData(i18n.T("plugin.diange.admin"), binding.BindBool(&d.AdminPermission)),
|
widget.NewCheckWithData(i18n.T("plugin.diange.admin"), binding.BindBool(&d.AdminPermission)),
|
||||||
)
|
)
|
||||||
|
dgMdPerm := container.NewBorder(nil, nil,
|
||||||
|
widget.NewLabel(i18n.T("plugin.diange.medal.perm")), nil,
|
||||||
|
container.NewGridWithColumns(2,
|
||||||
|
container.NewBorder(nil, nil,
|
||||||
|
widget.NewLabel(i18n.T("plugin.diange.medal.name")), nil,
|
||||||
|
widget.NewEntryWithData(binding.BindString(&d.MedalName))),
|
||||||
|
container.NewBorder(nil, nil,
|
||||||
|
widget.NewLabel(i18n.T("plugin.diange.medal.level")), nil,
|
||||||
|
widget.NewEntryWithData(binding.IntToString(binding.BindInt(&d.MedalPermission)))),
|
||||||
|
),
|
||||||
|
)
|
||||||
dgQueue := container.NewBorder(nil, nil,
|
dgQueue := container.NewBorder(nil, nil,
|
||||||
widget.NewLabel(i18n.T("plugin.diange.queue_max")), nil,
|
widget.NewLabel(i18n.T("plugin.diange.queue_max")), nil,
|
||||||
widget.NewEntryWithData(binding.IntToString(binding.BindInt(&d.QueueMax))),
|
widget.NewEntryWithData(binding.IntToString(binding.BindInt(&d.QueueMax))),
|
||||||
@@ -170,6 +187,6 @@ func (d *Diange) CreatePanel() fyne.CanvasObject {
|
|||||||
dgSourceCMD := container.NewBorder(
|
dgSourceCMD := container.NewBorder(
|
||||||
nil, nil, widget.NewLabel(i18n.T("plugin.diange.source_cmd")), nil,
|
nil, nil, widget.NewLabel(i18n.T("plugin.diange.source_cmd")), nil,
|
||||||
container.NewVBox(sourceCmds...))
|
container.NewVBox(sourceCmds...))
|
||||||
d.panel = container.NewVBox(dgPerm, dgQueue, dgCoolDown, dgShortCut, dgSourceCMD)
|
d.panel = container.NewVBox(dgPerm, dgMdPerm, dgQueue, dgCoolDown, dgShortCut, dgSourceCMD)
|
||||||
return d.panel
|
return d.panel
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,13 +80,16 @@ func (l *Local) Search(keyword string) ([]*player.Media, error) {
|
|||||||
keywords := strings.Split(keyword, " ")
|
keywords := strings.Split(keyword, " ")
|
||||||
for _, p := range l.Playlists {
|
for _, p := range l.Playlists {
|
||||||
for _, m := range p.Medias {
|
for _, m := range p.Medias {
|
||||||
|
title := strings.ToLower(m.Title)
|
||||||
|
artist := strings.ToLower(m.Artist)
|
||||||
n := 0
|
n := 0
|
||||||
for _, k := range keywords {
|
for _, k := range keywords {
|
||||||
if strings.Contains(m.Title, k) || strings.Contains(m.Artist, k) {
|
kw := strings.ToLower(k)
|
||||||
|
if strings.Contains(title, kw) || strings.Contains(artist, kw) {
|
||||||
n++
|
n++
|
||||||
}
|
}
|
||||||
if k == m.Title {
|
if kw == title {
|
||||||
n += 2
|
n += 3
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if n > 0 {
|
if n > 0 {
|
||||||
|
|||||||
Reference in New Issue
Block a user