-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathmain.go
More file actions
100 lines (91 loc) · 4.49 KB
/
main.go
File metadata and controls
100 lines (91 loc) · 4.49 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
package main
import (
"flag"
"fmt"
"net/http"
"os"
"os/exec"
"starchive/audio"
"starchive/handlers"
"starchive/util"
"starchive/web"
)
var downloadQueue *web.DownloadQueue
var downloadVideos bool
func updateYtDlp() {
fmt.Println("Updating yt-dlp...")
updateCmd := exec.Command("python3", "-m", "pip", "install", "-U", "yt-dlp")
output, err := updateCmd.CombinedOutput()
if err != nil {
fmt.Printf("Warning: Failed to update yt-dlp: %v\n", err)
fmt.Printf("Output: %s\n", output)
} else {
fmt.Println("yt-dlp updated successfully")
fmt.Printf("Output: %s\n", output)
}
}
func main() {
// Simple subcommand dispatch: first arg is the command
if len(os.Args) < 2 {
fmt.Println("Usage: starchive <command> [args]\n\nCommands:\n run Start the server (default features)\n ls List files in ./data\n dl Download video with given ID\n external Import external audio file to data directory\n vocal Extract vocals from audio file using audio-separator\n bpm Analyze BPM and key of vocal and instrumental files\n hz Analyze frequency characteristics of audio files\n sync Synchronize two audio files for mashups using rubberband\n split Split audio file by silence detection\n rm Remove all files with specified id from ./data\n play Play a wav file starting from the middle (press any key to stop)\n demo Create 30-second demo with +3 pitch shift from middle of track\n blend Interactive blend shell for mixing two tracks\n blend-clear Clear blend metadata for track combinations\n retry Retry downloading specific components (vtt, json, thumbnail, video) for a given ID\n ul Upload mp4 to YouTube using the given ID\n small Create small optimized video from data/id.mp4\n podpapyrus Download thumbnail and VTT, create text file from given ID")
os.Exit(1)
}
cmd := os.Args[1]
switch cmd {
case "run":
runCmd := flag.NewFlagSet("run", flag.ExitOnError)
runCmd.BoolVar(&downloadVideos, "download-videos", true, "Download full videos; if false, only subtitles and thumbnails")
// Parse flags after the subcommand
if err := runCmd.Parse(os.Args[2:]); err != nil {
fmt.Println("Error parsing flags:", err)
os.Exit(2)
}
updateYtDlp()
downloadQueue = web.NewDownloadQueue()
web.SetupRoutes(downloadQueue)
fmt.Println("Server starting on port 3009...")
if err := http.ListenAndServe(":3009", nil); err != nil {
fmt.Printf("Server error: %v\n", err)
os.Exit(1)
}
case "ls":
handlers.HandleLs()
case "dl":
updateYtDlp()
handlers.HandleDl()
case "external":
handlers.HandleExternal()
case "vocal", "vocals":
handlers.HandleVocal()
case "bpm":
handlers.HandleBpm()
case "hz":
handlers.HandleHz()
case "sync":
handlers.HandleSync()
case "split":
audio.HandleSplitCommand(os.Args[2:])
case "rm":
util.HandleRmCommand(os.Args[2:])
case "play":
audio.HandlePlayCommand(os.Args[2:])
case "demo":
audio.HandleDemoCommand(os.Args[2:])
case "blend":
handlers.HandleBlend()
case "blend-clear":
handlers.HandleBlendClear()
case "retry":
util.HandleRetryCommand(os.Args[2:])
case "ul":
handlers.HandleUl()
case "small":
handlers.HandleSmall()
case "podpapyrus":
handlers.HandlePodpapyrus()
default:
fmt.Printf("Unknown command: %s\n", cmd)
fmt.Println("Usage: starchive <command> [args]\n\nCommands:\n run Start the server (default features)\n ls List files in ./data\n dl Download video with given ID\n external Import external audio file to data directory\n vocal Extract vocals from audio file using audio-separator\n bpm Analyze BPM and key of vocal and instrumental files\n hz Analyze frequency characteristics of audio files\n sync Synchronize two audio files for mashups using rubberband\n split Split audio file by silence detection\n rm Remove all files with specified id from ./data\n play Play a wav file starting from the middle (press any key to stop)\n demo Create 30-second demo with +3 pitch shift from middle of track\n blend Interactive blend shell for mixing two tracks\n blend-clear Clear blend metadata for track combinations\n retry Retry downloading specific components (vtt, json, thumbnail, video) for a given ID\n ul Upload mp4 to YouTube using the given ID\n small Create small optimized video from data/id.mp4\n podpapyrus Download thumbnail and VTT, create text file from given ID")
os.Exit(1)
}
}