🚧 Ask for next step
This commit is contained in:
		
					parent
					
						
							
								c941ed3302
							
						
					
				
			
			
				commit
				
					
						5472d7376a
					
				
			
		
					 5 changed files with 26 additions and 11 deletions
				
			
		|  | @ -3,11 +3,11 @@ package app | ||||||
| import ( | import ( | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"os" | 	"os" | ||||||
| 	p "path" |  | ||||||
| 
 | 
 | ||||||
| 	"codeberg.org/danjones000/strip-beats/files" | 	"codeberg.org/danjones000/strip-beats/files" | ||||||
| 	"codeberg.org/danjones000/strip-beats/input/boolean" | 	"codeberg.org/danjones000/strip-beats/input/boolean" | ||||||
| 	"codeberg.org/danjones000/strip-beats/media" | 	"codeberg.org/danjones000/strip-beats/media" | ||||||
|  | 	"codeberg.org/danjones000/strip-beats/utils" | ||||||
| 	"github.com/rkoesters/xdg/trash" | 	"github.com/rkoesters/xdg/trash" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
|  | @ -37,7 +37,7 @@ func PickFileWithConf() media.Probe { | ||||||
| 	good := false | 	good := false | ||||||
| 	for !good { | 	for !good { | ||||||
| 		path = files.PickRandomFile() | 		path = files.PickRandomFile() | ||||||
| 		msg = fmt.Sprintf("We've selected %s\nIs that ok?", getShortPath(path)) | 		msg = fmt.Sprintf("We've selected %s\nIs that ok?", utils.GetShortPath(path)) | ||||||
| 		good = boolean.Choose(msg) | 		good = boolean.Choose(msg) | ||||||
| 		if !good { | 		if !good { | ||||||
| 			good = boolean.Choose("Would you like to quit?") | 			good = boolean.Choose("Would you like to quit?") | ||||||
|  | @ -81,10 +81,3 @@ func Finish() { | ||||||
| 	} | 	} | ||||||
| 	PickAgain() | 	PickAgain() | ||||||
| } | } | ||||||
| 
 |  | ||||||
| func getShortPath(path string) string { |  | ||||||
| 	base := p.Base(path) |  | ||||||
| 	dir := p.Dir(path) |  | ||||||
| 	dir = p.Base(dir) |  | ||||||
| 	return fmt.Sprintf("%s/%s", dir, base) |  | ||||||
| } |  | ||||||
|  |  | ||||||
|  | @ -4,6 +4,7 @@ import ( | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"os" | 	"os" | ||||||
| 
 | 
 | ||||||
|  | 	"codeberg.org/danjones000/strip-beats/input/boolean" | ||||||
| 	"codeberg.org/danjones000/strip-beats/media" | 	"codeberg.org/danjones000/strip-beats/media" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
|  | @ -31,11 +32,15 @@ func Run(step AppStep) { | ||||||
| 			if file == nil { | 			if file == nil { | ||||||
| 				quit() | 				quit() | ||||||
| 			} | 			} | ||||||
|  | 			watch := boolean.Choose(fmt.Sprintf("Would you like to watch %s?", file.ShortPath())) | ||||||
|  | 			if watch { | ||||||
|  | 				step = Watch | ||||||
|  | 			} | ||||||
| 		case Watch: | 		case Watch: | ||||||
| 			media.Watch(file.Format.Path) | 			media.Watch(file.Format.Path) | ||||||
|  | 			step = Quit // @todo | ||||||
| 		case Quit: | 		case Quit: | ||||||
| 			quit() | 			quit() | ||||||
| 		} | 		} | ||||||
| 		step = (step + 1) % Restart |  | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -8,7 +8,6 @@ import ( | ||||||
| 	"os" | 	"os" | ||||||
| 
 | 
 | ||||||
| 	"codeberg.org/danjones000/strip-beats/app" | 	"codeberg.org/danjones000/strip-beats/app" | ||||||
| 	// "codeberg.org/danjones000/strip-beats/input/boolean" |  | ||||||
| 	// "codeberg.org/danjones000/strip-beats/input/list" | 	// "codeberg.org/danjones000/strip-beats/input/list" | ||||||
| 	"github.com/spf13/cobra" | 	"github.com/spf13/cobra" | ||||||
| ) | ) | ||||||
|  |  | ||||||
|  | @ -2,6 +2,7 @@ package media | ||||||
| 
 | 
 | ||||||
| import ( | import ( | ||||||
| 	"codeberg.org/danjones000/strip-beats/config" | 	"codeberg.org/danjones000/strip-beats/config" | ||||||
|  | 	"codeberg.org/danjones000/strip-beats/utils" | ||||||
| 	"encoding/json" | 	"encoding/json" | ||||||
| 	"github.com/akrennmair/slice" | 	"github.com/akrennmair/slice" | ||||||
| 	ffmpeg "github.com/u2takey/ffmpeg-go" | 	ffmpeg "github.com/u2takey/ffmpeg-go" | ||||||
|  | @ -62,6 +63,10 @@ func (p Probe) GetFirstAcceptableAudio() *Stream { | ||||||
| 	return sts[0] | 	return sts[0] | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | func (pr Probe) ShortPath() string { | ||||||
|  | 	return utils.GetShortPath(pr.Format.Path) | ||||||
|  | } | ||||||
|  | 
 | ||||||
| func (pr Probe) WantedAudioStream() *Stream { | func (pr Probe) WantedAudioStream() *Stream { | ||||||
| 	count := pr.GetAudioCount() | 	count := pr.GetAudioCount() | ||||||
| 	if count < 1 { | 	if count < 1 { | ||||||
|  |  | ||||||
							
								
								
									
										13
									
								
								utils/utils.go
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								utils/utils.go
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,13 @@ | ||||||
|  | package utils | ||||||
|  | 
 | ||||||
|  | import ( | ||||||
|  | 	"fmt" | ||||||
|  | 	p "path" | ||||||
|  | ) | ||||||
|  | 
 | ||||||
|  | func GetShortPath(path string) string { | ||||||
|  | 	base := p.Base(path) | ||||||
|  | 	dir := p.Dir(path) | ||||||
|  | 	dir = p.Base(dir) | ||||||
|  | 	return fmt.Sprintf("%s/%s", dir, base) | ||||||
|  | } | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue