initial
This commit is contained in:
97
main.go
Normal file
97
main.go
Normal file
@@ -0,0 +1,97 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"time"
|
||||
// "stream_enregistre"
|
||||
// "stream_titre"
|
||||
)
|
||||
|
||||
const autocutDelai = 60 //s
|
||||
|
||||
// Le filename reçu se verra juste ajouter une extension ici (.mp3 ou .index)
|
||||
func Enregistre(filename string) {
|
||||
startTime := time.Now()
|
||||
fmt.Println("Started... ", startTime)
|
||||
fmt.Println(" Attendre quelques minutes et regarder dans le repertoire courant... ☺ ")
|
||||
fmt.Println(" <ctrl>C pour arrêter")
|
||||
|
||||
doneChanRecord := make(chan bool)
|
||||
errChanRecord := make(chan error)
|
||||
|
||||
doneChanTitle := make(chan bool)
|
||||
errChanTitle := make(chan error)
|
||||
|
||||
filenameStream := filename + ".mp3"
|
||||
filenameIndex := filename + ".index"
|
||||
|
||||
go Enregistre_stream(doneChanRecord, errChanRecord, filenameStream)
|
||||
go Enregistre_titres(doneChanTitle, errChanTitle, filenameIndex)
|
||||
|
||||
// Exécuter la fonction toutes les 'timer' millisecondes
|
||||
ticker := time.Tick(autocutDelai * time.Second)
|
||||
for range ticker {
|
||||
Cut(filenameStream, filenameIndex)
|
||||
}
|
||||
|
||||
// Attendre que les goroutines aient terminé
|
||||
successRecord := <-doneChanRecord
|
||||
if !successRecord {
|
||||
err := <-errChanRecord
|
||||
fmt.Println("Erreur enregistrement :", err)
|
||||
return
|
||||
}
|
||||
successTitle := <-doneChanTitle
|
||||
if !successTitle {
|
||||
err := <-errChanTitle
|
||||
fmt.Println("Erreur titres :", err)
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println("Programme terminé")
|
||||
}
|
||||
|
||||
func DecoupeAll() {
|
||||
|
||||
Cut("data/stream_recorded_2023-03-03T09:10:15.stripped.mp3", "data/index2023-03-03T09:10:14.txt")
|
||||
Cut("data/stream_recorded_2023-03-02T10:12:03.stripped.mp3", "data/index2023-03-02T10:12:03.txt")
|
||||
|
||||
//Cut("data/stream_recorded_2023-02-27T22:55:39.stripped.mp3", "data/index2023-02-27T22:55:39.txt")
|
||||
|
||||
Cut("data/stream_recorded_2023-03-01T20:20:48.stripped.mp3", "data/index2023-03-01T20:20:48.txt")
|
||||
|
||||
Cut("data/stream_recorded_2023-02-28T18:33:07.stripped.mp3", "data/index2023-02-28T18:33:07.txt")
|
||||
|
||||
Cut("data/stream_recorded_2023-03-01T08:16:54.stripped.mp3", "data/index2023-03-01T08:16:53.txt")
|
||||
|
||||
Cut("data/stream_recorded_2023-03-04T11:59:43.stripped.mp3", "data/index2023-03-04T11:59:43.txt")
|
||||
Cut("data/stream_recorded_2023-03-04T13:39:29.stripped.mp3", "data/index2023-03-04T13:39:28.txt")
|
||||
|
||||
Cut("data/rolanradio_2023-03-04T14:58:40.mp3", "data/index2023-03-04T14:58:40.txt")
|
||||
Cut("data/rolanradio_2023-03-04T18:26:17.mp3", "data/index2023-03-04T18:26:16.txt")
|
||||
Cut("data/rolanradio_2023-03-04T22:17:41.mp3", "data/index2023-03-04T22:17:40.txt")
|
||||
//Cut("data/", "data/")
|
||||
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
if len(os.Args) != 1 && len(os.Args) != 4 {
|
||||
fmt.Println("Usage: ")
|
||||
fmt.Println(" stream : enregistre et decoupe 'en direct' ")
|
||||
fmt.Println(" stream cut ficher_mp3 fichier_index : découpe un mp3 compte tenu de l'index")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if len(os.Args) == 4 && os.Args[1] == "cut" {
|
||||
mp3 := os.Args[2]
|
||||
index := os.Args[3]
|
||||
Cut(mp3, index)
|
||||
} else {
|
||||
strdate := time.Now().Format("2006-01-02T15:04:05")
|
||||
filename := fmt.Sprintf("%s_%s", strdate, "enregistrement")
|
||||
Enregistre(filename)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user