Skip to content

Commit 2585bc9

Browse files
committed
recorder: #32 fix not matched filename bug
1 parent b672379 commit 2585bc9

5 files changed

Lines changed: 9 additions & 17 deletions

File tree

src/parser/ffmpeg.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package parser
33
import (
44
"io"
55
"os/exec"
6-
"path/filepath"
76
"sync"
87

98
l "github.com/go-olive/olive/src/log"
@@ -45,9 +44,6 @@ func (p *ffmpeg) Type() string {
4544
}
4645

4746
func (p *ffmpeg) Parse(streamURL string, out string) (err error) {
48-
ext := filepath.Ext(out)
49-
out = out[0:len(out)-len(ext)] + ".flv"
50-
5147
l.Logger.WithFields(logrus.Fields{
5248
// "streamURL": streamURL,
5349
"out": out,

src/parser/flv.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package parser
22

33
import (
4-
"path/filepath"
5-
64
"github.com/go-olive/flv"
75
l "github.com/go-olive/olive/src/log"
86
"github.com/sirupsen/logrus"
@@ -25,9 +23,6 @@ func (this *customFlv) New() Parser {
2523
}
2624

2725
func (this *customFlv) Parse(streamURL string, out string) (err error) {
28-
ext := filepath.Ext(out)
29-
out = out[0:len(out)-len(ext)] + ".flv"
30-
3126
l.Logger.WithFields(logrus.Fields{
3227
// "streamURL": streamURL,
3328
"out": out,

src/parser/streamlink.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package parser
33
import (
44
"io"
55
"os/exec"
6-
"path/filepath"
76
"sync"
87

98
l "github.com/go-olive/olive/src/log"
@@ -42,9 +41,6 @@ func (s *streamlink) Type() string {
4241

4342
// streamlink -o "a.mp4" https://www.twitch.tv/nnabi best -f
4443
func (s *streamlink) Parse(streamURL string, out string) (err error) {
45-
ext := filepath.Ext(out)
46-
out = out[0:len(out)-len(ext)] + ".flv"
47-
4844
l.Logger.WithFields(logrus.Fields{
4945
// "streamURL": streamURL,
5046
"out": out,

src/parser/ytdlp.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package parser
33
import (
44
"io"
55
"os/exec"
6-
"path/filepath"
76
"sync"
87

98
l "github.com/go-olive/olive/src/log"
@@ -42,9 +41,6 @@ func (p *ytdlp) Type() string {
4241

4342
// yt-dlp -f "bv[height=1080]+ba/b" https://www.youtube.com/watch?v=f6PdkucL1hk
4443
func (p *ytdlp) Parse(streamURL string, out string) (err error) {
45-
ext := filepath.Ext(out)
46-
out = out[0:len(out)-len(ext)] + ".mp4"
47-
4844
l.Logger.WithFields(logrus.Fields{
4945
// "streamURL": streamURL,
5046
"out": out,

src/recorder/recorder.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,15 @@ func (r *recorder) record() error {
199199
}
200200
out = filepath.Join(saveDir, out)
201201

202+
switch r.parser.Type() {
203+
case "yt-dlp":
204+
ext := filepath.Ext(out)
205+
out = out[0:len(out)-len(ext)] + ".mp4"
206+
default:
207+
ext := filepath.Ext(out)
208+
out = out[0:len(out)-len(ext)] + ".flv"
209+
}
210+
202211
r.startTime = time.Now()
203212
r.out = out
204213

0 commit comments

Comments
 (0)