mirror of
https://github.com/crunchy-labs/crunchy-cli.git
synced 2026-01-21 04:02:00 -06:00
Fix subtitle styling and size (#66)
This commit is contained in:
parent
0572af4e07
commit
95b66c3ff5
2 changed files with 37 additions and 1 deletions
|
|
@ -40,6 +40,8 @@ var (
|
|||
archiveResolutionFlag string
|
||||
|
||||
archiveGoroutinesFlag int
|
||||
|
||||
archiveNoSubtitleOptimizations bool
|
||||
)
|
||||
|
||||
var Cmd = &cobra.Command{
|
||||
|
|
@ -203,6 +205,11 @@ func init() {
|
|||
"g",
|
||||
runtime.NumCPU(),
|
||||
"Number of parallel segment downloads")
|
||||
|
||||
Cmd.Flags().BoolVar(&archiveNoSubtitleOptimizations,
|
||||
"no-subtitle-optimizations",
|
||||
false,
|
||||
"Disable subtitle optimizations. See https://github.com/crunchy-labs/crunchy-cli/issues/66 for more information")
|
||||
}
|
||||
|
||||
func archive(urls []string) error {
|
||||
|
|
@ -540,13 +547,38 @@ func archiveDownloadSubtitles(filename string, subtitles ...*crunchyroll.Subtitl
|
|||
}
|
||||
files = append(files, f.Name())
|
||||
|
||||
if err := subtitle.Save(f); err != nil {
|
||||
buffer := &bytes.Buffer{}
|
||||
|
||||
if err := subtitle.Save(buffer); err != nil {
|
||||
f.Close()
|
||||
for _, file := range files {
|
||||
os.Remove(file)
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if !archiveNoSubtitleOptimizations {
|
||||
buffer2 := &bytes.Buffer{}
|
||||
var scriptInfo bool
|
||||
for _, line := range strings.Split(buffer.String(), "\n") {
|
||||
if scriptInfo && strings.HasPrefix(strings.TrimSpace(line), "[") {
|
||||
buffer2.WriteString("ScaledBorderAndShadows: yes\n")
|
||||
scriptInfo = false
|
||||
} else if strings.TrimSpace(line) == "[Script Info]" {
|
||||
scriptInfo = true
|
||||
}
|
||||
buffer2.WriteString(line + "\n")
|
||||
}
|
||||
|
||||
if _, err = io.Copy(f, buffer2); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
if _, err = io.Copy(f, buffer); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
f.Close()
|
||||
|
||||
utils.Log.Debug("Downloaded '%s' subtitles", subtitle.Locale)
|
||||
|
|
|
|||
|
|
@ -146,6 +146,10 @@ The video resolution. Can either be specified via the pixels (e.g. 1920x1080), t
|
|||
|
||||
\fB-g, --goroutines GOROUTINES\fR
|
||||
Sets the number of parallel downloads for the segments the final video is made of. Default is the number of cores the computer has.
|
||||
.TP
|
||||
|
||||
\fB--no-subtitle-optimizations DISABLE\fR
|
||||
Disable subtitle optimizations which caused subtitle sizing and layout issues (https://github.com/crunchy-labs/crunchy-cli/issues/66).
|
||||
|
||||
.SH UPDATE COMMAND
|
||||
Checks if a newer version is available.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue