Skip to content

Commit

Permalink
增加日志文件,修改自动升级bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Andyfoo committed Oct 11, 2019
1 parent a3bcab5 commit 0d78e9e
Show file tree
Hide file tree
Showing 11 changed files with 98 additions and 45 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@
/GoSubTitleSearcher_x64.exe
/.vscode
/.idea
/logs.txt
4 changes: 2 additions & 2 deletions 4_gen_upgrade.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
set appver=1.0.1
set appdesc=Ð޸IJ¿·ÖÎÊÌâ
set appver=1.0.3
set appdesc=增加日志文件,修改自动升级bug



Expand Down
35 changes: 33 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,39 @@
# GoSubTitleSearcher
字幕搜索查询(go语言版),支持4k 2160p,1080p,720p视频字幕搜索,集合了字幕库、迅雷、射手、SubHD查询接口。

可以拖动视频或选择视频开始搜索字幕
**Go语言版本:**
https://gitee.com/andyfoo/GoSubTitleSearcher
https://github.com/Andyfoo/GoSubTitleSearcher

**Java版本在此,不打算更新了:**
https://gitee.com/andyfoo/SubTitleSearcher
https://github.com/Andyfoo/SubTitleSearcher

**设计思路:**
- 个人精力有限,本程序仅支持windows,不考虑其它系统。
- go语言启动web server 实现业务处理。
- go语言实现webview(ie)外壳打开html界面,js调用http和websocket与go交互。
- 编译后的exe文件使用upx压缩。
- 使用了go-xutils集成了自己写的和第三方的常用函数。
- 在线升级使用github.com库中放文件来检测下载。



