all repos — gopipe @ 72f5236b15f0ae2fd00b01b36a7bce52dbd2c429

Embed YouTube videos on Telegram, Discord and more!

src/app/utils.go (view raw)

 1package app
 2
 3import (
 4	"os"
 5	"strconv"
 6	"strings"
 7)
 8
 9type Captions struct {
10	VideoID  string
11	Language string
12	URL      string
13}
14
15func getEnvDefault(key string, def string) string {
16	res := os.Getenv(key)
17	if res == "" {
18		return def
19	}
20	return res
21}
22
23func parseBool(s string) bool {
24	return strings.ToLower(s) == "true" || s == "1"
25}
26
27func getFormatID(s string) int {
28	formatID, err := strconv.ParseUint(s, 10, 64)
29	if err != nil {
30		formatID = 1
31	}
32	return int(formatID)
33}