77 "github.com/sirupsen/logrus"
88 "m4s-converter/conver"
99 "os"
10+ "os/exec"
1011 "path/filepath"
1112 "strconv"
1213 "strings"
@@ -83,6 +84,8 @@ func (c *Config) Synthesis() {
8384 if itemId == 0 || e != nil {
8485 itemId , _ = js .Get ("owner_id" ).Int ()
8586 }
87+ c .ItemId = strconv .Itoa (itemId )
88+
8689 if status != "completed" && status != "视频已缓存完成" {
8790 skipFilePaths = append (skipFilePaths , v )
8891 logrus .Warn ("未缓存完成,跳过合成" , v , title + "-" + uname )
@@ -102,12 +105,12 @@ func (c *Config) Synthesis() {
102105 mp4Name := title + conver .Mp4Suffix
103106 outputFile := filepath .Join (groupDir , mp4Name )
104107 newFile := filepath .Join (groupPath , mp4Name )
105- if Exist (outputFile ) && c .Skip {
108+ if c . Skip || Exist (outputFile ) && c .findMp4Info ( outputFile , c . ItemId ) {
106109 logrus .Warn ("跳过已合成的文件:" , newFile )
107110 continue
108111 }
109112 if Exist (outputFile ) && ! c .Overlay {
110- outputFile = filepath .Join (groupDir , title + strconv . Itoa ( itemId ) + conver .Mp4Suffix )
113+ outputFile = filepath .Join (groupDir , title + c . ItemId + conver .Mp4Suffix )
111114 }
112115
113116 if er := c .Composition (video , audio , outputFile ); er != nil {
@@ -135,6 +138,17 @@ func (c *Config) Synthesis() {
135138 c .wait ()
136139}
137140
141+ func (c * Config ) findMp4Info (fp , sub string ) bool {
142+ if ! Exist (c .GPACPath ) {
143+ return false
144+ }
145+ ret , err := exec .Command (c .GPACPath , "-info" , fp ).CombinedOutput ()
146+ if err != nil {
147+ return false
148+ }
149+ return strings .Contains (string (ret ), sub )
150+ }
151+
138152func null2Str (s string , value string ) string {
139153 if s != "" {
140154 return s
0 commit comments