**可以拖动视频或选择视频开始搜索字幕**
![可以拖动视频或选择视频开始搜索字幕](https://raw.githubusercontent.com/Andyfoo/GoSubTitleSearcher/master/_docs/screenshot/p1.png)

可以单独或批量下载字幕,可复制标题文字
**可以单独或批量下载字幕,可复制标题文字**
![可以单独或批量下载字幕,可复制标题文字](https://raw.githubusercontent.com/Andyfoo/GoSubTitleSearcher/master/_docs/screenshot/p2.png)


**第三方依赖**
>https://github.com/Andyfoo/go-xutils
>https://github.com/GeertJohan/go.rice
>https://github.com/PuerkitoBio/goquery
>https://github.com/gorilla/websocket
>https://golang.org/x/text
>https://golang.org/x/sys
>https://github.com/akavel/rsrc
>https://gitter.im/zserge/webview
>https://github.com/google/logger
>...
4 changes: 2 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
var (
AppName = "GoSubTitleSearcher"
AppTitle = "字幕下载"
AppVer = "1.0.1"
AppPubDate = "2019-10-07"
AppVer = "1.0.2"
AppPubDate = "2019-10-11"

AppUpgradeUrl = "https://raw.githubusercontent.com/Andyfoo/my-apps/master/go/tools/GoSubTitleSearcher/last"

Expand Down
6 changes: 4 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
module GoSubTitleSearcher

go 1.12
go 1.13

require (
github.com/Andyfoo/go-xutils v1.0.8
github.com/Andyfoo/go-xutils v1.0.9
github.com/GeertJohan/go.rice v1.0.0
github.com/PuerkitoBio/goquery v1.5.0
github.com/gorilla/websocket v1.4.1
golang.org/x/text v0.3.2
)

//replace github.com/Andyfoo/go-xutils => E:/workspace/go/_my_libs/go-xutils
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
github.com/Andyfoo/go-xutils v1.0.8 h1:IGW7LX7eNEcA57ck434TnHtMOBeD/McIwcdxVbwuXWo=
github.com/Andyfoo/go-xutils v1.0.8/go.mod h1:g2JeCLw7rtC4i1oqCC1R2+PDyAnnbEbZ3uBDrb5fSdU=
github.com/Andyfoo/go-xutils v1.0.9 h1:pqz0xNmRNZrE1aolK1mdWBtcaVGVmoCOq+fJSe3KFxY=
github.com/Andyfoo/go-xutils v1.0.9/go.mod h1:2ZNWx3n7lcyB97STkRYzuHAXJTns/Vhp3fmgWTZEj/Y=
github.com/GeertJohan/go.incremental v1.0.0 h1:7AH+pY1XUgQE4Y1HcXYaMqAI0m9yrFqo/jt0CW30vsg=
github.com/GeertJohan/go.incremental v1.0.0/go.mod h1:6fAjUhbVuX1KcMD3c8TEgVUqmo4seqhv0i0kdATSkM0=
github.com/GeertJohan/go.rice v1.0.0 h1:KkI6O9uMaQU3VEKaj01ulavtF7o1fWT7+pk/4voiMLQ=
Expand All @@ -26,6 +26,8 @@ github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPU
golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a h1:gOpx8G595UYyvj8UK4+OFyY4rx037g3fmfhe5SasG3U=
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/sys v0.0.0-20191010194322-b09406accb47 h1:/XfQ9z7ib8eEJX2hdgFTZJ/ntt0swNk5oYBziWeTCvY=
golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
11 changes: 11 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"GoSubTitleSearcher/config"
"GoSubTitleSearcher/ui"
"fmt"
"os"

"GoSubTitleSearcher/server"
Expand All @@ -15,6 +16,16 @@ func init() {

}
func main() {
lf := xlog.OpenFile(config.AppPath + "/logs.txt")
if lf == nil {
fmt.Errorf("Failed to open log file")
return
}
defer lf.Close()

defer xlog.Init("APP", true, false, lf).Close()
xlog.Info("############################ start app ################################")

// if config.IsDebug {
// xlog.Std = xlog.NewFile(config.AppPath+"/logs.txt", "", xlog.Ldefault)
// }
Expand Down
5 changes: 4 additions & 1 deletion res/html/mainwin.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@
</li>
<li>
<div>软件网址:</div>
<div><a href="https://github.com/Andyfoo/GoSubTitleSearcher" class="e_link">github.com/Andyfoo/GoSubTitleSearcher</a></div>
<div>
<a href="https://gitee.com/Andyfoo/GoSubTitleSearcher" class="e_link">gitee.com/Andyfoo/GoSubTitleSearcher</a><br>
<a href="https://github.com/Andyfoo/GoSubTitleSearcher" class="e_link">github.com/Andyfoo/GoSubTitleSearcher</a>
</div>
</li>
</ul>
<div class="info">
Expand Down
48 changes: 24 additions & 24 deletions server/rice-box.go

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions spider/down_zimu_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
)

func Test1(t *testing.T) {
fmt.Println("test")
config.SetMovFile("E:/_tmp/mov/downsizing.2017.720p.bluray.x264-geckos.mkv")
// var a, _ = sheshou.GetList("E:/_tmp/mov/downsizing.2017.720p.bluray.x264-geckos.mkv")
// for k, v := range *a {
Expand All @@ -23,8 +24,8 @@ func testSearchList() {
SearchList(searchParm)
//GBK Big5 UTF-8
//Down(1, config.DownParmS{config.FilenameType_DEF, true, "UTF-8"})
downResult := Down(2, config.DownParmS{config.FilenameType_DEF, false, "UTF-8"})
DownArchive(downResult.ArchiveKey, downResult.ArchiveFilelist[0].Filename, config.DownParmS{})
//downResult := Down(2, config.DownParmS{config.FilenameType_DEF, false, "UTF-8"})
//DownArchive(downResult.ArchiveKey, downResult.ArchiveFilelist[0].Filename, config.DownParmS{})

fmt.Println(downResult)
//fmt.Println(downResult)
}
16 changes: 9 additions & 7 deletions ui/upgrader/upgrader.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"syscall"
"time"

"github.com/Andyfoo/go-xutils/xencode"
"github.com/Andyfoo/go-xutils/xlog"
)

Expand Down Expand Up @@ -107,22 +108,23 @@ func UpgradeApp() bool {

//killRun()
upgradeStr := ""
upgradeStr += fmt.Sprintf("TASKKILL /F /IM %s\n", AppName)
upgradeStr += fmt.Sprintf("ping -n 3 127.0.0.1>nul\n")
upgradeStr += fmt.Sprintf("TASKKILL /F /IM %s\r\n", AppName)
upgradeStr += fmt.Sprintf("ping -n 3 127.0.0.1>nul\r\n")

if JsonConfig.Type == "zip" {
unzip(appData, upgradePath)
upgradeStr += fmt.Sprintf("xcopy /Q /E /Y %s\\%s\\* %s\n", upgradePath, strings.TrimRight(AppName, ".exe"), AppPath)
upgradeStr += fmt.Sprintf("xcopy /Q /E /Y \"%s\\%s\\*\" \"%s\"\r\n", upgradePath, strings.TrimRight(AppName, ".exe"), AppPath)
} else if JsonConfig.Type == "exe" {
ioutil.WriteFile(upgradePath+"/"+AppName, appData, 0755)
upgradeStr += fmt.Sprintf("copy /Y %s\\%s %s%s\n", upgradePath, AppName, AppPath, AppName)
upgradeStr += fmt.Sprintf("copy /Y \"%s\\%s\" \"%s%s\"\r\n", upgradePath, AppName, AppPath, AppName)
} else {
xlog.Errorf("type is error: %v\n", JsonConfig.Type)
return false
}
upgradeStr += fmt.Sprintf("start %s%s\n", AppPath, AppName)
upgradeStr += fmt.Sprintf("start %s%s\r\n", AppPath, AppName)
upgradeStr = xencode.Utf8ToGbkStr(upgradeStr)
ioutil.WriteFile(upgradeFile, []byte(upgradeStr), 0755)
fmt.Println(upgradeStr)
//fmt.Println(upgradeStr)
runBatFile(upgradeFile)
xlog.Infof("upgrade finish\n")

Expand All @@ -146,7 +148,7 @@ func Mkdir(path string) bool {
return false
}
func runBatFile(file string) {
cmd := exec.Command(file)
cmd := exec.Command("cmd", "/c", file)
cmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true}
err := cmd.Start()
if err != nil {
Expand Down

0 comments on commit 0d78e9e

Please sign in to comment.