all repos — gopipe @ e52ebbb0058a735dc63d53c92024f696a6c3de34

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
 9func getEnvDefault(key string, def string) string {
10	res := os.Getenv(key)
11	if res == "" {
12		return def
13	}
14	return res
15}
16
17func parseBool(s string) bool {
18	return strings.ToLower(s) == "true" || s == "1"
19}
20
21func getFormatID(s string) int {
22	formatID, err := strconv.ParseUint(s, 10, 64)
23	if err != nil {
24		formatID = 0
25	}
26	return int(formatID)
27}