MCPcopy
hub / github.com/ChineseSubFinder/ChineseSubFinder / IsExported

Method IsExported

pkg/ffmpeg_helper/ffmpeg_info.go:44–105  ·  view source on GitHub ↗

IsExported 是否已经导出过,如果没有导出或者导出不完整为 false

(exportType ExportType)

Source from the content-addressed store, hash-verified

42
43// IsExported 是否已经导出过,如果没有导出或者导出不完整为 false
44func (f *FFMPEGInfo) IsExported(exportType ExportType) bool {
45
46 bProcessDone := false
47 nowCacheFolder, err := f.GetCacheFolderFPath()
48 if err != nil {
49 f.log.Errorln("FFMPEGInfo.IsExported.GetCacheFolderFPath", f.VideoFullPath, err.Error())
50 return false
51 }
52 tmpNowExportedMaskFile := filepath.Join(nowCacheFolder, exportedMakeFileName)
53
54 defer func() {
55 // 函数执行完毕,再进行 check,是否需要删除 exportedMakeFileName 这个文件
56 if bProcessDone == false {
57 // 失败就需要删除这个 exportedMakeFileName 文件
58 if pkg.IsFile(tmpNowExportedMaskFile) == true {
59 _ = os.Remove(tmpNowExportedMaskFile)
60 }
61 }
62 }()
63
64 // 首先存储的缓存目录要存在
65 if pkg.IsDir(nowCacheFolder) == false {
66 return bProcessDone
67 }
68
69 if pkg.IsFile(tmpNowExportedMaskFile) == false {
70 return bProcessDone
71 }
72
73 switch exportType {
74 case Audio:
75 // 音频是否导出了
76 done := f.isAudioExported(nowCacheFolder)
77 if done == false {
78 return bProcessDone
79 }
80 break
81 case Subtitle:
82 // 字幕都要导出了
83 done := f.isSubExported(nowCacheFolder)
84 if done == false {
85 return bProcessDone
86 }
87 case SubtitleAndAudio:
88 // 音频是否导出了
89 done := f.isAudioExported(nowCacheFolder)
90 if done == false {
91 return bProcessDone
92 }
93 // 字幕都要导出了
94 done = f.isSubExported(nowCacheFolder)
95 if done == false {
96 return bProcessDone
97 }
98 default:
99 return bProcessDone
100 }
101

Callers 1

ExportFFMPEGInfoMethod · 0.80

Calls 5

GetCacheFolderFPathMethod · 0.95
isAudioExportedMethod · 0.95
isSubExportedMethod · 0.95
IsFileFunction · 0.92
IsDirFunction · 0.92

Tested by

no test coverage detected