Tag files

This commit is contained in:
Dan Jones 2023-11-12 22:10:31 -06:00
commit ed7e1ddade
8 changed files with 172 additions and 4 deletions

View file

@ -20,6 +20,7 @@ func PickNewFile() media.Probe {
}
func SetFile(path string) media.Probe {
resetTags()
f := media.ProbeFile(path)
file = &f
copyTagsFromFile()
@ -71,6 +72,7 @@ func PickAgain() {
}
file = nil
tmpfile = nil
resetTags()
}
func Finish() {

16
app/convert.go Normal file
View file

@ -0,0 +1,16 @@
package app
import (
"fmt"
"codeberg.org/danjones000/strip-beats/media"
"codeberg.org/danjones000/strip-beats/utils"
)
func convert() {
in := utils.Tern(tmpfile == nil, file, tmpfile)
out, _ := media.ConvertAndTag(*in, tags)
fmt.Println(out)
quit()
}

View file

@ -2,6 +2,8 @@ package app
import (
"os"
p "path/filepath"
s "strings"
"codeberg.org/danjones000/strip-beats/media"
"codeberg.org/danjones000/strip-beats/utils"
@ -31,7 +33,10 @@ func validateNumber(input string, lastChar rune) bool {
}
func fadeFile() error {
tmp, err := os.CreateTemp("", "audio.*.mka")
base := p.Base(file.Format.Path)
ext := p.Ext(base)
base = s.TrimSuffix(base, ext)
tmp, err := os.CreateTemp("", base+".*.mka")
if err != nil {
return err
}

View file

@ -10,7 +10,7 @@ func (st AppStep) Title() string {
mustpick := "You need to pick a file"
switch st {
case Pick:
return "Pick a new show"
return "Pick a new file"
case Watch:
if file == nil {
return mustpick
@ -26,6 +26,11 @@ func (st AppStep) Title() string {
return mustpick
}
return fmt.Sprintf("Should we try to identify %s", file.ShortPath())
case Convert:
if file == nil {
return mustpick
}
return fmt.Sprintf("Convert %s?", file.ShortPath())
case Restart:
return "Forget current selection"
case Quit:
@ -54,6 +59,8 @@ func (st AppStep) Rune() rune {
return 'r'
case Print:
return 'a'
case Convert:
return 'c'
case Quit:
return 'q'
default:
@ -70,7 +77,7 @@ func mainMenu() AppStep {
if file == nil {
steps = []list.Option{Pick, Quit}
} else {
steps = []list.Option{Pick, Watch, Fade, Print, Quit}
steps = []list.Option{Pick, Watch, Fade, Print, Convert, Quit}
}
step := list.List("What would you like to do next?", steps, nil)

View file

@ -16,6 +16,7 @@ const (
Watch
Fade
Print
Convert
Restart
Quit
)
@ -94,6 +95,9 @@ func Run(step AppStep) {
case Print:
print()
step = mainMenu()
case Convert:
convert()
step = mainMenu()
case Quit:
quit()
default:

View file

@ -8,6 +8,10 @@ import (
var tags t.Tags
func resetTags() {
tags = t.Tags{}
}
func copyTagsFromFile() {
if file == nil {
panic(errors.New("Missing file"))