feat: vtt converting
This commit is contained in:
parent
ba2e477dc0
commit
ba66894e42
7 changed files with 693 additions and 107 deletions
30
internal/format/txt/txt.go
Normal file
30
internal/format/txt/txt.go
Normal file
|
@ -0,0 +1,30 @@
|
|||
package txt
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"sub-cli/internal/model"
|
||||
)
|
||||
|
||||
// GenerateFromSubtitle converts our intermediate Subtitle to plain text format
|
||||
func GenerateFromSubtitle(subtitle model.Subtitle, filePath string) error {
|
||||
file, err := os.Create(filePath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error creating TXT file: %w", err)
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
// Write title if available
|
||||
if subtitle.Title != "" {
|
||||
fmt.Fprintln(file, subtitle.Title)
|
||||
fmt.Fprintln(file)
|
||||
}
|
||||
|
||||
// Write content without timestamps
|
||||
for _, entry := range subtitle.Entries {
|
||||
fmt.Fprintln(file, entry.Text)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue