Skip to content

Commit

Permalink
1.支持 手动选择视频/音频文件(兼容系统)
Browse files Browse the repository at this point in the history
2.新增软件新版本提醒
3.优化程序异常提醒
  • Loading branch information
wxbool committed Dec 21, 2019
1 parent 6ea6b71 commit 2a0fd8f
Show file tree
Hide file tree
Showing 9 changed files with 268 additions and 110 deletions.
2 changes: 1 addition & 1 deletion app/aliyun/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func (c AliyunClound) GetAudioFileResult(taskId string , client *sdk.Client , ca
}

if statusText != STATUS_SUCCESS {
return errors.New("录音文件识别失败 !")
return errors.New("录音文件识别失败 , (" + statusText + ")")
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion app/aliyun/tool.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,4 +338,4 @@ func SubString(str string , begin int ,length int) (substr string) {
}
// 返回子串
return string(rs[begin:end])
}
}
2 changes: 2 additions & 0 deletions app/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ type AppSetings struct {
OutputType int //输出文件类型
SrtFileDir string //Srt文件输出目录
SoundTrack int //输出音轨

CloseNewVersionMessage bool //关闭软件新版本提醒(默认开启)
}

//任务文件列表 - 结构
Expand Down
14 changes: 12 additions & 2 deletions app/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ func(mw *MyMainWindow) RunAppSetingDialog(owner walk.Form , confirmCall func(*Ap
Composite{
Layout: Grid{Columns: 2},
Children: []Widget{

//输出文件类型
Label{
Text: "输出文件类型:",
Expand Down Expand Up @@ -99,6 +100,15 @@ func(mw *MyMainWindow) RunAppSetingDialog(owner walk.Form , confirmCall func(*Ap
ColumnSpan: 2,
Text: "说明:\r\n“字幕文件输出目录” 若留空,则默认与媒体文件输出到同一目录下",
TextColor:walk.RGB(190 , 190 , 190),
MinSize:Size{Height:36},
},


Label{
Text: "关闭软件新版本提醒:",
},
CheckBox{
Checked: Bind("CloseNewVersionMessage"),
},
},
},
Expand Down Expand Up @@ -503,12 +513,12 @@ func (mw *MyMainWindow) RunTranslateSetingDialog(owner walk.Form) {

//打开 Github
func (mw *MyMainWindow) OpenAboutGithub() {
tool.OpenUrl("https://github.com/wxbool/video-srt")
tool.OpenUrl("https://github.com/wxbool/video-srt-windows")
}

//打开 Gitee
func (mw *MyMainWindow) OpenAboutGitee() {
tool.OpenUrl("https://gitee.com/641453620/video-srt")
tool.OpenUrl("https://gitee.com/641453620/video-srt-windows")
}


Expand Down
83 changes: 83 additions & 0 deletions app/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package app

import (
"errors"
"github.com/PuerkitoBio/goquery"
"github.com/lxn/walk"
"net/http"
"strconv"
"strings"
"time"
)

const (
VERSION_SOURCE string = "https://gitee.com/641453620/video-srt-windows/tags"
)

type AppVersion struct {

}

//根据码云查询新版本
func (v *AppVersion) GetVersion () (string , error) {

timeout := time.Duration(2 * time.Second)
client := &http.Client{
Timeout:timeout,
}
//获取版本来源html
response, err := client.Get(VERSION_SOURCE)
if err != nil {
return "" , err
}
defer response.Body.Close()
if response.StatusCode != 200 {
return "" , errors.New("status code error : " + strconv.Itoa(response.StatusCode))
}

//加载html
html, err := goquery.NewDocumentFromReader(response.Body)
if err != nil {
return "" , err
}

//查找节点
vs := ""
html.Find("#git-tags-container .releases-tags-wrap .releases-tag-content .tag-list .tag-item").Each(func(i int, s *goquery.Selection) {
if vs != "" {
return
}
tag , is := s.Find(".tag-name a").Attr("title")
if is && tag != "" {
vs = strings.TrimSpace(tag)
}
})

return vs,nil
}


//显示更新提醒
func (v *AppVersion) ShowVersionNotifyInfo (version string , own *MyMainWindow) error {
mw, err := walk.NewMainWindow()
if err != nil {
return err
}
ni, err := walk.NewNotifyIcon(mw)
if err != nil {
return err
}

defer func() {
time.Sleep(time.Second * 15)
_ = ni.Dispose()
}()

if err := ni.SetVisible(true); err != nil {
return err
}
if err := ni.ShowMessage("更新提醒" , "检测到VideoSrt的新版本(v"+version+"),请及时下载更新哦") ; err != nil {
return err
}
return nil
}
6 changes: 5 additions & 1 deletion app/video.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ func AliyunAudioRecognition(engine aliyun.AliyunClound , filelink string , intel
AudioResult = make(map[int64][] *aliyun.AliyunAudioRecognitionResult)

//遍历获取识别结果
engine.GetAudioFileResult(taskid , client , func(result []byte) {
resultError := engine.GetAudioFileResult(taskid , client , func(result []byte) {
//mylog.WriteLog( string( result ) )

//结果处理
Expand Down Expand Up @@ -303,6 +303,10 @@ func AliyunAudioRecognition(engine aliyun.AliyunClound , filelink string , intel
}
})

if (resultError != nil) {
panic(resultError)
}

return
}

Expand Down
Binary file added data/img/media.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/img/open.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 2a0fd8f

Please sign in to comment.