diff --git a/publisher/app/cmd/deploy.go b/publisher/app/cmd/deploy.go index 2dbfb5b0..df752d53 100644 --- a/publisher/app/cmd/deploy.go +++ b/publisher/app/cmd/deploy.go @@ -21,7 +21,7 @@ type Deploy struct { Dry bool } -var supers = []string{"umputun", "bobuk", "ksenks", "grayodesa"} +var superUsersTelegram = []string{"umputun", "bobuk", "ksenks", "grayodesa", "aleks_sys"} // Do performs a series of actions to deploy a new episode. // It takes an episode number as input and returns an error if any of the actions fail. @@ -39,7 +39,7 @@ func (d *Deploy) Do(episodeNum int) error { log.Printf("[INFO] create chat log") slParams := []string{} - for _, s := range supers { + for _, s := range superUsersTelegram { slParams = append(slParams, fmt.Sprintf("--super=%s", s)) } d.Run("ssh umputun@master.radio-t.com", fmt.Sprintf(`docker exec -i super-bot /srv/telegram-rt-bot %s --dbg --export-num=%d --export-path=/srv/html`, diff --git a/publisher/app/cmd/deploy_test.go b/publisher/app/cmd/deploy_test.go index 67262682..51033ae2 100644 --- a/publisher/app/cmd/deploy_test.go +++ b/publisher/app/cmd/deploy_test.go @@ -40,8 +40,9 @@ func TestDeploy_Do(t *testing.T) { assert.Equal(t, `cd /srv/site.hugo && git pull && docker-compose run --rm hugo`, ex.RunCalls()[1].Params[0]) assert.Equal(t, `ssh umputun@master.radio-t.com`, ex.RunCalls()[2].Cmd) - assert.Equal(t, []string{"docker exec -i super-bot /srv/telegram-rt-bot --super=umputun --super=bobuk --super=ksenks --super=grayodesa --dbg --export-num=123 --export-path=/srv/html"}, ex.RunCalls()[2].Params) - + assert.Equal(t, []string{"docker exec -i super-bot /srv/telegram-rt-bot " + + "--super=umputun --super=bobuk --super=ksenks --super=grayodesa --super=aleks_sys " + + "--dbg --export-num=123 --export-path=/srv/html"}, ex.RunCalls()[2].Params) } func TestDeploy_archiveNews(t *testing.T) { diff --git a/publisher/app/cmd/prep.go b/publisher/app/cmd/prep_post.go similarity index 100% rename from publisher/app/cmd/prep.go rename to publisher/app/cmd/prep_post.go diff --git a/publisher/app/cmd/prep_test.go b/publisher/app/cmd/prep_post_test.go similarity index 100% rename from publisher/app/cmd/prep_test.go rename to publisher/app/cmd/prep_post_test.go diff --git a/publisher/app/cmd/proc.go b/publisher/app/cmd/proc_mp3.go similarity index 98% rename from publisher/app/cmd/proc.go rename to publisher/app/cmd/proc_mp3.go index 1d640c30..da0bfb0f 100644 --- a/publisher/app/cmd/proc.go +++ b/publisher/app/cmd/proc_mp3.go @@ -33,11 +33,6 @@ type Proc struct { var authors = []string{"Umputun", "Bobuk", "Gray", "Ksenks", "Alek.sys"} // Do uploads an episode to all destinations. It takes an episode number as input and returns an error if any of the actions fail. -// It performs the following actions: -// 1. Set mp3 tags. -// 2. Deploy to master. -// 3. Deploy to nodes. -// // deploy performed by spot tool, see spot.yml func (p *Proc) Do(episodeNum int) error { log.Printf("[INFO] upload episode %d, mp3 location:%q, posts location:%q", episodeNum, p.LocationMp3, p.LocationPosts) @@ -226,6 +221,8 @@ func (p *Proc) parseChapters(content string) ([]chapter, error) { return chapters, nil } +// getMP3Duration returns the duration of an MP3 file given its file path. +// It takes the file path as an input and returns the duration as a time.Duration and an error if any. func (p *Proc) getMP3Duration(filePath string) (time.Duration, error) { file, err := os.Open(filePath) if err != nil { diff --git a/publisher/app/cmd/proc_test.go b/publisher/app/cmd/proc_mp3_test.go similarity index 100% rename from publisher/app/cmd/proc_test.go rename to publisher/app/cmd/proc_mp3_test.go diff --git a/publisher/app/main.go b/publisher/app/main.go index 46483990..f2792cc3 100644 --- a/publisher/app/main.go +++ b/publisher/app/main.go @@ -60,26 +60,29 @@ func main() { setupLog(opts.Dbg) - episodeNum, err := episode() - if err != nil { - log.Fatalf("[ERROR] can't get last podcast number, %v", err) + episodeNum := func() int { + num, err := episode() + if err != nil { + log.Fatalf("[ERROR] can't get last podcast number, %v", err) + } + log.Printf("[DEBUG] detcted episode: %d", num) + return num } - log.Printf("[DEBUG] detcted episode: %d", episodeNum) if p.Active != nil && p.Command.Find("new") == p.Active { - runNew(episodeNum) + runNew(episodeNum()) } if p.Active != nil && p.Command.Find("prep") == p.Active { - runPrep(episodeNum) + runPrep(episodeNum()) } if p.Active != nil && p.Command.Find("proc") == p.Active { - runProc(episodeNum) + runProc(episodeNum()) } if p.Active != nil && p.Command.Find("deploy") == p.Active { - runDeploy(episodeNum) + runDeploy(episodeNum()) } if p.Active != nil && p.Command.Find("tags") == p.Active {