-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
67 lines (55 loc) · 1.45 KB
/
main.go
File metadata and controls
67 lines (55 loc) · 1.45 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package main
import (
"log"
"os"
createQuoteVideo "videoCreater/createQuoteVideo"
createRedditVideo "videoCreater/createRedditVideo"
"github.com/joho/godotenv"
)
func init() {
initConfig()
}
func main() {
// Checks if the minimum number of arguments is not met
if len(os.Args) < 2 {
log.Println("Usage: videocreater <videotype> [extra info]")
os.Exit(1)
}
videoType := os.Args[1]
switch videoType {
case "quote":
createQuoteVideo.CreateQuoteVideo()
case "reddit":
// Ensure that subreddit argument is also provided
if len(os.Args) < 3 {
log.Println("videotype 'reddit' requires the subreddit name as well")
os.Exit(1)
}
createRedditVideo.CreateRedditVideo(os.Args[2])
default:
log.Println("Unknown videotype. Use 'quote' or 'reddit'.")
os.Exit(1) // Exit after logging the unknown type error
}
}
// Initialize environment and verify configuration
func initConfig() {
godotenv.Load()
// Check if the API key is set
apiKey := os.Getenv("GOOGLE_API_KEY")
if apiKey == "" {
log.Fatalf("GOOGLE_API_KEY environment variable is not set")
}
// Ensure necessary directories exist
ensureDirExists("raw-videos")
ensureDirExists("edited-videos")
ensureDirExists("text-to-speeched")
ensureDirExists("logos")
}
// Ensure directory exists
func ensureDirExists(dir string) {
if _, err := os.Stat(dir); os.IsNotExist(err) {
if err := os.Mkdir(dir, 0755); err != nil {
log.Fatalf("Failed to create directory %s: %v", dir, err)
}
}
}