修改模块名: lrc2lts => ltc (LrcToCaptions)
This commit is contained in:
parent
3e2af31678
commit
a29d2c057e
16 changed files with 30 additions and 29 deletions
1
.idea/.name
generated
Normal file
1
.idea/.name
generated
Normal file
|
@ -0,0 +1 @@
|
||||||
|
ltc
|
0
.idea/lrc2srt.iml → .idea/ltc.iml
generated
0
.idea/lrc2srt.iml → .idea/ltc.iml
generated
2
.idea/modules.xml
generated
2
.idea/modules.xml
generated
|
@ -2,7 +2,7 @@
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ProjectModuleManager">
|
<component name="ProjectModuleManager">
|
||||||
<modules>
|
<modules>
|
||||||
<module fileurl="file://$PROJECT_DIR$/.idea/lrc2srt.iml" filepath="$PROJECT_DIR$/.idea/lrc2srt.iml" />
|
<module fileurl="file://$PROJECT_DIR$/.idea/ltc.iml" filepath="$PROJECT_DIR$/.idea/ltc.iml" />
|
||||||
</modules>
|
</modules>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
|
@ -1,4 +1,4 @@
|
||||||
package lrc2srt
|
package ltc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package lrc2srt
|
package ltc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -1,4 +1,4 @@
|
||||||
module github.com/Hami-Lemon/lrc2srt
|
module github.com/Hami-Lemon/ltc
|
||||||
|
|
||||||
go 1.18
|
go 1.18
|
||||||
|
|
||||||
|
|
4
lrc.go
4
lrc.go
|
@ -1,11 +1,11 @@
|
||||||
package lrc2srt
|
package ltc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/Hami-Lemon/lrc2srt/glist"
|
"github.com/Hami-Lemon/ltc/glist"
|
||||||
)
|
)
|
||||||
|
|
||||||
type LRCNode struct {
|
type LRCNode struct {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package lrc2srt
|
package ltc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
echo off
|
echo off
|
||||||
@REM forceposix 表示在windows上参数也为linux风格,即以“-”开头
|
@REM forceposix 表示在windows上参数也为linux风格,即以“-”开头
|
||||||
go build -tags="forceposix" -ldflags "-s -w" -o lts.exe .
|
go build -tags="forceposix" -ldflags "-s -w" -o ltc.exe .
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
l2s "github.com/Hami-Lemon/lrc2srt"
|
"github.com/Hami-Lemon/ltc"
|
||||||
"github.com/jessevdk/go-flags"
|
"github.com/jessevdk/go-flags"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ func main() {
|
||||||
}
|
}
|
||||||
//显示版本信息
|
//显示版本信息
|
||||||
if opt.Version {
|
if opt.Version {
|
||||||
fmt.Printf("LrcToSrt(lts) version: %s\n", VERSION)
|
fmt.Printf("LrcToCaptions(ltc) version: %s\n", VERSION)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
//获取保存的文件名
|
//获取保存的文件名
|
||||||
|
@ -51,9 +51,9 @@ func main() {
|
||||||
var lyric, tranLyric string
|
var lyric, tranLyric string
|
||||||
if opt.Id != "" {
|
if opt.Id != "" {
|
||||||
if opt.Source != "163" {
|
if opt.Source != "163" {
|
||||||
lyric, tranLyric = l2s.GetQQLyric(opt.Id)
|
lyric, tranLyric = ltc.GetQQLyric(opt.Id)
|
||||||
} else {
|
} else {
|
||||||
lyric, tranLyric = l2s.Get163Lyric(opt.Id)
|
lyric, tranLyric = ltc.Get163Lyric(opt.Id)
|
||||||
}
|
}
|
||||||
//下载歌词
|
//下载歌词
|
||||||
if opt.Download {
|
if opt.Download {
|
||||||
|
@ -64,9 +64,9 @@ func main() {
|
||||||
} else if !strings.HasSuffix(o, ".lrc") {
|
} else if !strings.HasSuffix(o, ".lrc") {
|
||||||
o += ".lrc"
|
o += ".lrc"
|
||||||
}
|
}
|
||||||
l2s.WriteFile(o, lyric)
|
ltc.WriteFile(o, lyric)
|
||||||
if tranLyric != "" {
|
if tranLyric != "" {
|
||||||
l2s.WriteFile("tran_"+o, tranLyric)
|
ltc.WriteFile("tran_"+o, tranLyric)
|
||||||
}
|
}
|
||||||
fmt.Println("下载歌词完成!")
|
fmt.Println("下载歌词完成!")
|
||||||
return
|
return
|
||||||
|
@ -77,7 +77,7 @@ func main() {
|
||||||
fmt.Println("Error: 不支持的格式,目前只支持lrc歌词文件。")
|
fmt.Println("Error: 不支持的格式,目前只支持lrc歌词文件。")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
lyric = l2s.ReadFile(opt.Input)
|
lyric = ltc.ReadFile(opt.Input)
|
||||||
if lyric == "" {
|
if lyric == "" {
|
||||||
fmt.Println("获取歌词失败,文件内容为空。")
|
fmt.Println("获取歌词失败,文件内容为空。")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
@ -86,17 +86,17 @@ func main() {
|
||||||
fmt.Println("Error: 请指定需要转换的歌词。")
|
fmt.Println("Error: 请指定需要转换的歌词。")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
lrc, lrcT := l2s.ParseLRC(lyric), l2s.ParseLRC(tranLyric)
|
lrc, lrcT := ltc.ParseLRC(lyric), ltc.ParseLRC(tranLyric)
|
||||||
srt, srtT := l2s.LrcToSrt(lrc), l2s.LrcToSrt(lrcT)
|
srt, srtT := ltc.LrcToSrt(lrc), ltc.LrcToSrt(lrcT)
|
||||||
if srtT != nil {
|
if srtT != nil {
|
||||||
var mode l2s.SRTMergeMode
|
var mode ltc.SRTMergeMode
|
||||||
switch opt.Mode {
|
switch opt.Mode {
|
||||||
case 1:
|
case 1:
|
||||||
mode = l2s.SRT_MERGE_MODE_STACK
|
mode = ltc.SRT_MERGE_MODE_STACK
|
||||||
case 2:
|
case 2:
|
||||||
mode = l2s.SRT_MERGE_MODE_UP
|
mode = ltc.SRT_MERGE_MODE_UP
|
||||||
case 3:
|
case 3:
|
||||||
mode = l2s.SRT_MERGE_MODE_BOTTOM
|
mode = ltc.SRT_MERGE_MODE_BOTTOM
|
||||||
}
|
}
|
||||||
srt.Merge(srtT, mode)
|
srt.Merge(srtT, mode)
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,7 @@ func main() {
|
||||||
//如果是相对路径,父目录即是当前运行路径
|
//如果是相对路径,父目录即是当前运行路径
|
||||||
dir, er := os.Getwd()
|
dir, er := os.Getwd()
|
||||||
if er == nil {
|
if er == nil {
|
||||||
name = dir + name
|
name = dir + string(os.PathSeparator) + name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fmt.Printf("保存结果为:%s\n", name)
|
fmt.Printf("保存结果为:%s\n", name)
|
|
@ -1,4 +1,4 @@
|
||||||
package lrc2srt
|
package ltc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"compress/gzip"
|
"compress/gzip"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package lrc2srt
|
package ltc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
4
srt.go
4
srt.go
|
@ -1,9 +1,9 @@
|
||||||
package lrc2srt
|
package ltc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/Hami-Lemon/lrc2srt/glist"
|
"github.com/Hami-Lemon/ltc/glist"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package lrc2srt
|
package ltc
|
||||||
|
|
||||||
import "testing"
|
import "testing"
|
||||||
|
|
||||||
|
|
2
util.go
2
util.go
|
@ -1,4 +1,4 @@
|
||||||
package lrc2srt
|
package ltc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package lrc2srt
|
package ltc
|
||||||
|
|
||||||
import "testing"
|
import "testing"
|
||||||
|
|
||||||
|
|
Reference in a new issue