🚧 Work on fingerprinting music
This commit is contained in:
		
					parent
					
						
							
								dac33a7688
							
						
					
				
			
			
				commit
				
					
						cfef5a6c7a
					
				
			
		
					 3 changed files with 59 additions and 2 deletions
				
			
		
							
								
								
									
										12
									
								
								app/menu.go
									
										
									
									
									
								
							
							
						
						
									
										12
									
								
								app/menu.go
									
										
									
									
									
								
							|  | @ -21,6 +21,11 @@ func (st AppStep) Title() string { | |||
| 			return mustpick | ||||
| 		} | ||||
| 		return fmt.Sprintf("Trim and/or add fade to %s", file.ShortPath()) | ||||
| 	case Print: | ||||
| 		if file == nil { | ||||
| 			return mustpick | ||||
| 		} | ||||
| 		return fmt.Sprintf("Should we try to identify %s", file.ShortPath()) | ||||
| 	case Restart: | ||||
| 		return "Forget current selection" | ||||
| 	case Quit: | ||||
|  | @ -31,6 +36,9 @@ func (st AppStep) Title() string { | |||
| } | ||||
| 
 | ||||
| func (st AppStep) Text() string { | ||||
| 	if st == Print { | ||||
| 		return "Use fpcalc, AcousticId, and MusicBrainz to identify the song" | ||||
| 	} | ||||
| 	return "" | ||||
| } | ||||
| 
 | ||||
|  | @ -44,6 +52,8 @@ func (st AppStep) Rune() rune { | |||
| 		return 'f' | ||||
| 	case Restart: | ||||
| 		return 'r' | ||||
| 	case Print: | ||||
| 		return 'a' | ||||
| 	case Quit: | ||||
| 		return 'q' | ||||
| 	default: | ||||
|  | @ -60,7 +70,7 @@ func mainMenu() AppStep { | |||
| 	if file == nil { | ||||
| 		steps = []list.Option{Pick, Quit} | ||||
| 	} else { | ||||
| 		steps = []list.Option{Pick, Watch, Fade, Quit} | ||||
| 		steps = []list.Option{Pick, Watch, Fade, Print, Quit} | ||||
| 	} | ||||
| 
 | ||||
| 	step := list.List("What would you like to do next?", steps, nil) | ||||
|  |  | |||
							
								
								
									
										35
									
								
								app/print.go
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								app/print.go
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,35 @@ | |||
| package app | ||||
| 
 | ||||
| import ( | ||||
| 	"fmt" | ||||
| 
 | ||||
| 	"codeberg.org/danjones000/strip-beats/media" | ||||
| 	// "github.com/akrennmair/slice" | ||||
| ) | ||||
| 
 | ||||
| func print() { | ||||
| 	if file == nil { | ||||
| 		PickFileWithConf() | ||||
| 	} | ||||
| 	fp, err := media.Fingerprint("/home/drj/MyFiles/Videos/WebShows/YouTube/Dolly_Parton_-_Topic/Just_Because_I_m_a_Woman.Dolly_Parton_-_Topic.Fmv-XQerVkM.webm") | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	ids, err := media.LookupFingerprint(fp) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	var recs []media.MbRecording | ||||
| 	for _, res := range ids.Results { | ||||
| 		for _, rec := range res.Recordings { | ||||
| 			err = media.FillMbRecording(&rec) | ||||
| 			if err != nil { | ||||
| 				panic(err) | ||||
| 			} | ||||
| 			recs = append(recs, rec) | ||||
| 
 | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	fmt.Printf("%+v\n", recs) | ||||
| } | ||||
							
								
								
									
										14
									
								
								app/run.go
									
										
									
									
									
								
							
							
						
						
									
										14
									
								
								app/run.go
									
										
									
									
									
								
							|  | @ -14,6 +14,7 @@ const ( | |||
| 	Pick AppStep = iota | ||||
| 	Watch | ||||
| 	Fade | ||||
| 	Print | ||||
| 	Restart | ||||
| 	Quit | ||||
| ) | ||||
|  | @ -48,8 +49,16 @@ func testMb() { | |||
| 	quit() | ||||
| } | ||||
| 
 | ||||
| func testPrint() { | ||||
| 	SetFile("/home/drj/MyFiles/Videos/WebShows/YouTube/Dolly_Parton_-_Topic/Just_Because_I_m_a_Woman.Dolly_Parton_-_Topic.Fmv-XQerVkM.webm") | ||||
| 	print() | ||||
| 
 | ||||
| 	quit() | ||||
| } | ||||
| 
 | ||||
| func Run(step AppStep) { | ||||
| 	testMb() | ||||
| 	// testMb() | ||||
| 	testPrint() | ||||
| 	for step < Quit { | ||||
| 		switch step { | ||||
| 		case Pick: | ||||
|  | @ -79,6 +88,9 @@ func Run(step AppStep) { | |||
| 				media.Watch(tmpfile.Format.Path) | ||||
| 			} | ||||
| 			step = mainMenu() // @todo ask to check new file | ||||
| 		case Print: | ||||
| 			print() | ||||
| 			step = mainMenu() | ||||
| 		case Quit: | ||||
| 			quit() | ||||
| 		default: | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue