aboutsummaryrefslogtreecommitdiff
path: root/internal/pvfm/fname.go
blob: fa84695c2745f88470a9fd80aeccb7a4a37d4a78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package pvfm

import (
	"fmt"
	"strings"
	"time"

	"within.website/x/internal/pvfm/pvl"
)

func GenFilename() (string, error) {
	cal, err := pvl.Get()
	if err != nil {
		return "", nil
	}

	now := cal.Result[0]

	localTime := time.Now()
	thentime := time.Unix(now.StartTime, 0)
	if thentime.Unix() < localTime.Unix() {
		// return fmt.Sprintf("%s - %s.mp3", now.Title, localTime.Format(time.RFC822)), nil
	}

	now.Title = strings.Replace(now.Title, "/", "-slash-", 0)

	return fmt.Sprintf("%s - %s.mp3", now.Title, localTime.Format(time.RFC822)), nil
}