-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathseries.go
51 lines (40 loc) · 1.13 KB
/
series.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
package main
import (
"github.com/pboehm/series/config"
"github.com/pboehm/series/util"
"github.com/spf13/cobra"
"log"
"os"
"path"
)
var LOG = log.New(os.Stderr, "", 0)
func HandleError(err error) {
if err != nil {
LOG.Fatalf("Error during execution: %s", err)
}
}
var configDirectory, configFile, customEpisodeDirectory string
var defaultConfig, appConfig config.Config
func setupConfig() {
configDirectory = path.Join(util.HomeDirectory(), ".series")
configFile = path.Join(configDirectory, "config.json")
defaultConfig = config.Config{
EpisodeDirectory: path.Join(util.HomeDirectory(), "Downloads"),
IndexFile: path.Join(configDirectory, "index.xml"),
ScriptExtractors: []string{},
}
appConfig = config.GetConfig(configFile, defaultConfig)
}
var seriesCmd = &cobra.Command{
Use: "series",
Run: renameAndIndexHandler,
}
func init() {
seriesCmd.PersistentFlags().StringVarP(&customEpisodeDirectory, "dir", "d", "",
"The directory which includes the episodes. (Overrides the config value)")
}
func main() {
setupConfig()
seriesCmd.AddCommand(renameAndIndexCmd, indexCmd, streamsCmd)
seriesCmd.Execute()
}