Skip to content

Commit 958c26e

Browse files
committed
improve README
1 parent c55001e commit 958c26e

File tree

3 files changed

+21
-24
lines changed

3 files changed

+21
-24
lines changed

ccdb.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ func NewFromCCDBCapture(s string) (res Subtitle, err error) {
2525
continue
2626
}
2727
if parseText {
28-
// log.Println("TEXT:", row)
2928
if row == "\r" || row == "" {
30-
parseText = false // XXX until text = empty
29+
parseText = false
3130
} else {
3231
row = strings.TrimSpace(row)
3332
if row != "" {
@@ -46,7 +45,6 @@ func NewFromCCDBCapture(s string) (res Subtitle, err error) {
4645
}
4746
break
4847
}
49-
// log.Println("TIME:", row)
5048
parts := strings.SplitN(row, ",", 2)
5149
if len(parts) == 2 {
5250
caption.Start, _ = parseCCDBTime(parts[0])

cmd/subber/README.md

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# About
1+
## About
22

33
Subber is a cli tool for reading,
44
writing and manipulating .srt subtitle files
@@ -21,17 +21,19 @@ So, sometimes "other software" needs a cleaned up .srt,
2121
and the `subber` cli app automates this task.
2222

2323

24-
# Installation
24+
## Installation
2525

26+
Windows and macOS binaries are available under [Releases](https://github.com/martinlindhe/subtitles/releases)
2627

28+
Or if you have golang installed, you can compile from source:
2729
```
2830
go install github.com/martinlindhe/subtitles/cmd/subber
2931
```
3032

3133

32-
# Usage
34+
## Usage
3335

34-
To download subtitles for a video file:
36+
### To download subtitles for a video file
3537

3638
```
3739
$ subber movie.mp4
@@ -51,27 +53,37 @@ Some additional flags (use `-h` for full list) includes:
5153
* `--sync="-3000"` Moves all captions backwards by 3000 ms
5254

5355

54-
Remove ads from an existing .srt file:
56+
### Remove ads from an existing .srt file
5557

5658
```
5759
$ subber subtitle.srt
5860
5961
Removing caption 21 [<font color="#FFFF00"> Captions by VITAC </font><font color="#00FFFF"> www.vitac.com</font>]
6062
```
6163

62-
Strip html tags from .srt:
64+
### Strip html tags from .srt
6365

6466
```
6567
$ subber subtitle.srt --filter="html"
6668
6769
[html] <i>And there's a lot of it there.</i> -> And there's a lot of it there.
6870
```
6971

70-
Normalize capitalization in .srt:
72+
### Normalize capitalization in .srt
7173

7274
```
7375
$ subber subtitle.srt --filter="caps"
7476
7577
[caps] INTRODUCING -> Introducing
7678
[caps] right, to go? -> Right, to go?
7779
```
80+
81+
### Convert a .ssa to a .srt
82+
83+
```
84+
$ subber subtitle.ssa -o subtitle.srt
85+
```
86+
87+
## License
88+
89+
Under [MIT](LICENSE)

cmd/subber/subber.go

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ func cleanupSub(data []byte, filterName string, keepAds bool, sync int) (string,
8989
}
9090

9191
func action(inFileName, outFileName string) error {
92-
9392
if outFileName == "" {
9493
outFileName = inFileName
9594
}
@@ -138,7 +137,6 @@ func action(inFileName, outFileName string) error {
138137
}
139138
return nil
140139
}
141-
backupSub(subFileName)
142140
out, _ = cleanupSub(data, *filterName, *keepAds, *sync)
143141
err = writeText(subFileName, *skipBackups, out)
144142
if err != nil {
@@ -148,24 +146,13 @@ func action(inFileName, outFileName string) error {
148146
return nil
149147
}
150148

151-
func backupSub(fileName string) {
152-
log.Println("XXX TODO impl backupSub")
153-
}
154-
155149
func writeText(outFileName string, skipBackups bool, text string) error {
156-
157150
if !skipBackups && fileExists(outFileName) {
158151
backupFileName := outFileName + ".org"
159152
os.Rename(outFileName, backupFileName)
160153
// fmt.Printf("Backed up to %s\n", backupFileName)
161154
}
162-
163-
err := ioutil.WriteFile(outFileName, []byte(text), 0644)
164-
if err != nil {
165-
return err
166-
}
167-
168-
return nil
155+
return ioutil.WriteFile(outFileName, []byte(text), 0644)
169156
}
170157

171158
func fileExists(name string) bool {

0 commit comments

Comments
 (0)