-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
89 lines (78 loc) · 2.67 KB
/
main.go
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
package main
import (
"bytes"
_ "embed"
"github.com/boggydigital/clo"
"github.com/boggydigital/nod"
"github.com/boggydigital/pathways"
"github.com/boggydigital/yet/cli"
"github.com/boggydigital/yet/data"
"os"
)
var (
//go:embed "cli-commands.txt"
cliCommands []byte
//go:embed "cli-help.txt"
cliHelp []byte
)
const (
dirOverridesFilename = "directories.txt"
)
func main() {
nod.EnableStdOutPresenter()
ya := nod.Begin("yet is serving your videos needs")
defer ya.End()
if err := pathways.Setup(dirOverridesFilename,
data.DefaultYetRootDir,
nil,
data.AllAbsDirs...); err != nil {
_ = ya.EndWithError(err)
os.Exit(1)
}
defs, err := clo.Load(
bytes.NewBuffer(cliCommands),
bytes.NewBuffer(cliHelp),
nil)
if err != nil {
_ = ya.EndWithError(err)
os.Exit(1)
}
clo.HandleFuncs(map[string]clo.Handler{
"add-channel": cli.AddChannelHandler,
"add-playlist": cli.AddPlaylistHandler,
"add-video": cli.AddVideoHandler,
"backup": cli.BackupHandler,
"cleanup-ended-videos": cli.CleanupEndedVideosHandler,
"dehydrate-posters": cli.DehydratePostersHandler,
"download-video": cli.DownloadVideoHandler,
"get-captions": cli.GetCaptionsHandler,
"get-channels-metadata": cli.GetChannelsMetadataHandler,
"get-playlists-metadata": cli.GetPlaylistsMetadataHandler,
"get-poster": cli.GetPosterHandler,
"get-rutube-video": cli.GetRuTubeVideoHandler,
"get-video-metadata": cli.GetVideoMetadataHandler,
"process-queue": cli.ProcessQueueHandler,
"migrate": cli.MigrateHandler,
"queue-channels-downloads": cli.QueueChannelsDownloadsHandler,
"queue-playlists-downloads": cli.QueuePlaylistsDownloadsHandler,
"refresh-channels-metadata": cli.RefreshChannelsMetadataHandler,
"refresh-playlists-metadata": cli.RefreshPlaylistsMetadataHandler,
"remove-channel": cli.RemoveChannelHandler,
"remove-playlist": cli.RemovePlaylistHandler,
"remove-videos": cli.RemoveVideosHandler,
"scrub-deposition-properties": cli.ScrubDepositionPropertiesHandler,
"scrub-ended-properties": cli.ScrubEndedPropertiesHandler,
"serve": cli.ServeHandler,
"sync": cli.SyncHandler,
"update-yt-dlp": cli.UpdateYtDlpHandler,
"version": cli.VersionHandler,
})
if err := defs.AssertCommandsHaveHandlers(); err != nil {
_ = ya.EndWithError(err)
os.Exit(1)
}
if err := defs.Serve(os.Args[1:]); err != nil {
_ = ya.EndWithError(err)
os.Exit(1)
}
}