Skip to content

Commit

Permalink
Update super users and refactor episode number detection
Browse files Browse the repository at this point in the history
  • Loading branch information
umputun committed Jan 2, 2024
1 parent 2768cad commit 0925389
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 17 deletions.
4 changes: 2 additions & 2 deletions publisher/app/cmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 [email protected]", fmt.Sprintf(`docker exec -i super-bot /srv/telegram-rt-bot %s --dbg --export-num=%d --export-path=/srv/html`,
Expand Down
5 changes: 3 additions & 2 deletions publisher/app/cmd/deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 [email protected]`, 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) {
Expand Down
File renamed without changes.
File renamed without changes.
7 changes: 2 additions & 5 deletions publisher/app/cmd/proc.go → publisher/app/cmd/proc_mp3.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down
File renamed without changes.
19 changes: 11 additions & 8 deletions publisher/app/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 0925389

Please sign in to comment.