Skip to content

Commit

Permalink
More changes to support internal subs
Browse files Browse the repository at this point in the history
  • Loading branch information
alexballas committed Aug 22, 2024
1 parent bd420af commit e3e8b67
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
16 changes: 15 additions & 1 deletion internal/gui/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,20 @@ func playAction(screen *NewScreen) {
}
}

if screen.SelectInternalSubs.Selected != "" {
for n, opt := range screen.SelectInternalSubs.Options {
if opt == screen.SelectInternalSubs.Selected {
tempSubsPath, err := utils.ExtractSub(n, screen.mediafile)
if err != nil {
break
}

screen.tempFiles = append(screen.tempFiles, tempSubsPath)
screen.subsfile = tempSubsPath
}
}
}

screen.tvdata = &soapcalls.TVPayload{
ControlURL: screen.controlURL,
EventURL: screen.eventlURL,
Expand Down Expand Up @@ -479,10 +493,10 @@ func clearmediaAction(screen *NewScreen) {
}

func clearsubsAction(screen *NewScreen) {
screen.SelectInternalSubs.ClearSelected()
screen.SubsText.Text = ""
screen.subsfile = ""
screen.SubsText.Refresh()
screen.SelectInternalSubs.ClearSelected()
}

func skipNextAction(screen *NewScreen) {
Expand Down
11 changes: 11 additions & 0 deletions internal/gui/gui.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (

// NewScreen .
type NewScreen struct {
tempFiles []string
SelectInternalSubs *widget.Select
CurrentPos binding.String
EndPos binding.String
Expand Down Expand Up @@ -91,6 +92,16 @@ func (f *debugWriter) Write(b []byte) (int, error) {

// Start .
func Start(ctx context.Context, s *NewScreen) {
if s.tempFiles == nil {
s.tempFiles = make([]string, 0)
}

defer func() {
for _, file := range s.tempFiles {
os.Remove(file)
}
}()

w := s.Current
w.SetOnDropped(onDropFiles(s))

Expand Down

0 comments on commit e3e8b67

Please sign in to comment.